programmering:flower1-code
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>flower1</title> <script src="../libraries/p5.min.js" type="text/javascript"></script> <style> body {padding: 0; margin: 0;} canvas {vertical-align: top;} </style> <script> var t,t_direction; function setup() { createCanvas(400,400); background(0); stroke(255,100); strokeWeight(5); t=width/8; t_direction=1; } function drawOne(l) { line(0,0, l*cos(radians(67.5)),l*sin(radians(67.5))); line(l*cos(radians(67.5)),l*sin(radians(67.5)), 0,l*sin(radians(135))/sin(radians(22.5))); line(0,0, l*cos(radians(180-67.5)),l*sin(radians(180-67.5))); line(l*cos(radians(180-67.5)),l*sin(radians(180-67.5)), 0,l*sin(radians(135))/sin(radians(22.5))); } function draw() { background(0); translate(width/2,height/2); for (var i=0; i<64; i++) { rotate(radians(22.5*i/4)); drawOne(t); } if (t<width/8) { t_direction=1; } if (t>width/4) { t_direction=-1; } t=t+t_direction; } </script> </head> <body> </body> </html>
programmering/flower1-code.txt · Last modified: 2023/10/21 19:19 by 127.0.0.1