pasen.py

Created by numworks-nl

Created on April 07, 2023

2.02 KB

Kleur een paar eitjes samen met je NumWorks grafische rekenmachine ter gelegenheid van Pasen!


from math import *
from turtle import *
from kandinsky import *

rects = [
(0,0,340,340,(135,206,250))]
for r in rects:
  fill_rect(*r)

def fillEllipsis(centerI, centerJ, a, b, theta, R, color):
  a2 = a*a
  b2 = b*b
  for i in range(centerI-5*R,centerI+5*R):
    for j in range(centerJ-5*R,centerJ+5*R):
      deltaI = i-centerI
      deltaJ = j-centerJ
      x = cos(theta)*deltaI + sin(theta)*deltaJ
      y = sin(theta)*deltaI - cos(theta)*deltaJ
      if (x*x/a2+y*y/b2 <= R):
        set_pixel(i, j, color)

fillEllipsis(200,120,12,8,8,7,(138,43,228))
fillEllipsis(120,120,7,9,9,10,(138,43,228))
fillEllipsis(160,120,12,9,11,7,(229,0,0))
fillEllipsis(160,120,2,2,2,2,(255,229,229))
fillEllipsis(150,110,2,2,2,2,(255,229,229))
fillEllipsis(170,110,2,2,2,2,(255,229,229))
fillEllipsis(160,100,2,2,2,2,(255,229,229))
fillEllipsis(145,125,2,2,2,2,(255,229,229))
fillEllipsis(175,125,2,2,2,2,(255,229,229))
def petal():
    circle(10, 90)
    left(90)
    circle(10, 90)
    left(18)
    
def flower():
    petal()
    petal()
    petal()
    petal()
    petal()

hideturtle()
penup()
goto(40,-4)
pendown()
pencolor('pink')
flower()
penup()
goto(-40,-4)
pendown()
pencolor('pink')
flower()
penup()

rects = [
(0,180,340,60,(0,128,0))]
for r in rects:
  fill_rect(*r)

rects = [
(120,130,80,50,(227,203,163))]
for r in rects:
  fill_rect(*r)

rects = [
(100,130,80,20,(227,203,163))]
for r in rects:
  fill_rect(*r)

rects = [
(140,130,80,20,(227,203,163))]
for r in rects:
  fill_rect(*r)
  
rects = [
(110,150,80,20,(227,203,163))]
for r in rects:
  fill_rect(*r)
  
rects = [
(130,150,80,20,(227,203,163))]
for r in rects:
  fill_rect(*r)

fillEllipsis(270,45,8,8,8,8,(255,215,0))
pencolor('yellow')
width(2)
goto(111,40)
pendown()
goto(111,25)
penup()
goto(111,90)
pendown()
goto(111,105)
penup()
goto(135,67)
pendown()
goto(150,67)
penup()
goto(85,67)
pendown()
goto(70,67)
penup()
goto(128,47)
pendown()
goto(140,37)
penup()
goto(94,85)
pendown()
goto(82,95)
penup()
goto(94,47)
pendown()
goto(82,37)
penup()
goto(128,85)
pendown()
goto(140,95)

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>.