Пример #1
0
def design_02():
    # set pen 
    sg.set_pen_color(0,0,0)
    sg.set_pen_style('SolidLine')
    
    # set brush 
    sg.set_brush_style('SolidPattern')
    
    # define points
    away_dist = 350
    points = [(-114,0+away_dist),(-100,40+away_dist),(-20,60+away_dist),(0,100+away_dist),(0,100+away_dist),(20,60+away_dist),(100,40+away_dist),(114,0+away_dist)]
    inner_away_dist = 330
    inner_points = [(-114,10+inner_away_dist),(-100,40+inner_away_dist),(-20,60+inner_away_dist),(0,90+inner_away_dist),(0,90+inner_away_dist),(20,60+inner_away_dist),(100,40+inner_away_dist),(114,10+inner_away_dist)]
    
    # run loop to draw
    num = 10
    for i in range(num):
        # most outer path
        sg.rotate_origin(360/num)
        sg.set_pen_width(4)
        sg.draw_path(points)
        # another path
        sg.set_pen_width(2)
        sg.draw_path(inner_points)
        # dot
        sg.set_pen_width(30)
        sg.draw_point(0,370)
        
    # fill the center with white color
    sg.set_pen_style("NoPen")
    sg.draw_circle(0,0,368)
Пример #2
0
def design_06():
    sg.set_pen_style('NoPen')
    sg.set_brush_style('SolidPattern')
    sg.set_brush_color(0,0,0)
    num = 8
    for i in range(num):
        # draw the 3 leaf grass
        sg.save_stat()
        sg.translate_origin(0,120)
        sg.draw_ellipse(0,25,10,50)
        sg.rotate_origin(-20)
        sg.draw_ellipse(0,25,10,50)
        sg.rotate_origin(40)
        sg.draw_ellipse(0,25,10,50)
        sg.restore_stat()
        # rotate
        sg.rotate_origin(360/num)
    sg.set_brush_style('NoBrush')
    sg.set_pen_style('SolidLine')
    sg.set_pen_width(2)
    sg.rotate_origin(360/num/2)
    for i in range(num):
        sg.draw_rect_with_rot(0,110,65,65,45)
        sg.draw_rect_with_rot(0,100,65,65,45)
        sg.rotate_origin(360/num)
Пример #3
0
def design_03():
    sg.set_pen_style('SolidLine')
    sg.set_pen_width(5)
    sg.draw_circle(0,0,368)
    sg.set_pen_width(1)
    num = 200
    for i in range(num):
        sg.rotate_origin(360/num)
        sg.draw_line(0,0,368,0)
    sg.set_pen_width(3)
    sg.draw_circle(0,0,340)
Пример #4
0
def draw_many_circles(num):
    sg.set_pen_style('NoPen')
    for i in range(num):
        width = random.randint(0, 200)
        x = random.randint(0, w)
        y = random.randint(0, h)
        sg.set_brush_style_linear_gradient(x - width / 2, y, x + width / 2, y,
                                           255, (num - i) / num * 200,
                                           (num - i) / num * 200, 255, 255,
                                           255)
        sg.draw_circle(x, y, width / 2)
Пример #5
0
def design_05():
    sg.set_pen_width(2)
    sg.set_pen_style('SolidLine')
    sg.set_pen_color(0,0,0)
    sg.draw_circle(0,0,240)
    sg.draw_circle(0,0,235)
    sg.draw_circle(0,0,215)
    sg.draw_circle(0,0,200)
    num = 200
    sg.set_pen_width(4)
    for i in range(num):
        sg.draw_point(0,207)
        sg.rotate_origin(360/num)
    sg.set_pen_width(5)
    sg.draw_circle(0,0,180)
Пример #6
0
def design_04():
    num = 20
    # most outer layer
    sg.set_pen_width(2)
    sg.set_brush_color(0,0,0)
    sg.set_brush_style('SolidPattern')
    for i in range(num):
        sg.rotate_origin(360/num)
        sg.draw_ellipse(260,0,150,15)
    sg.set_brush_style('NoBrush')
    sg.rotate_origin(360/num/2)
    
    for i in range(num):
        sg.set_pen_width(2)
        sg.rotate_origin(360/num)
        sg.draw_circle(0,280,40)
        sg.draw_circle(0,280,30)
        sg.set_pen_width(40)
        sg.draw_point(0,280)
        
    # middle layer
    sg.set_brush_style('SolidPattern')
    sg.set_brush_color(255,255,255)
    sg.rotate_origin(360/num/2)
    for i in range(num):
        sg.set_pen_width(2)
        sg.rotate_origin(360/num)
        sg.draw_circle(0,255,37)
        sg.draw_circle(0,255,27)
        sg.set_pen_width(30)
        sg.draw_point(0,255)
        
    # inner layer
    sg.set_brush_style('SolidPattern')
    sg.set_brush_color(255,255,255)
    sg.rotate_origin(360/num/2)
    for i in range(num):
        sg.set_pen_width(2)
        sg.rotate_origin(360/num)
        sg.draw_circle(0,230,37)
        sg.draw_circle(0,230,27)
        
    # cover center
    sg.set_pen_style('NoPen')
    sg.set_brush_color(255,255,255)
    sg.draw_circle(0,0,230)
