Created
October 10, 2018 01:44
-
-
Save GauntletWizard/02ea78a2a2a1c31fe455e6a4fb8ed05a to your computer and use it in GitHub Desktop.
Wall Drawing 273 SCAD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Wall Drawing 273 is an art piece by Sol LeWitt. | |
| // This open source implementation is by Ted Hahn. | |
| // This is generative art - Your viewing of it will be different than mine. I have included the positions of the walls because I am lazy and have not gotten around to making those random too, but the art on those walls is unique - You will not see the same image I did. | |
| // draftlines is the number of lines to draw from each side. | |
| draftlines = 10; | |
| // The line module draws a 2d line from start to end, where start and end are [x, y] pairs. | |
| module line (start, end, width=.1) { | |
| echo("start=", start, "end=", end); | |
| x0=start[0]; | |
| y0=start[1]; | |
| x1=end[0]; | |
| y1=end[1]; | |
| // Simple pythagorean | |
| length=pow( | |
| pow(x0 - x1, 2) + | |
| pow(y0 - y1, 2), | |
| 1/2); | |
| angle=atan((y1-y0)/ (x1-x0) ); | |
| echo("length is ", length); | |
| echo("angle is ", angle); | |
| translate([x0, y0, 0]) rotate(a=[0, 0, angle + (x1 >= x0? 0:180)]) | |
| translate([0, -width/2, 0]) | |
| square([length, width]); | |
| }; | |
| module redlines(x, y) { | |
| o = [0,y/2]; | |
| echo(o); | |
| color("red") { | |
| for( i = [0:draftlines]) { | |
| line(o, [round(rands(1, x, 1)[0]), round(rands(1, y, 1)[0])]); | |
| }; | |
| } | |
| } | |
| module red(x, y) { | |
| redlines(x, y); | |
| // I am expressing this translation wrong. No good reason - I'm bad at this math. | |
| translate([x, 0, 0]) rotate([0,0,90]) redlines(y, x); | |
| translate([x, y, 0]) rotate([0,0,180]) redlines(x, y); | |
| translate([0, y, 0]) rotate([0,0,270]) redlines(y, x); | |
| } | |
| /* | |
| module redlines(o, x, y) { | |
| color("red") { | |
| for( i = [0:draftlines]) { | |
| !line(o, [round(rands(1, x, 1)[0]), round(rands(1, y, 1)[0])]); | |
| }; | |
| } | |
| } | |
| module red(x, y) { | |
| redlines([x/2, 0], x, y); | |
| redlines([x, y/2], x, y); | |
| redlines([x/2, y], x, y); | |
| redlines([0, y/2], x, y); | |
| } | |
| */ | |
| *red(12,16); | |
| module bluelines(x, y) { | |
| color("blue") { | |
| for( i = [0:draftlines]) { | |
| line([0,0], [round(rands(1, x, 1)[0]), round(rands(1, y, 1)[0])] ); | |
| } | |
| } | |
| } | |
| module blue(x, y) { | |
| bluelines(x, y); | |
| // I am expressing this translation wrong. No good reason - I'm bad at this math. | |
| translate([x, 0, 0]) rotate([0,0,90]) bluelines(y, x); | |
| translate([x, y, 0]) rotate([0,0,180]) bluelines(x, y); | |
| translate([0, y, 0]) rotate([0,0,270]) bluelines(y, x); | |
| } | |
| *blue(12, 16); | |
| module yellow(x, y) { | |
| color("yellow") { | |
| for ( i = [0:draftlines * 4]) { | |
| line([x/2, y/2], [round(rands(0, x, 1)[0]), round(rands(0, y, 1)[0])]); | |
| } | |
| } | |
| } | |
| *yellow(12, 16); | |
| module wall(x,y) { | |
| rotate([-90,-90,0]) union() {color("white") square([x, y]); children(); }; | |
| } | |
| /* | |
| translate([0,0,0]) rotate([0,0,0]) wall(x,16) { | |
| y=16; | |
| red(x, y); | |
| blue(x, y); | |
| yellow(x, y); | |
| }; | |
| */ | |
| // Unified height | |
| x=12; | |
| translate([0,0,0]) rotate([0,0,0]) wall(x,16) { | |
| y=16; | |
| red(x, y); | |
| }; | |
| translate([16,0,0]) rotate([0,0,-30]) wall(x,7) { | |
| y=7; | |
| blue(x, y); | |
| }; | |
| translate([22,-4,0]) rotate([0,0,-60]) wall(x,16) { | |
| y=16; | |
| yellow(x, y); | |
| }; | |
| translate([0,-28,0]) rotate([0,0,90]) wall(x,16) { | |
| y=16; | |
| red(x, y); | |
| blue(x, y); | |
| }; | |
| translate([0,-28,0]) rotate([0,0,-45]) wall(x,16) { | |
| y=16; | |
| red(x, y); | |
| yellow(x, y); | |
| }; | |
| translate([12,-40,0]) rotate([0,0,25]) wall(x,16) { | |
| x=12; y=16; | |
| blue(x, y); | |
| yellow(x, y); | |
| }; | |
| translate([4,-9,0]) rotate([0,0,-45]) wall(x,16) { | |
| y=16; | |
| red(x, y); | |
| blue(x, y); | |
| yellow(x, y); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment