ellipse.py

Created by elodie-gamot

Created on October 21, 2021

325 Bytes

Avec Kandinsky. Colore le contenu d’une ellipse : u et v sont les coordonnées du centre, a demi-grand axe, b demi-petit axe et theta définit l’angle par rapport au repère.


from kandinsky import *
from math import *

meh=color(200,100,100)
  
def ellipse(u,v,a,b,theta):
  c=int(sqrt(a**2+b**2))
  for i in range(u-c,u+c):
    for j in range(v-c,v+c):
      if (((i-u)*cos(theta)+(j-v)*sin(theta))**2)/a**2+(((i-u)*sin(theta)-(j-v)*cos(theta))**2)/b**2<1:
        set_pixel(i,j,meh)

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