cherryblossom.py

Created by andreanx

Created on March 16, 2021

2.99 KB

A quick adaptation of a turtle script released anonymously for the Casio fx-CG50 / Graph 90+E : https://tiplanet.org/forum/archives_voir.php?id=2711383


from random import *
from turtle import *
from kandinsky import *

casioplot_w, casioplot_h = 384, 182
kandinsky_w, kandinsky_h = 320, 222
screenold_w, screenold_h = casioplot_w, casioplot_h
screen_w, screen_h = kandinsky_w, kandinsky_h
coeff_x = screen_w / screenold_w
coeff_y = screen_h / screenold_h

def tx(x):
  return round(x * coeff_x)

def ty(y):
  return round(y * coeff_y)


def branche(longueur):
  pendown()
  a = longueur // 10
  xt,yt = pos()
  for b in range(a):
    forward(a*2)
    if b % 2 == 0:
      left(25)
    else:
      right(25)
    if (b+2)*10 < longueur:
      branche(longueur-(a-b-1)*5)
    if b % 2 == 0:
      right(25)
    else:
      left(25)
  fleur()
  forward(longueur-a*10)
  goto(xt,yt)
def fleur():
  pencolor("pink")
  pensize(5)
  for a in range(6):
    forward(5)
    backward(5)
    right(60)
  pencolor("red")
  pensize(1)
  for a in range(10):
    forward(2)
    backward(2)
    right(36)
  pensize(2)
  pencolor("brown")
def drawcircle(rayon, angle=None):
  penup()
  right(90)
  forward(rayon)
  left(90)
  pendown()
  circle(rayon,angle)
  penup()
  left(90)
  forward(rayon)
  right(90)
  right(angle)
  pendown()

def drawbranche(x1,y1,long=70,startsize=5):
  goto(x1,y1)
  pensize(startsize)
  pencolor("brown")
  pendown()
  backward(50)
  forward(50)
  branche(long)
  penup()
def petale(x1,y1,style):
  penup()
  goto(x1,y1)
  pencolor("pink")
  pendown()
  pensize(5)
  if style==1:
    forward(0)
    pensize(3)
    backward(3)
    pensize(1)
    backward(3)
  else:
    right(90)
    forward(1)
    penup()
    left(90)
    pensize(3)
    pendown()
    backward(4)
    penup()
    left(90)
    forward(1)
    right(90)
    pensize(2)
    right(22)
    pendown()
    backward(3)
    pensize(1)
    left(22)
    forward(1)
    right(45)
    backward(2)

speed(0)
penup()

goto(tx(-186),ty(-95))
pensize(5)
pendown()
left(90)
fill_rect(0,0,screen_w,screen_h,(60,146,255))
listcolor = [(63,149,253),(67,154,254),(71,156,253),(75,162,254),(78,163,254),(83,168,255),(86,171,254),(91,175,255),(94,178,254),(99,182,255),(102,185,255)]
for b in listcolor:
  pencolor(b)
  for a in range(4):
    drawcircle(250,66)
    right(90)
    penup()
    forward(4)
    left(90)
    pendown()
penup()


goto(tx(-191),ty(-60))
pencolor("brown")
pendown()
right(15)
drawbranche(tx(-191),ty(-60))
right(55)
drawbranche(tx(-90),ty(-95))
left(20)
drawbranche(tx(-171),ty(-95))
petale(tx(-180),ty(-45),1)
petale(tx(-158),ty(-33),2)
petale(tx(-100),ty(3),2)
petale(tx(-124),ty(78),1)
petale(tx(-73),ty(75),1)
petale(tx(-40),ty(20),2)
petale(tx(-30),ty(17),1)
petale(tx(-20),ty(50),2)
petale(tx(-22),ty(28),1)
petale(tx(-10),ty(5),1)
petale(tx(42),ty(20),1)
petale(tx(16),ty(23),2)
petale(tx(11),ty(37),1)
petale(tx(-83),ty(-80),2)
petale(tx(18),ty(50),1)
petale(tx(64),ty(57),1)
petale(tx(96),ty(18),1)
petale(tx(120),ty(26),2)
petale(tx(151),ty(18),1)
petale(tx(145),ty(36),2)
petale(tx(137),ty(-3),2)
petale(tx(82),ty(-44),2)
petale(tx(71),ty(-67),1)
petale(tx(96),ty(-26),1)
penup()
goto(tx(200),ty(200))

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.