首先使用PImage
来实例化对象,再经过loadImage
赋值,两层for
循环遍历图片上的像素点,每隔5个像素点,画一个直径为3的圆。颜色经过pic.get(x,y)
获取。函数
最后经过save
函数来保存图片。spa
PImage pic; int spacing=5; void setup(){ pic=loadImage("steve.jpeg"); size(706, 644); } void draw(){ for (int x=spacing; x<width; x+=spacing) { for (int y=spacing; y<height; y+=spacing) { color c=pic.get(x, y); fill(c); noStroke(); ellipse(x, y, spacing*0.6, spacing*0.6); } } save("image_2.jpg"); }