(二)利用processing绘制自定义图像
2016-02-14 21:11
471 查看
绘制自定义图案:
程序运行结果:
函数使用说明:
void setup(){
size(720, 480);
smooth();
strokeWeight(2);
background(0, 128, 255);
ellipseMode(RADIUS);
//neck
stroke(102);
line(266, 257, 266, 162);
line(276, 257, 276, 162);
line(286, 257, 286, 162);
//antenna
line(276, 155, 246, 112);
line(276, 155, 306, 56);
line(276, 155, 342, 170);
//body
noStroke();
fill(102);
ellipse(264, 377, 33, 33);
fill(0);
rect(219, 257, 90, 120);
fill(102);
rect(219, 274, 90, 6);
//head
fill(0);
ellipse(276, 155, 45, 45);
fill(255);
ellipse(288, 150, 14, 14);
fill(0);
ellipse(288, 150, 3, 3);
fill(153);
ellipse(263, 148, 5, 5);
ellipse(296, 130, 4, 4);
ellipse(305, 162, 3, 3);
saveFrame("Shape.png");
}程序运行结果:
函数使用说明:
函数运行和结果展示:
void setup(){ //绘制一个箭头 size(360, 100); background(0, 255, 0); fill(0, 0, 255); noStroke(); beginShape(); vertex(width/7, height/2); vertex(width/4, height/6); vertex(width/4, 2*height/6); vertex(5*width/6, 2*height/6); vertex(5*width/6, 4*height/6); vertex(width/4, 4*height/6); vertex(width/4, 5*height/6); endShape(CLOSE); saveFrame("Shape.png"); }
程序运行结果:
函数使用说明:
beginShape() -> vertex() -> endShape() //开始自定义图案绘制 -> 标记顶点像素 -> 结束自定义图案绘制,CLOSE参数 表示是封闭图案P5机器人绘制:
void setup(){
size(720, 480);
smooth();
strokeWeight(2);
background(0, 128, 255);
ellipseMode(RADIUS);
//neck
stroke(102);
line(266, 257, 266, 162);
line(276, 257, 276, 162);
line(286, 257, 286, 162);
//antenna
line(276, 155, 246, 112);
line(276, 155, 306, 56);
line(276, 155, 342, 170);
//body
noStroke();
fill(102);
ellipse(264, 377, 33, 33);
fill(0);
rect(219, 257, 90, 120);
fill(102);
rect(219, 274, 90, 6);
//head
fill(0);
ellipse(276, 155, 45, 45);
fill(255);
ellipse(288, 150, 14, 14);
fill(0);
ellipse(288, 150, 3, 3);
fill(153);
ellipse(263, 148, 5, 5);
ellipse(296, 130, 4, 4);
ellipse(305, 162, 3, 3);
saveFrame("Shape.png");
}程序运行结果:
函数使用说明:
ellipseMode() //CENTER 设置 x,y 表示中心点,width、height表示椭圆的 长度 和 宽度 //RADIUS 设置 x,y 表示中心点,width、height表示椭圆的 长度的一半和宽度的一半 //CORNER 设置 x,y 为椭圆的左上角,width、 height表示椭圆的 长度 和 宽度 //CORNERS 这个不太能理解(ellipseMode(CORNERS) interprets the first two parameters of ellipse() as the location of one corner of the ellipse's bounding box, and the third and fourth parameters as the location of the opposite corner.)
函数运行和结果展示:
void setup(){ size(100, 100); ellipseMode(RADIUS); fill(255); ellipse(50, 50, 30, 30); ellipseMode(CENTER); fill(100); ellipse(50, 50, 30, 30); } #################################################### void setup(){ size(100, 100); ellipseMode(CORNER); fill(255); ellipse(25, 25, 50, 50); ellipseMode(CORNERS); fill(100); ellipse(25, 25, 50, 50); saveFrame("Shape.png"); }
相关文章推荐
- Linux socket 初步
- Linux Kernel 4.0 RC5 发布!
- linux lsof详解
- linux 文件权限
- Linux 执行数学运算
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- Ubuntu Linux使用体验
- c语言实现hashmap(转载)
- Linux 信号signal处理机制
- linux下mysql添加用户
- Scientific Linux 5.5 图形安装教程
- Linux 下无损图片压缩小工具介绍