Пример #7
0
def draw_wave(y, color, amp):
    # random offset is for shifting the waves horizontally so they don't look exactly same
    rand_offset = random.random() * 4
    # pts is the list of points. Adding two points makes sure sharp corner.
    pts = [(0, 0), (0, 0)]
    # adding points to the list based on Sine wave
    for i in range(num + 1):
        pts.append((i * gapH, y - amp * abs(math.sin(i / 5 - rand_offset))))
    # adding two points makes sure sharp corner.
    pts.append((w, 0))
    pts.append((w, 0))
    # no need pen
    sg.set_pen_style('NoPen')
    # set brush hsv color
    sg.set_brush_color_hsv(color[0], color[1], color[2])
    # draw the shape
    sg.draw_closed_path(pts)
Пример #8
0
def draw_human(x, y):
    sg.set_pen_color(10, 10, 10)
    sg.set_pen_style('SolidLine')
    sg.set_brush_style('SolidPattern')
    sg.set_brush_color(10, 10, 10)
    # head
    sg.draw_circle(x, y + 100, 10)
    # body
    pts = [(x, y + 95), (x - 30, y + 30), (x + 10, y + 30)]
    sg.draw_polygon(pts)
    # arms and legs
    sg.set_pen_width(5)
    sg.draw_line(x + 5, y + 30, x + 5, y)
    sg.draw_line(x - 5, y + 30, x - 8, y)
    sg.set_pen_width(4)
    linepts = [(x, y + 85), (x + 20, y + 90), (x + 30, y + 110)]
    sg.draw_polyline(linepts)
    sg.draw_line(x, y + 80, x + 40, y + 85)
Пример #9
0
def draw_panda_gradient(x, y):
    sg.set_pen_style('NoPen')
    # ears
    sg.set_brush_style_radial_gradient(x - 50, y + 95, 40, 120, 120, 120, 0, 0,
                                       0)
    sg.draw_circle(x - 50, y + 75, 25)
    sg.set_brush_style_radial_gradient(x + 50, y + 95, 40, 120, 120, 120, 0, 0,
                                       0)
    sg.draw_circle(x + 50, y + 75, 25)
    # face
    sg.set_brush_style_radial_gradient(x, y + 70, 180, 255, 255, 255, 150, 150,
                                       150)
    sg.draw_circle(x, y, 75)
    # eyes
    sg.set_brush_color(0, 0, 0)
    sg.set_brush_style('SolidPattern')
    sg.draw_ellipse_with_rot(x - 30, y - 10, 50, 30, -60)
    sg.draw_ellipse_with_rot(x + 30, y - 10, 50, 30, 60)
    sg.set_brush_color(255, 255, 255)
    sg.draw_circle(x - 25, y - 5, 5)
    sg.draw_circle(x + 25, y - 5, 5)
    sg.set_brush_style_radial_gradient(x - 27, y - 3, 3, 200, 200, 200, 0, 0,
                                       0)
    sg.draw_circle(x - 25, y - 5, 4)
    sg.set_brush_style_radial_gradient(x + 23, y - 3, 3, 200, 200, 200, 0, 0,
                                       0)
    sg.draw_circle(x + 25, y - 5, 4)
    # nose
    sg.set_brush_style_radial_gradient(x - 3, y - 12, 7, 200, 200, 200, 0, 0,
                                       0)
    sg.draw_ellipse(x, y - 15, 20, 15)
    # mouth
    sg.set_pen_style('SolidLine')
    sg.set_pen_color(0, 0, 0)
    sg.set_pen_width(2)
    sg.draw_line(x, y - 20, x, y - 40)
    sg.draw_elliptical_arc(x, y - 30, 20, 10, 180, 180)
import super_simple_graphics.canvas as sg

w = 1000
h = 600

sg.create_canvas(w, h)
sg.fill_canvas(200, 200, 200)

sg.set_pen_style('NoPen')

sg.set_brush_color(180, 180, 180)
sg.draw_rect(w / 2, h / 4 * 3, w, h / 2)
sg.set_brush_color(200, 200, 200)
sg.draw_rect(w / 2, h / 4, w, h / 2)

sg.set_brush_style_linear_gradient(w / 2 - 50, h / 2, w / 2 + 80, h / 2, 80,
                                   80, 80, 120, 120, 120)
sg.draw_ellipse(w / 2 + 50, h / 2 - 95, 260, 50)

sg.set_brush_style_radial_gradient(w / 2 - 50, h / 2 + 50, 120, 250, 250, 250,
                                   60, 60, 60)
sg.draw_circle(w / 2, h / 2, 100)

sg.show_canvas()
Пример #11
0
w = 1800
h = 600
sg.create_canvas(w, h)
sg.fill_canvas(164, 236, 255)


def draw_many_circles(num):
    sg.set_pen_style('NoPen')
    for i in range(num):
        width = random.randint(0, 200)
        x = random.randint(0, w)
        y = random.randint(0, h)
        sg.set_brush_style_linear_gradient(x - width / 2, y, x + width / 2, y,
                                           255, (num - i) / num * 200,
                                           (num - i) / num * 200, 255, 255,
                                           255)
        sg.draw_circle(x, y, width / 2)


draw_many_circles(200)

sg.set_brush_style('SolidPattern')
sg.set_brush_color(255, 0, 0, 120)
sg.draw_rect(w / 2, 197, w, 110)

sg.set_font('Kozuka Gothic Pr6N EL', 120)
sg.set_pen_style('SolidLine')
sg.set_pen_color(255, 255, 255)
sg.draw_static_text(100, 200, "BALLOONS")

sg.show_canvas()