/* built with Studio Sketchpad: * https://sketchpad.cc * * observe the evolution of this sketch: * https://studio.sketchpad.cc/sp/pad/view/ro.zlvpwMRDJFC/rev.3 * * authors: * GoToLoop * license (unless otherwise specified): * creative commons attribution-share alike 3.0 license. * https://creativecommons.org/licenses/by-sa/3.0/ */ /** * Skulls (v2.0) * by Kristian_Johansen_87 (2014/Oct) * mod GoToLoop * * forum.processing.org/two/discussion/7760/ * load-an-array-of-images-and-display-them-randomly-in-the-canvas * * studio.processingtogether.com/sp/pad/export/ro.9D3bN1ux8U67I/latest */ static final int NUM = 10, FPS = 10; PImage skull; void setup() { size(800, 800, JAVA2D); noLoop(); frameRate(FPS); noSmooth(); imageMode(CORNER); skull = createSkull(); } void draw() { background(0); for (int i = 0; i++ != NUM; image(skull , random(width - skull.width), random(height - skull.height))); } void mousePressed() { redraw(); } void keyPressed() { redraw(); } PImage createSkull() { PGraphics pg = createGraphics(70, 80, JAVA2D); pg.beginDraw(); pg.smooth(4); pg.rectMode(CORNER); pg.ellipseMode(CENTER); pg.noStroke(); pg.fill(-1); pg.ellipse(35, 35, 70, 70); pg.rect(17, 65, 36, 15); pg.fill(0); pg.ellipse(18, 35, 17, 25); pg.ellipse(52, 35, 17, 25); pg.triangle(27, 51, 32, 51, 32, 61); pg.triangle(38, 51, 43, 51, 38, 61); pg.rect(23, 65, 3, 15); pg.rect(33, 65, 3, 15); pg.rect(43, 65, 3, 15); pg.endDraw(); return pg.get(); }