home
|
featured sketchers
|
gallery
write a sketch
|
community
|
Copy sketch
Printouts
/** * Draw some lines like MC Escher would have... * by Evan Rakob AKA PixelPusher * // http://pixelist.info **/ // the initial spacing between lines, in pixels float spacing = 1f; // line width in pixels (from middle of line) int lineWidth = 1; // the multiplier for the spacing of successive lines float spaceMult = 1.001f; boolean mouseDown = false; int[] startMouse = new int[2]; int[] lastMouse = new int[2]; void setup() { size(360, 240); background(0); strokeWeight(lineWidth); spacing = 1f; lineWidth = 1; spaceMult = 1.001f; mouseDown = false; startMouse = new int[2]; lastMouse = new int[2]; startMouse[0] = -1; startMouse[1] = -1; } void draw() { background(0); if (mouseDown) { if (lastMouse[1] != mouseY) { spaceMult += (startMouse[1]-mouseY)*0.001; spaceMult = max(spaceMult, 1.001); lastMouse[1] = mouseY; } else { startMouse[1] = mouseY; } } int ctr=0; // counter var float space = spacing; //first draw white bg below fill(255); noStroke(); rect(0, 0, width, height*0.5); // draw black lines from center to top ctr = int(height*0.5-space); strokeWeight(lineWidth); stroke(0); while (ctr > 0) { line(0, ctr, width, ctr); ctr -= int(2*space); space *= spaceMult; } // draw white lines from center to bottom stroke(255); space = spacing; ctr = int(height*0.5-space); while (ctr < height) { line(0, ctr, width, ctr); ctr += int(2*space); space *= spaceMult; } } void mousePressed() { startMouse[0] = mouseX; startMouse[1] = mouseY; lastMouse[0] = startMouse[0]; lastMouse[1] = startMouse[1]; mouseDown = true; } void mouseReleased() { mouseDown = false; }
Sketches you submit on sketchPatch will be licensed under the
Creative Commons Attribution 3.0 Unported License
. If you upload code based on other people's work, please check the licence compatibility.
Ooops, found some glitches.
Write your sketch here
Check the Processing language
reference
(
most
of it works).
Need inspiration? Play with the examples in
the gallery
.
Title
Tags
Publish
(come on, let other people see your sketch!)
Your comments about the sketch
Inspired by M. C. Escher's prints, this was a common (I think) was of representing the perspective of the sky and ground receding into infinity using simple horizontal lines. Drag up and down on the sketch to change the line spacings.