Ejemplo n.º 1
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)
Ejemplo n.º 2
0
def random_circles():
    sg.set_brush_style("NoBrush")
    sg.set_pen_width(1)
    for i in range(20):
        x = random.uniform(0, w)
        y = random.uniform(0, h)
        sg.draw_circle(x, y, random.uniform(10, 500))
Ejemplo n.º 3
0
def layer_lines():
    sg.set_pen_width(1)
    for i in range(10):
        offset_x = random.uniform(-200, 200)
        offset_y = random.uniform(-200, 200)
        sg.draw_line((h - w) / 2 + w + offset_x, 0 + offset_x,
                     -(h - w) / 2 + offset_y, h + offset_y)
Ejemplo n.º 4
0
def design_01():
    num = 80
    sg.set_pen_width(2)
    sg.set_brush_style('NoBrush')
    for i in range(num):
        if i % 4 ==0:
            sg.draw_ellipse(400,0,200,50)
        else:
            sg.draw_ellipse(400,0,150,50)
        sg.rotate_origin(360/num)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)
Ejemplo n.º 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)
Ejemplo n.º 10
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)
Ejemplo n.º 11
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)
Ejemplo n.º 12
0
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)
        sg.set_brush_style_linear_gradient(x - 40, y - 40, x + 40, y + 40, 255,
                                           255, 255, 255, 0, 0)
        sg.draw_rounded_rect(x, y, nsize * 2, nsize * 2, 10, 10)
sg.reset_origin()

# bg layer 2
sg.set_pen_color(255, 255, 255, 100)
    "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()
Ejemplo n.º 14
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)
w = 600
h = 1000

circles = []

for i in range(20):
    circles.append((random.uniform(0,w),random.uniform(0,h),random.uniform(30,180)))

# create windows
sg.create_canvas(w,h)

# draw thicker black background circles
for item in circles:
    sg.set_brush_color(255,255,255,0)
    sg.set_pen_color(0,0,0)
    sg.set_pen_width(9*2)
    sg.draw_circle(item[0],item[1],item[2])


# draw thicker white background circles    
for item in circles:
    sg.set_pen_color(255,255,255)
    sg.set_pen_width(3*2)
    sg.draw_circle(item[0],item[1],item[2])
    
sg.set_pen_style('NoPen')
sg.set_brush_color(0,200,150,220)
sg.draw_rect_with_rot_bl(0,350,w,150,0)

sg.set_pen_color(255,255,255)
sg.set_pen_style('SolidLine')
Ejemplo n.º 16
0
"""

import math, random, sys
import super_simple_graphics.canvas as sg

w = 850
h = 480
number_of_text = 17
text_gap = 15
y_offset = -100

sg.create_canvas(w,h)
sg.fill_canvas_hsv(50,25,230)

    
sg.set_pen_width(2)
if sys.platform == "darwin":
    sg.set_font_n_style("Helvetica Neue",220,'Condensed Black')
elif sys.platform == "win32":
    sg.set_font_n_style("Arial Black",220,'Regular')

text = "TOKYO"
for i in range(0,number_of_text):
    sg.set_pen_color_hsv((i*(number_of_text-2)+180)%360,220,190)
    sg.draw_text(w/2,h-i*text_gap+y_offset,w,h,text)
  
sg.set_pen_color_hsv(0,0,0)
sg.draw_text(w/2,h-number_of_text*text_gap+y_offset,w,h,text)


sg.show_canvas()
Ejemplo n.º 17
0
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 11 21:44:27 2020

@author: Kevin Ma
"""

import super_simple_graphics.canvas as sg
import random

w = 600
h = 1000
gap = 6

# create canvas
sg.create_canvas(w, h)

# set the image to the buffer first
sg.set_buffer_image("../images/aphrodite.jpg")

# sample the buffer image at the points with distance of pixels specified by gap variable
for i in range(int(w / gap)):
    for j in range(int(h / gap)):
        color = sg.get_color_from_buffer_image(i * gap, j * gap)
        sg.set_pen_width((1 - color[0] / 255.0) * 8 * random.uniform(0.8, 1.2))
        #sg.set_pen_color(color[0],color[1],color[2])
        sg.draw_point(i * gap + random.uniform(-1, 1),
                      j * gap + random.uniform(-1, 1))

sg.show_canvas()