Edward Delaporte created this art using the P5.js JavaScript library, and the following additional code:
/* This is a Live Art work created by Edward Delaporte. This script is Copyright Edward Delaporte 2023. This script and the art it creates are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. http://creativecommons.org/licenses/by-sa/4.0/ You can share your own remix of this code as long as you display this license and attribution. */ function start_fractal() { line_bit = new_line_segment(color(0,0,0)); line_bit.y = 200; line_bit.length = 70; line_bit.x = 300; line_bit.degrees = 0; roty = random(40, 170); do_fractal(line_bit); line_bit.degrees += roty; do_fractal(line_bit); line_bit.degrees += roty; do_fractal(line_bit); /* line_bit.degrees += roty; do_fractal(line_bit); line_bit.degrees += roty; do_fractal(line_bit); */ } async function do_fractal(bit) { stroke(random(150, 255),random(150,255),random(150, 255)); const next_bit = structuredClone(draw_line_segment(bit)); next_bit.length = next_bit.length*.67; next_bit.weight = next_bit.weight*.67; next_bit.degrees = add_degrees(bit.degrees, 45); if(next_bit.length > 1) { await do_fractal(next_bit); const bit2 = structuredClone(next_bit); bit2.degrees = add_degrees(bit.degrees, -90); await do_fractal(bit2); } } function setup() { // maxim = .5 * window.innderWidth; maxim_x = 600; maxim_y = 400; midline = maxim_y / 2; myCanvas = createCanvas(maxim_x, maxim_y); tile_background(maxim_x, maxim_y); //make_horizon(0, 0, maxim_x, maxim_y); // draw_horizon(0, 0, maxim_x, maxim_y); // setup_season(); // draw_ground(myCanvas, maxim_y /2); start_fractal(); console.log("setup done"); } function draw() { } function mouseClicked() { // background(220); // spinny(mouseX, mouseY, 20) }
function toRadians (angle) { return angle * (Math.PI / 180); } function add_degrees(angle, degrees) { updated = angle + degrees; if(updated > 360) { updated = updated - 360; } return updated; } var line_segment = { x: 0, y: 0, weight: 4, degrees: 0, length: 20, history: 0, color: null, color_seq: [], }; function draw_line_segment(line_seg, hide=0) { seg = structuredClone(line_seg); seg.history+=1; // stroke(seg.color.red, seg.color.green, seg.color.blue); strokeWeight(seg.weight); angleRad = toRadians(seg.degrees); endx = seg.x + seg.length*Math.cos(angleRad); endy = seg.y + seg.length*Math.sin(angleRad); if(hide==0) { line(seg.x, seg.y, endx, endy); } next_seg = structuredClone(seg); next_seg.x = endx; next_seg.y = endy; return next_seg; } function draw_line_cross(line_seg, dx, dy, hide=0) { seg = structuredClone(line_seg); seg.history+=1; strokeWeight(seg.weight); angleRad = toRadians(seg.degrees + 90); endx = seg.x + .5*seg.length*Math.cos(angleRad); endy = seg.y + .5*seg.length*Math.sin(angleRad); startx = seg.x - .5*seg.length*Math.cos(angleRad); starty = seg.y - .5*seg.length*Math.sin(angleRad); if(hide==0) line(startx+dx, starty+dy, endx+dx, endy+dy); /* next_seg = structuredClone(seg); next_seg.x = endx; next_seg.y = endy; return next_seg; */ } function draw_line_with_kite_shadow(line_seg, color_seq) { // prep seg = structuredClone(line_seg); angleRad = toRadians(seg.degrees); endx = seg.x + seg.length*Math.cos(angleRad); endy = seg.y + seg.length*Math.sin(angleRad); if(line_seg.history > 0) { // skip first line // draw shadow shadow_idx = (seg.history % color_seq.length); sha_c = color_seq[shadow_idx]; stroke(sha_c.red, sha_c.green, sha_c.blue); fill(sha_c); swe = seg.weight*16; quad( seg.x,seg.y, seg.x+swe,seg.y+swe, endx,endy, endx+swe,endy+swe ); // draw line stroke(seg.color.red, seg.color.green, seg.color.blue); strokeWeight(seg.weight); line(seg.x, seg.y, endx, endy); } else { endx = seg.x; endy = seg.y; } // house keeping seg.history+=1; next_seg = structuredClone(seg); next_seg.x = endx; next_seg.y = endy; return next_seg; } function new_line_segment(color_seq) { seg = structuredClone(line_segment); seg.color_seq = color_seq; seg.color = seg.color_seq[0]; return seg; }
function tile_background(maxim_x, maxim_y) { line_shade = 70; stroke(line_shade, line_shade, line_shade); fill(150,50,50); background(maxim_x,maxim_y); xp = 0; yp = 0; min_tile_size = maxim_y; while(yp<maxim_y) { tile_size = random(40,100); console.log("size" + tile_size); if(tile_size < min_tile_size) { min_tile_size = tile_size; console.log("min tile is now " + min_tile_size); } rect(xp, yp, xp+tile_size, yp+tile_size); xp += tile_size; if(xp>maxim_x) { xp=0; yp+=min_tile_size; min_tile_size = maxim_y; } } }
This work ©2020-2024 by Edward Delaporte is licensed under CC BY-NC-SA 4.0