Exemplo n.º 1
0
def example_cuban_flag(axes=None):
  create_canvas_and_axes(canvas_width=30, canvas_height=20, axes=axes)
  draw_a_rectangle(left=0, centre_y=10, width=30, height=4, colour='blue')
  draw_a_rectangle(left=0, bottom=0, width=30, height=4, colour='blue')
  draw_a_rectangle(left=0, top=20, width=30, height=4, colour='blue')
  draw_a_triangle(tip_x=17, tip_y=10, width=20, height=17, colour='red', turn=9)
  draw_a_star(centre_x=6, centre_y=10, radius_1=3, radius_2=1, ends_qty=5, colour='white') 
  show_drawing_and_save_if_needed()
Exemplo n.º 2
0
def example_us_flag(axes=None):
  create_canvas_and_axes(canvas_width = 19*13*2, canvas_height = 10*13*2, axes=axes)

  for stripe_nb in range(7):
    draw_a_rectangle(centre_x=19*13, centre_y=10+2*20*stripe_nb, width=19*13*2, height=20, colour='red')
    
  draw_a_rectangle(centre_x=100, centre_y=190, width=200, height=140, colour='navy')   

  for row in range(9): # there are 9 rows of stars
    # let's define how many stars are in this row
    # and where is the centre_x of the first star    
    if row%2==0: # if row number is even
      stars_qty=6
      first_star_centre_x = 15 
    else:        # if row number is odd
      stars_qty=5
      first_star_centre_x = 33 
    # centre_y=260-(row+1)*14 because we are counting star rows from the top
    for column in range(stars_qty):
        draw_a_star(centre_x=first_star_centre_x+column*34, centre_y=260-(row+1)*14, radius_1=9, radius_2=3, ends_qty=5, colour='white') 

  show_drawing_and_save_if_needed()              
Exemplo n.º 3
0
def example_penguins(axes=None):
  
  def draw_half_circle(turn, **kwargs):
    draw_a_sector(angle_start=turn, angle_end=turn+6, **kwargs)
  #######################################################
  # Creating the canvas!                               ##  
  create_canvas_and_axes(canvas_width = 320,
                                canvas_height = 180,
                                title = "Penguin Conversation",
                                #tick_step = 10,
                                #model="https://i.pinimg.com/564x/fc/90/7d/fc907dc3638cfd64aa2c3ba56e216b92.jpg",
                                background_colour = 'lightskyblue',
                                axes=axes)

  #######################################################
  # Now let's draw the shapes!                         ##
  # snowflakes
  for s in range(150):
    draw_a_star(centre_x=random_number(max = get_width(axes)), 
                       centre_y=random_number(max = get_height(axes)), 
                       radius_1=1, radius_2=3, ends_qty=8, colour='aliceblue')

  # ice
  ice_colours = ['aliceblue', 'steelblue', 'skyblue']
  for s in range(1500):
    draw_a_triangle(tip_x=random_number(max = get_width(axes)), 
                    tip_y=0.2*random_number(max = get_height(axes)),
                    height=random_number(30), 
                    width=random_number(15), 
                    turn=random_element(range(2, 11)),
                    colour = random_element(ice_colours)) 

  # penguins!

  # the penguin on the left
  # body
  draw_a_circle(centre_x=60, centre_y=40, radius=20, colour='white')
  # feet
  draw_half_circle(centre_x=54, centre_y=16, radius=6, colour='orangered', turn=8.5)
  draw_half_circle(centre_x=66, centre_y=16, radius=6, colour='orangered', turn=9.5)
  # wings
  draw_half_circle(centre_x=31, centre_y=60, radius=30, colour='black', turn=2)
  draw_half_circle(centre_x=89, centre_y=60, radius=30, colour='black', turn=4)
  # head
  draw_a_circle(centre_x=60, centre_y=80, radius=15, colour='black')
  # eyes
  draw_a_circle(centre_x=55, centre_y=85, radius=3, colour=None, outline_colour='white', outline_linewidth=2)
  draw_a_circle(centre_x=65, centre_y=85, radius=3, colour=None, outline_colour='white', outline_linewidth=2)
  # beck
  draw_a_sector(centre_x=58, centre_y=76, angle_start=0, angle_end=3, radius=6, stretch_x=1.5, turn=0.5, colour='orangered')

  # the penguin on the right
  # first foot 
  draw_half_circle(centre_x=270, centre_y=16, radius=6, colour='orangered', turn=9)
  # body - white
  draw_half_circle(centre_x=280, centre_y=50, radius=30, colour='white', turn=5)
  # second foot 
  draw_half_circle(centre_x=280, centre_y=15, radius=6,  colour='orangered', turn=8)
  # body - black
  draw_half_circle(centre_x=290, centre_y=50, radius=30, colour='black', turn=5)
  # beck
  draw_half_circle(centre_x=255, centre_y=75, radius=6, colour='orangered', turn=8 + 1/2)
  # head
  draw_a_circle(centre_x=270, centre_y=80, radius=15, colour='black')
  # an eye
  draw_a_circle(centre_x=263, centre_y=85, radius=3, colour=None, outline_colour='white', outline_linewidth=2)

  show_drawing_and_save_if_needed()
