From 70421f763f947fa8d46db0b462ff26be1baa1de3 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 16 Mar 2022 00:51:43 +1300 Subject: [PATCH] started compartmentlising animations 0.1 --- Catalogue/Scripts/debugFunctions.js | 21 ++ Catalogue/floral inverse animation.html | 85 ++++++ Catalogue/floral tri tip touch.html | 80 ++++++ Catalogue/floral.html | 75 ++++++ Catalogue/foral accident.html | 83 ++++++ Catalogue/nodal expanding.html | 101 ++++++++ Catalogue/nodal.html | 88 +++++++ Catalogue/phyllotaxis.html | 98 +++++++ Catalogue/rectangle pattern 1.html | 86 +++++++ Catalogue/template.html | 79 +++--- Catalogue/triangle.html | 66 +++++ Python/ShapesStuff/nodal_pattern - Copy.py | 136 ++++++++++ .../nodal_pattern-DESKTOP-QKEHV8K.py | 133 ++++++++++ Python/ShapesStuff/nodal_pattern.py | 134 ++++++++++ animate 0.1 (deconstructing)/animation.html | 242 +++--------------- 15 files changed, 1270 insertions(+), 237 deletions(-) create mode 100644 Catalogue/Scripts/debugFunctions.js create mode 100644 Catalogue/floral inverse animation.html create mode 100644 Catalogue/floral tri tip touch.html create mode 100644 Catalogue/floral.html create mode 100644 Catalogue/foral accident.html create mode 100644 Catalogue/nodal expanding.html create mode 100644 Catalogue/nodal.html create mode 100644 Catalogue/phyllotaxis.html create mode 100644 Catalogue/rectangle pattern 1.html create mode 100644 Catalogue/triangle.html create mode 100644 Python/ShapesStuff/nodal_pattern - Copy.py create mode 100644 Python/ShapesStuff/nodal_pattern-DESKTOP-QKEHV8K.py create mode 100644 Python/ShapesStuff/nodal_pattern.py diff --git a/Catalogue/Scripts/debugFunctions.js b/Catalogue/Scripts/debugFunctions.js new file mode 100644 index 0000000..3bb3a85 --- /dev/null +++ b/Catalogue/Scripts/debugFunctions.js @@ -0,0 +1,21 @@ +function Draw_center() { + ctx.beginPath(); + ctx.moveTo(centerX - 100, centerY); + ctx.lineTo(centerX + 100, centerY); + ctx.moveTo(centerX, centerY - 100); + ctx.lineTo(centerX, centerY + 100); + ctx.strokeStyle = "red"; + ctx.stroke(); + console.log("drawn center") + } + + function DrawBorder(){ + ctx.beginPath(); + ctx.moveTo(0,0); + ctx.lineTo(ctx.canvas.width, 0); + ctx.lineTo(ctx.canvas.width, ctx.canvas.height); + ctx.lineTo(0, ctx.canvas.height); + ctx.lineTo(0,0); + ctx.strokeStyle = "red"; + ctx.stroke(); + } \ No newline at end of file diff --git a/Catalogue/floral inverse animation.html b/Catalogue/floral inverse animation.html new file mode 100644 index 0000000..9b34d03 --- /dev/null +++ b/Catalogue/floral inverse animation.html @@ -0,0 +1,85 @@ + + + + + + + Your browser does not support the HTML5 canvas tag. + + + + \ No newline at end of file diff --git a/Catalogue/floral tri tip touch.html b/Catalogue/floral tri tip touch.html new file mode 100644 index 0000000..8785654 --- /dev/null +++ b/Catalogue/floral tri tip touch.html @@ -0,0 +1,80 @@ + + + + + + + Your browser does not support the HTML5 canvas tag. + + + + \ No newline at end of file diff --git a/Catalogue/floral.html b/Catalogue/floral.html new file mode 100644 index 0000000..1983404 --- /dev/null +++ b/Catalogue/floral.html @@ -0,0 +1,75 @@ + + + + + + + Your browser does not support the HTML5 canvas tag. + + + + \ No newline at end of file diff --git a/Catalogue/foral accident.html b/Catalogue/foral accident.html new file mode 100644 index 0000000..2106ae7 --- /dev/null +++ b/Catalogue/foral accident.html @@ -0,0 +1,83 @@ + + + + + + + Your browser does not support the HTML5 canvas tag. + + + + \ No newline at end of file diff --git a/Catalogue/nodal expanding.html b/Catalogue/nodal expanding.html new file mode 100644 index 0000000..15b763e --- /dev/null +++ b/Catalogue/nodal expanding.html @@ -0,0 +1,101 @@ + + + + + + + Your browser does not support the HTML5 canvas tag. + + + + \ No newline at end of file diff --git a/Catalogue/nodal.html b/Catalogue/nodal.html new file mode 100644 index 0000000..93d888a --- /dev/null +++ b/Catalogue/nodal.html @@ -0,0 +1,88 @@ + + + + + + + Your browser does not support the HTML5 canvas tag. + + + + \ No newline at end of file diff --git a/Catalogue/phyllotaxis.html b/Catalogue/phyllotaxis.html new file mode 100644 index 0000000..7e78cd3 --- /dev/null +++ b/Catalogue/phyllotaxis.html @@ -0,0 +1,98 @@ + + + + + + + Your browser does not support the HTML5 canvas tag. + + + + \ No newline at end of file diff --git a/Catalogue/rectangle pattern 1.html b/Catalogue/rectangle pattern 1.html new file mode 100644 index 0000000..01cc751 --- /dev/null +++ b/Catalogue/rectangle pattern 1.html @@ -0,0 +1,86 @@ + + + + + + + Your browser does not support the HTML5 canvas tag. + + + + \ No newline at end of file diff --git a/Catalogue/template.html b/Catalogue/template.html index e91558d..fc17f45 100644 --- a/Catalogue/template.html +++ b/Catalogue/template.html @@ -1,44 +1,51 @@ - - - - Your browser does not support the HTML5 canvas tag. - - - + render(); + + + function render_clear() { + ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); + ctx.fillStyle = "black"; + ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height); + } + + + + + \ No newline at end of file diff --git a/Catalogue/triangle.html b/Catalogue/triangle.html new file mode 100644 index 0000000..6cf38ef --- /dev/null +++ b/Catalogue/triangle.html @@ -0,0 +1,66 @@ + + + + + + + Your browser does not support the HTML5 canvas tag. + + + + \ No newline at end of file diff --git a/Python/ShapesStuff/nodal_pattern - Copy.py b/Python/ShapesStuff/nodal_pattern - Copy.py new file mode 100644 index 0000000..9e21130 --- /dev/null +++ b/Python/ShapesStuff/nodal_pattern - Copy.py @@ -0,0 +1,136 @@ +from turtle import * +r = 1 +g = 0 +b = 0 +tup = (r,g,b) +pencolor(tup) +change_amount = 0.1 +changing_color = "r+" + +#begin_fill() +pendown() + + + +def step_color_rainbow(): + + global changing_color + global change_amount + global r + global g + global b + if(changing_color == "r+"): + r += change_amount + if(r>1): + r = 1 + changing_color = "b-" + elif(changing_color == "g+"): + g += change_amount + if(g>1): + g = 1 + changing_color = "r-" + elif(changing_color == "b+"): + b += change_amount + if(b>1): + b = 1 + changing_color = "g-" + if(changing_color == "r-"): + r -= change_amount + if(r<0): + r = 0 + changing_color = "b+" + elif(changing_color == "g-"): + g -= change_amount + if(g<0): + g = 0 + changing_color = "r+" + elif(changing_color == "b-"): + b -= change_amount + if(b<0): + b = 0 + changing_color = "g+" + + + + + + + + +def step_color_two(): + global r + global g + global b + global changing_color + + r1 = 0.07 + g1 = 0.02 + b1 = 0.35 + + r2 = 1 + g2 = 0.07 + b2 = 0.31 + + + c_amount = 100 + + rdiff = r2-r1 + gdiff = g2 - g1 + bdiff = b2 - b1 + + rchange = rdiff/c_amount + gchange = gdiff/c_amount + bchange = bdiff/c_amount + #print(f"{rchange} {gchange} {bchange}") + #print(f" {r} {g} {b}") + if(changing_color == "r+"): + r += rchange + g += gchange + b += bchange + else: + r -= rchange + g -= gchange + b -= bchange + + if(r >= r2): + r = r2 + g = g2 + b = b2 + changing_color = "r-" + elif(r <= r1): + r = r1 + g = g1 + b = b1 + changing_color = "r+" + +nodes = 999 +step = 330 +node_angle = 360/nodes +speed(0) +bgcolor("black") +def iterations(n,s): + i = 1 + while True: + x = s*i + if(x % n== 0) and (x>= n): + return i + else: + i += 1 + +#print(iterations(nodes,step)) +distance = 1 +flip = 1 +while True: + forward(distance * flip) + #flip *= -1 + right(step*node_angle) + #node_angle *= 1.0001 + if abs(pos()) < 1: + break + + #step_color_two() + #step_color_rainbow() + #print(f"{r} {g} {b}") + pencolor((r,g,b)) + distance +=1 +done() \ No newline at end of file diff --git a/Python/ShapesStuff/nodal_pattern-DESKTOP-QKEHV8K.py b/Python/ShapesStuff/nodal_pattern-DESKTOP-QKEHV8K.py new file mode 100644 index 0000000..88944de --- /dev/null +++ b/Python/ShapesStuff/nodal_pattern-DESKTOP-QKEHV8K.py @@ -0,0 +1,133 @@ +from turtle import * +r = 1 +g = 0 +b = 0 +tup = (r,g,b) +pencolor(tup) +change_amount = 0.1 +changing_color = "r+" + +#begin_fill() +pendown() + + + +def step_color_rainbow(): + + global changing_color + global change_amount + global r + global g + global b + if(changing_color == "r+"): + r += change_amount + if(r>1): + r = 1 + changing_color = "b-" + elif(changing_color == "g+"): + g += change_amount + if(g>1): + g = 1 + changing_color = "r-" + elif(changing_color == "b+"): + b += change_amount + if(b>1): + b = 1 + changing_color = "g-" + if(changing_color == "r-"): + r -= change_amount + if(r<0): + r = 0 + changing_color = "b+" + elif(changing_color == "g-"): + g -= change_amount + if(g<0): + g = 0 + changing_color = "r+" + elif(changing_color == "b-"): + b -= change_amount + if(b<0): + b = 0 + changing_color = "g+" + + + + + + + + +def step_color_two(): + global r + global g + global b + global changing_color + + r1 = 0.07 + g1 = 0.02 + b1 = 0.35 + + r2 = 1 + g2 = 0.07 + b2 = 0.31 + + + c_amount = 100 + + rdiff = r2-r1 + gdiff = g2 - g1 + bdiff = b2 - b1 + + rchange = rdiff/c_amount + gchange = gdiff/c_amount + bchange = bdiff/c_amount + #print(f"{rchange} {gchange} {bchange}") + #print(f" {r} {g} {b}") + if(changing_color == "r+"): + r += rchange + g += gchange + b += bchange + else: + r -= rchange + g -= gchange + b -= bchange + + if(r >= r2): + r = r2 + g = g2 + b = b2 + changing_color = "r-" + elif(r <= r1): + r = r1 + g = g1 + b = b1 + changing_color = "r+" + +nodes = 999 +step = 247 +node_angle = 360/nodes +speed(0) +bgcolor("black") +def iterations(n,s): + i = 1 + while True: + x = s*i + if(x % n== 0) and (x>= n): + return i + else: + i += 1 + +#print(iterations(nodes,step)) +distance = 1 +while True: + forward(distance) + right(step*node_angle) + if abs(pos()) < 1: + break + + step_color_two() + #step_color_rainbow() + #print(f"{r} {g} {b}") + pencolor((r,g,b)) + distance +=2 +done() \ No newline at end of file diff --git a/Python/ShapesStuff/nodal_pattern.py b/Python/ShapesStuff/nodal_pattern.py new file mode 100644 index 0000000..4380b23 --- /dev/null +++ b/Python/ShapesStuff/nodal_pattern.py @@ -0,0 +1,134 @@ +from turtle import * +r = 1 +g = 0 +b = 0 +tup = (r,g,b) +pencolor(tup) +change_amount = 0.1 +changing_color = "r+" + +#begin_fill() +pendown() + + + +def step_color_rainbow(): + + global changing_color + global change_amount + global r + global g + global b + if(changing_color == "r+"): + r += change_amount + if(r>1): + r = 1 + changing_color = "b-" + elif(changing_color == "g+"): + g += change_amount + if(g>1): + g = 1 + changing_color = "r-" + elif(changing_color == "b+"): + b += change_amount + if(b>1): + b = 1 + changing_color = "g-" + if(changing_color == "r-"): + r -= change_amount + if(r<0): + r = 0 + changing_color = "b+" + elif(changing_color == "g-"): + g -= change_amount + if(g<0): + g = 0 + changing_color = "r+" + elif(changing_color == "b-"): + b -= change_amount + if(b<0): + b = 0 + changing_color = "g+" + + + + + + + + +def step_color_two(): + global r + global g + global b + global changing_color + + r1 = 0.07 + g1 = 0.02 + b1 = 0.35 + + r2 = 1 + g2 = 0.07 + b2 = 0.31 + + + c_amount = 100 + + rdiff = r2-r1 + gdiff = g2 - g1 + bdiff = b2 - b1 + + rchange = rdiff/c_amount + gchange = gdiff/c_amount + bchange = bdiff/c_amount + #print(f"{rchange} {gchange} {bchange}") + #print(f" {r} {g} {b}") + if(changing_color == "r+"): + r += rchange + g += gchange + b += bchange + else: + r -= rchange + g -= gchange + b -= bchange + + if(r >= r2): + r = r2 + g = g2 + b = b2 + changing_color = "r-" + elif(r <= r1): + r = r1 + g = g1 + b = b1 + changing_color = "r+" + +nodes = 999 +step = 330 +node_angle = 360/nodes +speed(0) +bgcolor("black") +def iterations(n,s): + i = 1 + while True: + x = s*i + if(x % n== 0) and (x>= n): + return i + else: + i += 1 + +#print(iterations(nodes,step)) +distance = 1 +speed = 0 +while True: + forward(distance) + right(step*node_angle) + if abs(pos()) < 1: + break + + step_color_two() + #step_color_rainbow() + #print(f"{r} {g} {b}") + pencolor((r,g,b)) + distance +=1 +done() \ No newline at end of file diff --git a/animate 0.1 (deconstructing)/animation.html b/animate 0.1 (deconstructing)/animation.html index 7291ef2..a528c6a 100644 --- a/animate 0.1 (deconstructing)/animation.html +++ b/animate 0.1 (deconstructing)/animation.html @@ -28,23 +28,6 @@ return newColor; } - function draw_shape(sides, radius, rotation, x, y, colour) { - var rot = Math.round((sides - 2) * 180 / sides * 2) - var piv = 360 / sides; - var stt = 0.5 * Math.PI - rad(rot) + rad(rotation); - var end = 0; - - for (let i = 1; i < sides + 1; i++) { - end = stt + rad(rot); - ctx.beginPath(); - ctx.arc(x + Math.cos(rad(90 + piv * i + rotation)) * radius, y + Math.sin(rad(90 + piv * i + rotation)) * radius, radius, stt, end, 0); - ctx.strokeStyle = colour; - ctx.stroke(); - - stt = end + -(rad(rot - piv)) //+rad(30); - - } - } function draw_shape_sub(sides, radius, rotation, x, y, colour) { var denominator = sides - 2 @@ -97,85 +80,7 @@ } } - function Draw_Shape_accident(sides, radius, rotation, x, y, colour) { - var rot = Math.round((sides - 2) * 180 / sides * 2) - var piv = 360 / sides; - var stt = 0.5 * Math.PI - rad(rot) //+ rad(rotation); - var end = 0; - var n = radius / ((radius / 10) * (radius / 10)) //pixel correction for mid leaf - - for (let i = 1; i < sides + 1; i++) { - end = stt + rad(rot); - - ctx.beginPath(); - ctx.arc(x + Math.cos(rad(90 + piv * i + rotation)) * radius, y + Math.sin(rad(90 + piv * i + rotation)) * radius, radius, stt - (stt - end + rad(rotation)) / 2, end + rad(n), 0); - ctx.strokeStyle = colour; - ctx.stroke(); - - - ctx.beginPath(); - ctx.arc(x + Math.cos(rad(90 + piv * i - rotation)) * radius, y + Math.sin(rad(90 + piv * i - rotation)) * radius, radius, stt, end - (end - stt - rad(rotation)) / 2 + rad(n), 0); - ctx.strokeStyle = colour; - ctx.stroke(); - - - stt = end + -(rad(rot - piv)) //+rad(30); - } - - } - - function Draw_Spiral_Pattern(sides, radius, rotation, x, y, colour) { - var rot = Math.round((sides - 2) * 180 / sides * 2) - var piv = 360 / sides; - var stt = 0.5 * Math.PI - rad(rot) //+ rad(rotation); - var end = 0; - var n = radius / ((radius / 10) * (radius / 10)) //pixel correction for mid leaf - - for (let i = 1; i < sides + 1; i++) { - end = stt + rad(rot); - - ctx.beginPath(); - ctx.arc(x + Math.cos(rad(90 + piv * i + rotation)) * radius, y + Math.sin(rad(90 + piv * i + rotation)) * radius, radius, stt + rad(rotation) - (stt - end) / 2, end + rad(rotation) + rad(n), 0); - ctx.strokeStyle = colour; - ctx.stroke(); - - - ctx.beginPath(); - ctx.arc(x + Math.cos(rad(90 + piv * i - rotation)) * radius, y + Math.sin(rad(90 + piv * i - rotation)) * radius, radius, stt - rad(rotation), end - (end - stt) / 2 + rad(n) - rad(rotation), 0); - ctx.strokeStyle = colour; - ctx.stroke(); - - - stt = end + -(rad(rot - piv)) //+rad(30); - } - - } - - function Draw_Spiral(sides, radius, rotation, x, y, colour) { - var rot = Math.round((sides - 2) * 180 / sides * 2) - var piv = 360 / sides; - var stt = 0.5 * Math.PI - rad(rot) + rad(rotation); - var end = 0; - var n = radius / ((radius / 10) * (radius / 10)) //pixel correction for mid leaf - - for (let i = 1; i < sides + 1; i++) { - end = stt + rad(rot); - ctx.beginPath(); - ctx.arc(x + Math.cos(rad(90 + piv * i + rotation)) * radius, y + Math.sin(rad(90 + piv * i + rotation)) * radius, radius, stt - (stt - end) / 2, end + rad(n), 0); - ctx.strokeStyle = colour; - ctx.stroke(); - - /* - ctx.beginPath(); - ctx.arc(x + Math.cos(rad(90 + piv * i + rotation)) * radius, y + Math.sin(rad(90 + piv * i + rotation)) * radius, radius, stt, end - (end - stt) / 2 + rad(n), 0); - ctx.fillStyle = colour; - ctx.fill(); - */ - - stt = end + -(rad(rot - piv)) //+rad(30); - } - - } + function render_clear() { ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); @@ -186,10 +91,10 @@ function draw_triangle(ang, radius) { ctx.beginPath(); - ctx.moveTo(startx + Math.cos(rad(90 + 120 * 1 + ang)) * radius, starty + Math.sin(rad(90 + 120 * 1 + ang)) * radius); - ctx.lineTo(startx + Math.cos(rad(90 + 120 * 2 + ang)) * radius, starty + Math.sin(rad(90 + 120 * 2 + ang)) * radius); - ctx.lineTo(startx + Math.cos(rad(90 + 120 * 3 + ang)) * radius, starty + Math.sin(rad(90 + 120 * 3 + ang)) * radius); - ctx.lineTo(startx + Math.cos(rad(90 + 120 * 1 + ang)) * radius, starty + Math.sin(rad(90 + 120 * 1 + ang)) * radius); + ctx.moveTo(centerX + Math.cos(rad(90 + 120 * 1 + ang)) * radius, centerY + Math.sin(rad(90 + 120 * 1 + ang)) * radius); + ctx.lineTo(centerX + Math.cos(rad(90 + 120 * 2 + ang)) * radius, centerY + Math.sin(rad(90 + 120 * 2 + ang)) * radius); + ctx.lineTo(centerX + Math.cos(rad(90 + 120 * 3 + ang)) * radius, centerY + Math.sin(rad(90 + 120 * 3 + ang)) * radius); + ctx.lineTo(centerX + Math.cos(rad(90 + 120 * 1 + ang)) * radius, centerY + Math.sin(rad(90 + 120 * 1 + ang)) * radius); ctx.strokeStyle = "red"; ctx.stroke(); } @@ -208,8 +113,8 @@ var piv = 360 / sides_org; var angle = 0; - startx = 1920 / 2//1875/2; - starty = 1080 / 2//950/2;//-(Math.tan(30*Math.PI/180)*width/2); + centerX = 1920 / 2//1875/2; + centerY = 1080 / 2//950/2;//-(Math.tan(30*Math.PI/180)*width/2); j = 0; i = 0; @@ -322,35 +227,35 @@ //draw_triangle(180+ (theFinalAngle*180/Math.PI) ,L) //draw_triangle((angle-180)/2.8,tmpA*400) - //draw_shape(7,300,0,startx,starty,"red"); - //draw_shape_sub(7,300,0,startx,starty,"blue"); - //draw_shape_fill(5,300,angle,startx,starty,"purple"); + //draw_shape(7,300,0,centerX,centerY,"red"); + //draw_shape_sub(7,300,0,centerX,centerY,"blue"); + //draw_shape_fill(5,300,angle,centerX,centerY,"purple"); /* - draw_shape_fill(5,300,angle,startx,starty,"purple"); - draw_shape_fill(5,115,-(angle+108),startx,starty,"red"); - draw_shape_fill(5,44,angle+108,startx,starty,"yellow"); + draw_shape_fill(5,300,angle,centerX,centerY,"purple"); + draw_shape_fill(5,115,-(angle+108),centerX,centerY,"red"); + draw_shape_fill(5,44,angle+108,centerX,centerY,"yellow"); - draw_shape(5,300,angle,startx,starty,"red"); - draw_shape(5,115,-(angle+108),startx,starty,"yellow"); - draw_shape(5,44,angle+108,startx,starty,"purple"); + draw_shape(5,300,angle,centerX,centerY,"red"); + draw_shape(5,115,-(angle+108),centerX,centerY,"yellow"); + draw_shape(5,44,angle+108,centerX,centerY,"purple"); */ - //Draw_Spiral(4,400,0,startx,starty,'red'); - //Draw_Spiral_Pattern(50, 250, angle, startx, starty, 'red') - //Draw_Shape_accident(4,300,angle,startx,starty,'red') - //Draw_Spiral(10,400,-angle,startx,starty,'red'); + //Draw_Spiral(4,400,0,centerX,centerY,'red'); + //Draw_Spiral_Pattern(50, 250, angle, centerX, centerY, 'red') + //Draw_Shape_accident(4,300,angle,centerX,centerY,'red') + //Draw_Spiral(10,400,-angle,centerX,centerY,'red'); - //draw_shape(99,300,angle,startx,starty,"red"); + //draw_shape(99,300,angle,centerX,centerY,"red"); //draw_triangle(0); //draw_tri(angle); //draw_test_fill(angle); - //draw_shape(5,300,angle,startx,starty); - //draw_shape(3,300,-angle,startx,starty) + //draw_shape(5,300,angle,centerX,centerY); + //draw_shape(3,300,-angle,centerX,centerY) - //draw_shape(7,400,angle,startx,starty) - //draw_shape(6,r,-angle,startx,starty) + //draw_shape(7,400,angle,centerX,centerY) + //draw_shape(6,r,-angle,centerX,centerY) /* @@ -364,17 +269,11 @@ //Draw_nodal_expanding(2.5,100000,angle*2+33000,angle*0, colour1,colour2,0.5, 5) //Draw_nodal_expanding(2.5,10000,angle,angle*0, colour1,colour2,0.5, 1) //console.log(angle*2) - //draw_shape(55,300,angle,startx,starty,"pink") + //draw_shape(55,300,angle,centerX,centerY,"pink") //Draw_Phyllotaxis(angle/5000+1); - //draw_shape_fill(4,400,angle,startx,starty,colourToText(ncolour)); + //draw_shape_fill(4,400,angle,centerX,centerY,colourToText(ncolour)); - //Draw_rectangle_pattern1(angle, 180, "purple"); - /* - for (let z = 0; z < 360; z+=360/45) { - Draw_rectangle_pattern1(z+angle,200,"blue"); - - } - */ + @@ -394,76 +293,23 @@ render() //render_clear() //Draw_nodal(500, 100,33) - //draw_shape_fill(5,300,angle,startx,starty,"purple"); - //draw_shape_fill(5,115,angle+108,startx,starty,"red"); - //draw_shape(5,300,angle,startx,starty); + //draw_shape_fill(5,300,angle,centerX,centerY,"purple"); + //draw_shape_fill(5,115,angle+108,centerX,centerY,"red"); + //draw_shape(5,300,angle,centerX,centerY); //Draw_center(); - function Draw_Phyllotaxis(angle) { - colour1 = [255, 170, 0]; - colour2 = [255, 0, 221]; - - var c = 32; - - for (let n = 50; n < 300; n += 1) { - ncolour = LerpRGB(colour1, colour2, Math.cos(rad(n / 2))); - var a = n * (angle)//137.5; - var r = c * Math.sqrt(n); - var x = r * Math.cos(a) + startx; - var y = r * Math.sin(a) + starty; - - ctx.beginPath(); - ctx.arc(x, y, 4, 0, 2 * Math.PI); - ctx.fillStyle = colourToText(ncolour); - ctx.fill(); - - } + - } - function draw_test_fill(angle) { - - ctx.beginPath(); - ctx.arc(1000, 500, 300, 0, rad(angle)); - ctx.fillStyle = "purple"; - ctx.fill(); - - } - - function Draw_nodal_expanding(expand, points, step, rotate, colour1, colour2, colour_change, line_width) { - var angle = 360 / points * step - - var start_angle = angle; - var done = false; - var total_moves = 1; - var length = expand; - - - for (let z = 1; z <= 2500; z++) { - ctx.beginPath(); - //ctx.moveTo(startx, starty); - ncolour = LerpRGB(colour1, colour2, Math.cos(rad(z * colour_change))); - - ctx.moveTo(startx + (Math.cos(rad(angle * (z - 1) + rotate)) * (length - expand)), starty + (Math.sin(rad(angle * (z - 1) + rotate)) * (length - expand))); - ctx.lineTo(startx + (Math.cos(rad(angle * z + rotate)) * length), starty + (Math.sin(rad(angle * z + rotate)) * length)); - length += expand; - ctx.lineWidth = line_width;//try 1 - ctx.strokeStyle = colourToText(ncolour); - ctx.stroke(); - } - - - } - - function Draw_nodal(radius, points, step, rotate, colour) { + function Draw_nodal(radius, points, step, rotate, colour) { //catalogued var angle = 360 / points * step ctx.beginPath(); var start_angle = angle; var done = false; var total_moves = 1; - ctx.moveTo(startx + (Math.cos(rad(angle + rotate)) * radius), starty + (Math.sin(rad(angle + rotate)) * radius)); + ctx.moveTo(centerX + (Math.cos(rad(angle + rotate)) * radius), centerY + (Math.sin(rad(angle + rotate)) * radius)); while (done != true) { if ((total_moves * step) % points != 0) { @@ -475,16 +321,16 @@ } } for (let z = 1; z <= total_moves; z++) { - ctx.lineTo(startx + (Math.cos(rad(angle * z + rotate)) * radius), starty + (Math.sin(rad(angle * z + rotate)) * radius)); + ctx.lineTo(centerX + (Math.cos(rad(angle * z + rotate)) * radius), centerY + (Math.sin(rad(angle * z + rotate)) * radius)); } ctx.strokeStyle = colour; ctx.stroke(); } - function Draw_rectangle_pattern1(angle, size, colour) { + function Draw_rectangle_pattern1(angle, size, colour) { //catalogued ctx.save(); - ctx.translate(startx, starty)//-(Math.sin(rad(angle)) *startx)); + ctx.translate(centerX, centerY)//-(Math.sin(rad(angle)) *centerX)); ctx.rotate(rad(angle + 180)); ctx.beginPath(); ctx.strokeStyle = colour; @@ -494,19 +340,13 @@ } - function draw_tri(angle) { - draw_shape(3, 520, angle, startx + 260, starty - 150); - draw_shape(3, 520, angle + 60, startx - 260, starty - 150); - draw_shape(3, 520, angle + 120, startx, starty + 300); - - } function Draw_center() { ctx.beginPath(); - ctx.moveTo(startx - 100, starty); - ctx.lineTo(startx + 100, starty); - ctx.moveTo(startx, starty - 100); - ctx.lineTo(startx, starty + 100); + ctx.moveTo(centerX - 100, centerY); + ctx.lineTo(centerX + 100, centerY); + ctx.moveTo(centerX, centerY - 100); + ctx.lineTo(centerX, centerY + 100); ctx.strokeStyle = "red"; ctx.stroke();