Code Sketch
Differentiable "Field Pattern & Polygon Turtle" (just playing around :-))
Category: Math
clear
invisible
zoom(0.2)
def circleface (t:Turtle,r:Int) = runInBackground {
repeat(100){
t.left(4)
t.forward(r)
}
t.left
t.forward(r)
repeat(12){
t.right(4)
t.forward(r/2)
}
t.penUp
// t.left(10)
t.forward(150)
t.penDown
repeat(90){
t.left(4)
t.forward(r/4)
}
}
def fieldpattern (t1:Turtle,t2:Turtle,t3:Turtle,tn:Int,tm:Int,x1:Int,x2:Int,x3:Int,y1:Int,y2:Int,y3:Int,l1:Int,l2:Int,l3:Int,speed:Int) = runInBackground{
var n=1
var m=1
t1.setPenColor(color(random(256),random(256),random(256)))
t2.setPenColor(color(random(256),random(256),random(256)))
t3.setPenColor(color(random(256),random(256),random(256)))
t1.setPenThickness(8)
t2.setPenThickness(8)
t3.setPenThickness(8)
t1.setAnimationDelay(speed)
t2.setAnimationDelay(speed)
t3.setAnimationDelay(speed)
repeat (tm) {
repeat (tn) {
t1.forward(l1)
t2.forward(l2)
t3.forward(l3)
t1.jumpTo(x1-m*200,y1-n*100)
t2.jumpTo(x2-m*200,y2-n*100)
t3.jumpTo(x3-m*200,y3-n*100)
m=m+1
}
t1.jumpTo(x1,y1)
t2.jumpTo(x2,y2)
t3.jumpTo(x3,y3)
n=n+1
m=1
}
m=1
n=1
repeat (tm) {
repeat (tn) {
t1.forward(l1)
t2.forward(l2)
t3.forward(l3)
t1.jumpTo(x1+m*200,y1+n*100)
t2.jumpTo(x2+m*200,y2+n*100)
t3.jumpTo(x3+m*200,y3+n*100)
m=m+1
}
t1.jumpTo(x1,y1)
t2.jumpTo(x2,y2)
t3.jumpTo(x3,y3)
n=n+1
m=1
}
m=1
n=1
repeat (tm) {
repeat (tn) {
t1.forward(l1)
t2.forward(l2)
t3.forward(l3)
t1.jumpTo(x1-m*200,y1+n*100)
t2.jumpTo(x2-m*200,y2+n*100)
t3.jumpTo(x3-m*200,y3+n*100)
m=m+1
}
t1.jumpTo(x1,y1)
t2.jumpTo(x2,y2)
t3.jumpTo(x3,y3)
n=n+1
m=1
}
m=1
n=1
repeat (tm) {
repeat (tn) {
t1.forward(l1)
t2.forward(l2)
t3.forward(l3)
t1.jumpTo(x1+m*200,y1-n*100)
t2.jumpTo(x2+m*200,y2-n*100)
t3.jumpTo(x3+m*200,y3-n*100)
m=m+1
}
t1.jumpTo(x1,y1)
t2.jumpTo(x2,y2)
t3.jumpTo(x3,y3)
n=n+1
m=1
}
t1.forward(90)
t2.forward(120)
t3.forward(120)
}
def polygonturtle (t:Turtle,mn:Int,fw:Int,ex:Int,rd:Int,speed:Int) = runInBackground {
var k=0
var l=2
t.setAnimationDelay(speed)
t.jumpTo(fw/2,fw/2)
repeat (mn) {
t.forward(fw+k)
t.left(360/mn)
t.forward(fw+k)
t.left(180)
t.forward(2*(fw+k))
t.left(180)
t.forward(fw+k)
t.left(360/mn)
k=k+ex
}
t.forward(fw/2)
t.right
t.forward(5*fw/mn)
t.right
//repeat (mn) {
circleface(t,l*rd)
// l=l+1
//}
}
def zooomin {
var r=0.5
repeat(90){
zoom(r-0.005)
}
}
def zooomout {
var r=0.05
repeat(90){
zoom(r+0.005)
}
}
val jumpy1 = newTurtle(0,-100)
val jumpy2 = newTurtle(-100,100)
val jumpy3 = newTurtle(100,100)
val jumpy4 = newTurtle(0,0)
jumpy1.left(35)
jumpy2.right(125)
jumpy3.left(145)
jumpy4.left()
jumpy4.setPenColor(color(random(256),random(256),random(256)))
jumpy4.setFillColor(color(random(256),random(256),random(256)))
jumpy4.setPenThickness(15)
fieldpattern(jumpy1,jumpy2,jumpy3,9,14,0,-100,100,-100,100,100,100,100,100,2)
polygonturtle(jumpy4,18,400,0,9,10)
//zooomout
//zooomin