1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /* built with Studio Sketchpad: * * observe the evolution of this sketch: * * authors: * GoToLoop * license (unless otherwise specified): * creative commons attribution-share alike 3.0 license. */ /** * Mouse Trace Array (v1.0) * by GoToLoop (2014/Mar) * * forum.processing.org/two/discussion/3437/how-to-create-a-mouse-trace * * studio.processingtogether.com/sp/pad/export/ro.9ldYvJUyiXGzi/latest */ static final int NUM = 0300, NEWEST = NUM - 1; final int [] x = new int [NUM], y = new int [NUM]; void setup () { size (800, 600, JAVA2D ); colorMode ( RGB , NEWEST); frameRate (60); smooth (4); strokeWeight (1); mouseX = width >>1; mouseY = height >>1; for ( int i = NUM; i-- != 0; x[i] = mouseX , y[i] = mouseY ); } void draw () { background (0); for ( int i = 0; i != NEWEST;) { stroke (0, i, 0); line (x[i], y[i], x[i] = x[i + 1], y[i] = y[++i]); } x[NEWEST] = mouseX ; y[NEWEST] = mouseY ; } |