资源描述:
《processing图片和音频载入.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、别忘记如何进行图片的载入和动画Jpg是最常见的数码相机和手机用图片格式。PImagephoto;voidsetup(){size(300,300);photo=loadImage("jp.jpg");background(120,125,10);stroke(0);strokeWeight(4);}voiddraw(){copy(photo,30,130,150,150,0,100,width,100);line(0,100,width,100);line(0,200,width,200);}PI
2、magephoto;voidsetup(){size(300,300);photo=loadImage("jp.jpg");background(120,125,10);stroke(0);strokeWeight(4);}voiddraw(){copy(photo,30,int(random(130)),150,150,0,100,width,100);//将float型转换成Int型。因为copy()里必须全是int型,而random()是float型。line(0,100,width,100
3、);line(0,200,width,200);}音频的载入如果你查reference里会发现,没有sound()或者audio(),但是importddf.minim.*;Minimminim;AudioSampleweather;intx=130;inty=100;intdx=5;intdy=5;voidsetup(){size(400,300);fill(255,0,0);noStroke();smooth();minim=newMinim(this);weather=minim.loadS
4、ample("weather.mp3",2048);}voiddraw(){background(255);ellipse(x,y,50,50);x+=dx;y+=dy;if(x>width){x=width;dx=-dx;weather.trigger();}if(x<0){x=0;dx=-dx;weather.trigger();}if(y>height){y=height;dy=-dy;weather.trigger();}if(y<0){y=0;dy=-dy;weather.trigger
5、();}}voidstop(){weather.close();minim.stop();super.stop();}