Esempio n. 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)
def draw_fg():
    pts = [(0, 0), (0, 0)]
    for i in range(num + 1):
        pts.append((i * gapH, 150 - 5 * abs(math.sin(i / 5))))
    pts.append((w, 0))
    pts.append((w, 0))
    sg.set_pen_color(0, 0, 0)
    sg.set_brush_style('SolidPattern')
    sg.set_brush_color(0, 0, 0)
    sg.draw_closed_path(pts)
Esempio n. 3
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)
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)
Esempio n. 5
0
def circle_stack(x, y, max_radius, num_of_circles, right_center):
    sg.set_brush_color(random.randrange(100, 255), 200, 200)
    sg.set_pen_color(0, 0, 0)
    pen_width = 2
    sg.set_pen_width(pen_width)
    #draw the bg circle
    if right_center:
        sg.draw_circle(x - max_radius - pen_width, y, max_radius)
    else:
        sg.draw_circle(x + max_radius + pen_width, y, max_radius)

    # draw all the on-top circles with no filling color
    sg.set_brush_color(0, 0, 0, 0)
    for i in range(num_of_circles):
        radius = max_radius * random.uniform(0, 1)
        if right_center:
            sg.draw_circle(x - radius - pen_width, y, radius)
        else:
            sg.draw_circle(x + radius + pen_width, y, radius)
Esempio n. 6
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)
Esempio n. 7
0
                                       g1=58,
                                       b1=255,
                                       r2=28,
                                       g2=5,
                                       b2=121)
    sg.set_brush_gradient_color_at(0.4, 255, 73, 167)


sg.create_canvas(w, h)

# fill the background with gradent color
set_gradient()
sg.draw_rect(w / 2, h / 2, w, h)

# bg layer 2
sg.set_pen_color(255, 255, 255, 50)
layer_lines()
random_circles()

# draw the squares
sg.translate_origin(w / 2, h / 2)
set_gradient_for_squares()
sg.set_pen_width(0)
sg.rotate_origin(45)

for m in range(-20, 21):
    for n in range(-20, 21):
        x = m * box_dist
        y = n * box_dist
        d = distance(x, y, 0, 0)
        nsize = fit_range(d, 0, 500, 50, 0)
    "Product B": 0.28,
    "Product C": 0.23,
    "Product D": 0.05
}

sg.create_canvas(600, 1000)
sg.fill_canvas_hsv(160, 100, 240)

dis_centre = 10

sg.set_font("Arial", 20)
sg.draw_text(300, 100, 600, 100, "2019 Desktop Product Share")
sg.set_font("Arial", 10)
sg.draw_text(300, 150, 600, 100, "- A Professional Survey")

current_angle = 0
for key, value in data.items():
    sg.set_pen_width(1)
    sg.set_pen_color(0, 0, 0)
    middle_angle = (current_angle + current_angle + 360 * value) / 2.0
    sg.set_brush_color(random.randrange(100, 255), 180,
                       random.randrange(100, 255))
    sg.draw_pie(300 + dis_centre * math.cos(math.radians(middle_angle)),
                500 + dis_centre * math.sin(math.radians(middle_angle)), 200,
                current_angle, 360 * value)
    sg.draw_text(300 + 100 * math.cos(math.radians(middle_angle)),
                 500 + 100 * math.sin(math.radians(middle_angle)), 200, 50,
                 key + " " + format(value * 100, '.0f') + "%")
    current_angle = current_angle + 360 * value

sg.show_canvas()
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()
Esempio n. 10
0
def draw_panda(x, y):
    # ears
    sg.set_pen_color(0, 0, 0)
    sg.set_pen_width(50)
    sg.draw_point(x - 50, y + 75)
    sg.draw_point(x + 50, y + 75)
    # face
    sg.set_pen_color(255, 255, 255)
    sg.set_pen_width(150)
    sg.draw_point(x, y)
    # eyes
    sg.set_pen_color(0, 0, 0, 0)
    sg.set_brush_color(0, 0, 0)
    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_pen_color(255, 255, 255)
    sg.set_pen_width(10)
    sg.draw_point(x - 25, y - 5)
    sg.draw_point(x + 25, y - 5)

    # nose
    sg.set_pen_color(0, 0, 0, 0)
    sg.set_brush_color(0, 0, 0)
    sg.draw_ellipse(x, y - 15, 20, 15)

    # mouth
    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)