From 8340996aff60d18d77fbe3d709d91019ec7b37eb Mon Sep 17 00:00:00 2001 From: bbaudry Date: Tue, 24 Dec 2024 16:08:25 -0500 Subject: [PATCH] +][]><[][+ --- p5-experiments/sapin/plottablesapin.js | 10 +- p5-experiments/sapin/sapin001.js | 110 +- p5-experiments/sapin/sapin002.gcode | 2782 ++++++++++++++++++++++++ p5-experiments/sapin/sapin002.html | 23 + p5-experiments/sapin/sapin002.js | 75 + p5-experiments/sapin/sapin002.svg | 1 + 6 files changed, 2975 insertions(+), 26 deletions(-) create mode 100644 p5-experiments/sapin/sapin002.gcode create mode 100644 p5-experiments/sapin/sapin002.html create mode 100644 p5-experiments/sapin/sapin002.js create mode 100644 p5-experiments/sapin/sapin002.svg diff --git a/p5-experiments/sapin/plottablesapin.js b/p5-experiments/sapin/plottablesapin.js index 1fe81669..02049658 100644 --- a/p5-experiments/sapin/plottablesapin.js +++ b/p5-experiments/sapin/plottablesapin.js @@ -1,17 +1,17 @@ //pixel = dpi * mm / 25.4 mm //each of the 5 sections is 120mm × 170mm //96dpi is for plotting on the UUNA TEK iDraw -//w=96*8.5=816 -//h=96*11=1056 +//w=96*6.5=624 +//h=96*4=384 //padding=96*45/25=172 var echelle = 1 -var w = 816 * echelle -var h = 706 * echelle +var w = 624 * echelle +var h = 384 * echelle var rightmargin = 0.95 * w var leftmargin = 0.05 * w var topmargin = 0.05 * h -var bottommargin = 0.7 * h +var bottommargin = 0.95 * h var actualwidth = rightmargin - leftmargin var actualheight = bottommargin - topmargin var cnv, imgbtn diff --git a/p5-experiments/sapin/sapin001.js b/p5-experiments/sapin/sapin001.js index 3c0217d8..7353ff0e 100644 --- a/p5-experiments/sapin/sapin001.js +++ b/p5-experiments/sapin/sapin001.js @@ -33,60 +33,78 @@ function drawart() { diam = actualheight * 0.84 //wheel(cx1+2, cy1, diam*0.99) //wheel(cx2, cy2, diam*1.01) - grid(leftmargin,topmargin,rightmargin,topmargin,rightmargin,bottommargin,leftmargin,bottommargin,0) - //pyramide(leftmargin,topmargin,rightmargin,topmargin,rightmargin,bottommargin,leftmargin,bottommargin) + if (random()<0.5){ + grid(leftmargin,topmargin,rightmargin,topmargin,rightmargin,bottommargin,leftmargin,bottommargin,sunrise,0) +} +else{ + grid(leftmargin,topmargin,rightmargin,topmargin,rightmargin,bottommargin,leftmargin,bottommargin,pyramide,0) +} } -function wheel(x,y,diam){ - var res=0.01 +function wheel(x1,y1,x2,y2,x3,y3,x4,y4){ + var res=0.1 + var cx1, cy1, cx2, cy2, diam + cx1 = x1+(x2-x1) * 0.48 + cy1 = y1+(y4-y1) * 0.48 + cx2 = x1+(x2-x1) * 0.52 + cy2 = y1+(y4-y1) * 0.52 + if((y4-y1)>(x2-x1)){ + diam = (x2-x1) * 0.84 + } + else{ + diam = (y4-y1) * 0.84 + } for(var i=res;i<=1;i+=res){ - ellipse(x,y,diam*i,diam*i) + ellipse(cx1,cy1,diam*i,diam*i) + ellipse(cx2,cy2,diam*i,diam*i) } +// quad(x1,y1,x2,y2,x3,y3,x4,y4) } -function grid(x1,y1,x2,y2,x3,y3,x4,y4,d){ - var proba = 0.42 - quad(x1,y1,x2,y2,x3,y3,x4,y4) +function grid(x1,y1,x2,y2,x3,y3,x4,y4,dessin,d){ + var proba = 0.52 if(d<2){ console.log("quad "+d) d++ var dx,dy dx=x1+(x2-x1)*random(0.21,0.42) - dy=y1+(y4-y1)*random(0.21,0.42) + dy=y1+(y4-y1)*random(0.31,0.42) if(random() + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/p5-experiments/sapin/sapin002.js b/p5-experiments/sapin/sapin002.js new file mode 100644 index 00000000..5b6ef740 --- /dev/null +++ b/p5-experiments/sapin/sapin002.js @@ -0,0 +1,75 @@ +function savesvg() { + save("sapin002.svg"); +} + +function savepng() { + save("sapin002.png"); +} + +function setup() { + getsvg() + //getpng() + centerCanvas(); + colorMode(HSB, 360, 100, 100, 250); + strokeCap(SQUARE) + noFill() + initgrid() +} + +var grid, res, nbcols, nbrows + +function initgrid() { + grid = [] + res=80 + nbcols = Math.floor(actualwidth / res) + nbrows = Math.floor(actualheight / res) + for (var i = 0; i < nbcols; i++) { + for (var j = 0; j < nbrows; j++) { + grid.push({ x: i * res, y: j * res }) + console.log("add one") + } + } +} + + +function draw() { + background(0, 0, 100) + stroke(0, 0, 0) + noFill() + //drawframe() + drawart() + noLoop() +} + +function drawgrid() { + translate(leftmargin,topmargin) + for (var i = 0; i < nbcols; i++) { + for (var j = 0; j < nbrows; j++) { + rect(grid[i*nbrows+j].x, grid[i*nbrows+j].y, res, res) + } + } +} + + +function drawart() { + translate(leftmargin,topmargin) + var x,y,cx,cy,initangle,diamy + for (var i = 0; i < nbcols; i++) { + for (var j = 0; j < nbrows; j++) { + x=grid[i*nbrows+j].x + y=grid[i*nbrows+j].y + cx=x+res/2 + cy=y+res/2 + initangle=Math.floor(random(180)) + diamy=res*random(0.5,0.8) + for(var a=initangle;a \ No newline at end of file