Exemplo n.º 4
0
from zyxxy_canvas import create_canvas_and_axes, show_drawing_and_save_if_needed
from zyxxy_all_EXAMPLES import example_cuban_flag
from zyxxy_shape_functions import draw_a_triangle, draw_a_rectangle, draw_a_star

#######################################################
# Creating the canvas!                               ##
create_canvas_and_axes(  canvas_width = 30,
                              canvas_height = 20,
                              tick_step = 2,
                              title = "Flag Of Cuba",
                              model = example_cuban_flag,
                              outlines_colour = "cyan")

#######################################################
# Now let's draw the shapes!                         ##
draw_a_triangle(tip_x=5, tip_y=10, width=20, height=17, colour='red', turn=3)

draw_a_rectangle(centre_x=15, centre_y=12, width=30, height=4, colour='blue')

draw_a_star(centre_x=15, centre_y=8, radius_1=3, radius_2=1, ends_qty=8, colour='white')

show_drawing_and_save_if_needed()
Exemplo n.º 5
0
draw_a_crescent(ax=ax, width=6, depth_1=1, depth_2=3, centre_x=-4, centre_y=16, turn=9)
draw_a_crescent(ax=ax, width=6, depth_1=1, depth_2=3, centre_x=4, centre_y=16, turn=3)

new_layer()

# the stripes
for y in [10.5, 15]:  
  draw_a_rectangle(ax=ax, width=16, height=2, centre_x=0, centre_y=y, opacity=0.3, clip_outline=head, colour='orange', outline_linewidth=0)

# change outlines style
set_default_outline_style(linewidth=2)

# the eyes
eye_height = 15
for centre_x in [-2, 2]:
  draw_a_crescent(ax=ax, centre_x=centre_x, centre_y=eye_height, width=2, depth_1=-1, depth_2=1, colour='white')
  draw_an_ellipse(ax=ax, centre_x=centre_x, centre_y=eye_height, width=1, height=2, colour='red')
  draw_a_circle(ax=ax, centre_x=centre_x, centre_y=eye_height, radius=0.5, colour='black')

draw_a_triangle(ax=ax, width=2, height=1, tip_x=0, tip_y=eye_height-2.5, colour='black')
draw_a_segment(ax=ax, start_x= 2, start_y=eye_height-2, turn=3, length=3.5)
draw_a_segment(ax=ax, start_x= 2, start_y=eye_height-3, turn=4, length=3.5)
draw_a_segment(ax=ax, start_x=-2, start_y=eye_height-2, turn=9, length=3.5)
draw_a_segment(ax=ax, start_x=-2, start_y=eye_height-3, turn=8, length=3.5)

# the mouth
draw_a_crescent(ax=ax, width=2, depth_1=1, depth_2=1.5, centre_x=0, centre_y=12.5, colour='pink')

draw_a_star(ax=ax, centre_x=-8, centre_y=18, radius_1=3, radius_2=1, ends_qty=8, colour='red')

show_drawing_and_save_if_needed()
Exemplo n.º 6
0
#######################################################
# Now let's draw the shapes!                         ##
for stripe_nb in range(3):
    draw_a_rectangle(left=0,
                     centre_y=15 + 30 * stripe_nb,
                     width=19 * 13 * 2,
                     height=15,
                     colour='red')

draw_a_rectangle(left=0, centre_y=190, width=90, height=80, colour='navy')

for row in range(7):  # there are 9 rows of stars
    # let's define how many stars are in this row
    # and where is the centre_x of the first star
    if row % 2 == 0:  # if row number is even
        stars_qty = 9
        first_star_centre_x = 15
    else:  # if row number is odd
        stars_qty = 8
        first_star_centre_x = 33
    # centre_y=260-(row+1)*14 because we are counting star rows from the top
    for column in range(stars_qty):
        draw_a_star(centre_x=first_star_centre_x + column * 40,
                    centre_y=260 - (row + 1) * 20,
                    radius_1=18,
                    radius_2=6,
                    ends_qty=5,
                    colour='skyblue')

show_drawing_and_save_if_needed()