Code
# from joy import *
import math
canvasWidth = 300
canvasHeight = 300
sqrt_2 = math.sqrt(2)
outerRadius = canvasWidth/2
bgColor = "yellow"
outerCircle = circle(r=outerRadius,fill=bgColor,stroke="black")
shapes = outerCircle
squareSide = 30
# Outer Most Layer
def squareLayer():
layerColor = color(r=239, g=101, b=101,a=0.55)
rotateAngle = math.degrees(math.atan(squareSide/(sqrt_2*outerRadius)))
repetitionCount = int(360/rotateAngle)
translatedSquare = rectangle(w=squareSide,h=squareSide,fill=layerColor,stroke="none") | rotate(45)| translate(x=outerRadius-squareSide/sqrt_2,y=0)
outerMostSquare = translatedSquare| repeat(repetitionCount,rotate(rotateAngle) )
plainLayer = circle(r=outerRadius-squareSide/sqrt_2,fill=bgColor,stroke="none")
return outerMostSquare + plainLayer
def kerala(top=70,left=-60,scale=0.8):
# Should input top left corner and scale
# starting from top going counterClockWise
# After every line, x2,y2 is the new x1,y1
x1,y1 = left, top
x2,y2 = int(left+scale*9) , int(top-scale*20)
lines = line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*14) , int(y1 - scale*14)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*4) , int(y1-scale*8)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*4) , int(y1-scale*4)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*6) , int(y1-scale*17)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*10) , int(y1-scale*15)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
# left side inset in map part
x1,y1 = x2, y2
x2,y2 = int(x1+scale*4) , int(y1-scale*1)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*4) , int(y1-scale*8)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*5) , int(y1-scale*3)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
# inset over
x1,y1 = x2, y2
x2,y2 = int(x1+scale*5) , int(y1-scale*20)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*8) , int(y1-scale*15)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*5) , int(y1-scale*15)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*10) , int(y1-scale*10)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*10) , int(y1-scale*20)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*5) , int(y1-scale*3)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*5) , int(y1-scale*8)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
# Reached Bottom most point, now moving right and up
x1,y1 = x2, y2
x2,y2 = int(x1+scale*5) , int(y1-scale*1)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*0) , int(y1+scale*2)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*1) , int(y1+scale*1)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*5) , int(y1+scale*5)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*3) , int(y1-scale*2)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*5) , int(y1+scale*5)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*0) , int(y1+scale*2)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*2) , int(y1+scale*4)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*1) , int(y1+scale*6)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*4) , int(y1+scale*3)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*4) , int(y1+scale*6)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
# Corner rounder
x1,y1 = x2, y2
x2,y2 = int(x1-scale*1) , int(y1+scale*1)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*5) , int(y1+scale*6)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
# Kollam-Pattanamthitta -> inner corner rounder
x1,y1 = x2, y2
x2,y2 = int(x1+scale*2) , int(y1+scale*2)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*6) , int(y1+scale*6)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
# pattanamthitta last stroke
x1,y1 = x2, y2
x2,y2 = int(x1+scale*3) , int(y1+scale*7)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
# Idukki first stroke
x1,y1 = x2, y2
x2,y2 = int(x1+scale*4) , int(y1+scale*4)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*3) , int(y1-scale*1)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*3) , int(y1+scale*3)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*4) , int(y1+scale*4)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*3) , int(y1-scale*2)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*6) , int(y1+scale*3)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
# Idukki inner curve
x1,y1 = x2, y2
x2,y2 = int(x1-scale*0) , int(y1+scale*3)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*2) , int(y1+scale*0)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*4) , int(y1+scale*5)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*3) , int(y1+scale*5)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*4) , int(y1+scale*5)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
# idukki Mushroom
x1,y1 = x2, y2
x2,y2 = int(x1-scale*4) , int(y1+scale*4)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*5) , int(y1-scale*4)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*4) , int(y1-scale*2)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*4) , int(y1-scale*1)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*2) , int(y1+scale*3)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*2) , int(y1+scale*2)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*2) , int(y1+scale*6)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*4) , int(y1+scale*3)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*2) , int(y1+scale*6)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*0) , int(y1+scale*6)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*1) , int(y1+scale*2)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*1) , int(y1+scale*2)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*8) , int(y1+scale*3)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
# inner curve
x1,y1 = x2, y2
x2,y2 = int(x1-scale*7) , int(y1+scale*2)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*0) , int(y1+scale*3)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*5) , int(y1+scale*6)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*5) , int(y1+scale*0)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*0) , int(y1+scale*3)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*5) , int(y1+scale*2)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*1) , int(y1+scale*6)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1+scale*2) , int(y1+scale*3)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*1) , int(y1-scale*1)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*3) , int(y1+scale*1)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*2) , int(y1-scale*4)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*7) , int(y1-scale*0)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*5) , int(y1+scale*1)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2,stroke="green")
x1,y1 = x2, y2
x2,y2 = int(x1-scale*5) , int(y1+scale*3)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*5) , int(y1+scale*3)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*7) , int(y1+scale*3)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*5) , int(y1+scale*2)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*1) , int(y1+scale*4)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*3) , int(y1-scale*0)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*4) , int(y1+scale*5)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*5) , int(y1+scale*5)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*5) , int(y1+scale*5)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*3) , int(y1+scale*5)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*7) , int(y1+scale*5)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
x1,y1 = x2, y2
x2,y2 = int(x1-scale*15) , int(y1+scale*7)
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
# reach start => end
x1,y1 = x2, y2
x2,y2 = left , top
lines += line(x1=x1,y1=y1,x2=x2,y2=y2)
# pointList = [
# point( x=left,y=top ),
# point
# ]
return lines
def semiCircles():
# take diameter = diag of square (global)
fillcolor = "red"
radius = squareSide / sqrt_2
print(radius)
oneCircle = circle(r=radius,fill=fillcolor,stroke="none") | translate(x= outerRadius-radius)
print(outerRadius)
rotateAngle = (2 * radius) / (outerRadius-radius)
print(rotateAngle)
rotateAngle = int(math.degrees(rotateAngle))
shape = oneCircle | repeat(int(360/rotateAngle), rotate(rotateAngle))
# clear outerPortion (ring portion)
rect = rectangle(w=radius,h=canvasHeight,fill=bgColor,stroke="none") | translate(outerRadius - radius/2)
rect = rect | repeat(100,rotate(10))
shape += rect
return shape
shapes += squareLayer()
# shapes += semiCircles()
rectangleColour = color(r=251,b=106,g=28,a=0.31)
shapes += rectangle(h=190,w=190,fill=rectangleColour,stroke="none") | repeat(20,rotate(10))
shapes += kerala()
# shapes += circle(r=canvasWidth/2,stroke="black",stroke_width="2")
show(shapes)