Beispiel #1
0
def paint_pictire(canvas_width, canvas_height):
    canvasSize(canvas_width, canvas_height)
    windowSize(canvas_width, canvas_height)
    paint_ground(canvas_width, canvas_height)
    paint_house(canvas_width, canvas_height)
    paint_window(320, 20, canvas_width / 3, canvas_height / 2 * 0.75,
                 (213, 255, 230), (135, 205, 222))
Beispiel #2
0
def main():
    xmax = 500
    ymax = 700
    graph.windowSize(xmax, ymax)
    graph.canvasSize(xmax, ymax)

    background(xmax, ymax, 300)

    x0 = 500
    y0 = 300
    window_width = 180
    window_indent = 20
    while x0 >= 0:
        window(x0, y0, window_width, window_indent, 5)
        x0 -= (window_width + window_indent)

    clew(200, 640, 50, 1)
    clew(400, 600, 30, -1)
    clew(300, 500, 30, -1)
    clew(150, 370, 15, 1)
    clew(70, 600, 15, 1)
    clew(425, 400, 15, -1)

    cat(350, 300, 80, 1, 'brown')
    cat(150, 450, 80, -1, 'grey')

    cat(100, 350, 30, -1, 'brown')
    cat(450, 500, 30, -1, 'brown')
    cat(100, 650, 30, -1, 'grey')
    cat(400, 650, 30, 1, 'grey')
    cat(350, 550, 30, 1, 'brown')

    graph.run()
Beispiel #3
0
def main():
    xmax = 500
    ymax = 700
    graph.windowSize(xmax, ymax)
    graph.canvasSize(xmax, ymax)

    background(xmax, ymax, 300)

    x0 = 500
    y0 = 300
    window_width = 180
    window_indent = 20
    while x0 >= 0:
        window(x0, y0, window_width, window_indent, 5)
        x0 -= (window_width + window_indent)

    my_pic = graph.canvas()
    graph.canvasSize(xmax, ymax)

    clew(200, 640, 50, 1)
    cat(350, 300, 80, 1, 'brown')

    my_pic.pack()

    graph.run()
Beispiel #4
0
def main():
    graph.windowSize(800, 600)
    beach(0, 450)
    sea(0, 330)
    sky(0, 0)
    cloud(100, 100, 20)
    sun(400, 100, 40)
    ship(250, 360, 150, 35)
Beispiel #5
0
def backgroung(length_sky):
    """
    Эта функция берёт длинну неба
    и заполняет остальное пространство кроме неба травой.
    Также она отвечает за ширину и высоту экрана
    """
    main_screen_width = 1600
    main_screen_height = 1000
    graph.windowSize(main_screen_width, main_screen_height)
    graph.penSize(0)
    graph.brushColor("skyblue")
    graph.rectangle(0, 0, main_screen_width, length_sky)
    graph.brushColor("limegreen")
    graph.rectangle(0, length_sky, main_screen_width, main_screen_height)
Beispiel #6
0
import graph
import MyLib
from math import *

graph.windowSize(1000, 1000)
graph.canvasSize(1000, 1000)

x0 = 600
y0 = 300
r = 200

graph.penColor(0, 0, 0)
graph.penSize(0.05)
graph.brushColor(155, 155, 155)

graph.circle(x0, y0, r)

indent = r / 10

MyLib.sector(x0 - r / 5, y0 + r / 5, r, (3 / 2) * pi, 2 * pi, 1, 0)
MyLib.sector(x0 - r / 5 - indent, y0 + r / 5 + indent, r, (3 / 2) * pi, 2 * pi,
             1, 0)
MyLib.sector(x0 - r / 5 - 2.5 * indent, y0 + r / 5 + 2.5 * indent, r,
             (3 / 2) * pi, 2 * pi, 1, 0)

MyLib.sector(x0 + r / 4, y0 + r / 2, r, pi, (3 / 2) * pi - pi / 6, 1, 0)
MyLib.sector(x0 + r / 4 + 2 * indent, y0 + r / 2 + 2 * indent, r, pi,
             (3 / 2) * pi - pi / 6, 1, 0)
MyLib.sector(x0 + r / 4 + 4 * indent, y0 + r / 2 + 4 * indent, r, pi + pi / 10,
             (3 / 2) * pi - pi / 6, 1, 0)
Beispiel #7
0
# Scale
k = 4

# Start points
p = -200
o = 0

lines = 0
rows = 0

# Background
brushColor(randColor())
rectangle(0 * k + p, 0 * k + o, 800 * k, 400 * k + o)

canvasSize(720 + 320 * n, 960)
windowSize(720 + 320 * n, 960)
penSize(2)


def draw_marlin():
    global marlin
    marlin = list()
    global lines, rows, p, o
    while lines <= 1:
        while rows <= n:

            # Face
            marlin.append(
                polygon([(115 * k + p, 89 * k + o), (108 * k + p, 77 * k + o),
                         (108 * k + p, 70 * k + o), (103 * k + p, 58 * k + o),
                         (104 * k + p, 25 * k + o), (149 * k + p, 20 * k + o),
Beispiel #8
0
from brusochek import Brusochek
from Controller import ControllerClass
import graph

center = 10  # половина центральной части платформы

width = 800  # Размер экрана
height = 600  # Размер экрана
radius = 10  # Радиус шарика
FrameSize = 6
graph.windowSize(width + 50, height + 50)  # размер окна
graph.canvasSize(width, height)  # размер холста
graph.canvasPos(0, 0)  # позиция холста

objects = ControllerClass('position.txt', width, height, FrameSize,
                          radius)  # объект контроллера

graph.penColor('black')  # цвет рамки
graph.penSize(FrameSize)  # ширина рамки
graph.line(5, 5, 5, height)  # левая сторона рамки
graph.line(5, 5, width, 5)  # верхняя сторона рамки
graph.line(width, 5, width, height)  # правая сторона рамки


def mov(event):
    objects.brusochek.mov(width, event.keycode)


def update():

    for dot in objects.dots:
Beispiel #9
0
    """
    randomly splits n stars across the rectangle with height and width
    """
    for i in range(n):
        star(randint(0, width), randint(0, height))


def fancy_cloud(x, y, size, n):
    """
    draws n clouds with decreasing size, creates gradient effect
    """
    for i in range(n):
        cloud(x, y, size - i // 2, i)


windowSize(600, 800)
canvasSize(500, 800)

brushColor(70, 50, 90)
rectangle(0, 0, 500, 400)

brushColor(59, 135, 59)
rectangle(0, 400, 500, 800)

brushColor(255, 244, 164)
circle(350, 120, 100)

starry_sky(200)

fancy_cloud(350, 180, 70, 100)
fancy_cloud(400, 40, 50, 100)
Beispiel #10
0
    obj2 = circle(200 * k - 85 * k, 52 * k, 2 * k)
    brushColor(252, 252, 12)
    polygon([(100 * k, 60 * k), (200 * k - 80 * k, 70 * k), (100 * k, 80 * k),
             (80 * k, 70 * k)])
    brushColor(252, 156, 12)
    polygon([(100 * k, 72 * k), (200 * k - 80 * k, 70 * k), (100 * k, 77 * k),
             (80 * k, 70 * k)])


# ##

# ## start main ###

# #init
print(123)
windowSize(200 * k, 300 * k)
canvasSize(200 * k, 300 * k)
print(321)
# print

gradient()
printTUX()
spyral()

# test code

obj = polygon([(50 * k, 50 * k), (150 * k, 50 * k), (150 * k, 150 * k),
               (50 * k, 150 * k)])

# changeCoord(obj,[(x,y),(x,y)])
# Animation
Beispiel #11
0
import graph as g
import math

window_width = 640
window_height = 442
g.windowSize(window_width, window_height)
g.canvasSize(window_width, window_height)

picture_width = 600
pen_width_0 = 0
pen_width_1 = 1

g.penSize(pen_width_0)

width_line_of_sky = 187
sky_upper_left_point_x = 20
sky_upper_left_point_y = 20
sky_bottom_right_point_x = sky_upper_left_point_x + picture_width
sky_bottom_right_point_y = sky_upper_left_point_y + width_line_of_sky
sky_color = '#94ffff'
g.brushColor(sky_color)
g.rectangle(sky_upper_left_point_x, sky_upper_left_point_y,
            sky_bottom_right_point_x, sky_bottom_right_point_y)

amplitude_sin_beach = 8
period_sin_beach = 88

width_line_of_sea = 101
sea_upper_left_point_x = sky_upper_left_point_x
sea_upper_left_point_y = sky_bottom_right_point_y
sea_bottom_right_point_x = sky_bottom_right_point_x
Beispiel #12
0
    by = int(50 * math.cos(alpha))
    penSize(10)
    penColor(53, 50, 51)
    line(x2 + bx, yy1 + by, x2 - bx, yy1 - by)
    for i in range(x2 - bx, x2 + bx, 7):
        penSize(3)
        y = yy1 + by + by * (i - x2 - bx) / bx
        penSize(5)
        penColor(53, 50, 51)
        line(i, y, i, y - 18)
        penSize(2)
        penColor(66, 63, 64)
        line(i - 2, y, i - 2, y - 17)


windowSize(500, 600)

R = 103
G = 113
B = 64
m = [[0] * 300 for i in range(250)]

for i in range(250):
    for j in range(300):
        if i == 0:
            if j == 0:
                m[i][j] = [R, G, B]
            else:
                R = m[i][j - 1][0]
                G = m[i][j - 1][1]
                B = m[i][j - 1][2]
Beispiel #13
0
from graph import windowSize, canvasSize, polygon, brushColor, rectangle, penColor, circle, line, run

windowSize(1000, 600)
canvasSize(1000, 600)


def ellipse(a, b, x0, y0):
    x = a
    y = 0
    s = [(x0 + a, y0)]
    for i in range(2 * a):
        x -= 1
        y = ((1 - x ** 2 / (a ** 2)) * b ** 2) ** 0.5
        s.append((x + x0, y + y0))
    for i in range(2 * a):
        x += 1
        y = -(((1 - x ** 2 / (a ** 2)) * b ** 2) ** 0.5)
        s.append((x + x0, y + y0))
    polygon(s)


def man(a, b):
    penColor(133, 133, 133)
    brushColor(133, 133, 133)
    ellipse(50, 95, a, b + 120)
    penColor(229, 194, 152)
    brushColor(229, 194, 152)
    circle(a, b, 45)
    penColor(0, 0, 0)
# отрисовывает руки : первая строка - правую, а вторая строка - левую;
    line(a + 40, b + 60, a + 80, b + 140)
    for i in range(31):
        points.append((i, 0.02 * i * (i - 30)))
    return points


def bird(scale: float = 1., angle: float = 0.):
    """Draw a scaled and turned instance of a bird"""
    pts = turn(scale_reflect(bird_pts(), scale, False), angle)
    lines = []
    for i in range(len(pts) - 1):
        lines.append(line(*pts[i], *pts[i + 1]))
        lines.append(point(*pts[1]))
    return lines


windowSize(600, 900)
canvasSize(600, 900)

# Background
color(20, 20, 180)
rectangle(0, 0, 600, 100)
color(100, 40, 210)
rectangle(0, 100, 600, 180)
color(140, 60, 200)
rectangle(0, 180, 600, 250)
color(170, 100, 170)
rectangle(0, 250, 600, 340)
color(230, 140, 170)
rectangle(0, 340, 600, 410)
color(250, 160, 50)
rectangle(0, 410, 600, 490)
Beispiel #15
0
import graph as g

g.windowSize(300, 400)
g.canvasSize(300, 400)

x0 = 20
y0 = 20
x1 = x0 + 256
y1 = y0 + 360
a = 0.26
x2 = x1
y2 = y0 + a * (y1 - y0)

b = 0.87
xc = x0 + b * (x1 - x0)
c = 0.1
yc = y0 + c * (y1 - y0)
d = 0.1
r = d * (x1 - x0)

g.penColor("#045FB4")
g.brushColor("#045FB4")
g.rectangle(x0, y0, x1, y1)

g.penColor("#81F7F3")
g.brushColor("#81F7F3")
g.rectangle(x0, y0, x2, y2)

g.penColor("yellow")
g.brushColor("yellow")
g.circle(xc, yc, r)
Beispiel #16
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import graph as g

import math

# z is size

z = 2
g.windowSize(1200 / z, 1000 / z)
g.canvasSize(1200 / z, 1000 / z)
g.brushColor('grey')

# background

g.rectangle(0, 0, 1200 / z, 1000 / z)


def bs(x, y):
    g.brushColor('black')
    g.rectangle(x, y, x + 10 / z, y + 10 / z)


x = 0
for i in range(120):
    y = 0
    if x % (4 / z) == 0:
        for j in range(50):
            bs(x, y)
            y += 20 / z
    else:
Beispiel #17
0
import graph
import MyLib
from math import *

graph.windowSize(500, 700)
graph.canvasSize(500, 700)

graph.brushColor(85, 70, 0)
graph.rectangle(0, 0, 500, 300)
graph.brushColor(125, 100, 0)
graph.rectangle(0, 300, 500, 700)

x0 = 500
y0 = 300
window_width = 180
window_indent = 20
while x0 >= 0:
    MyLib.window(x0, y0, window_width, window_indent, 5)
    x0 -= (window_width + window_indent)

MyLib.clew(200, 640, 50, 1)
MyLib.clew(400, 600, 30, - 1)
MyLib.clew(300, 500, 30, - 1)
MyLib.clew(150, 370, 15, 1)
MyLib.clew(70, 600, 15, 1)
MyLib.clew(425, 400, 15, - 1)

MyLib.cat(350, 300, 80, 1, 'brown')
MyLib.cat(150, 450, 80, -1, 'grey')

MyLib.cat(100, 350, 30, -1, 'brown')
from graph import windowSize, brushColor, penColor,\
    circle, run, penSize, line

windowSize(400, 400)

# big and round body
penSize(10)
penColor(47, 79, 79)
brushColor(47, 79, 79)

circle(200, 200, 120)

# dark circles for ears, circles under eyes and for the beauty
brushColor(40, 61, 61)

circle(125, 215, 40)
circle(275, 215, 35)
circle(210, 115, 15)
circle(270, 79, 34)
circle(130, 79, 34)
circle(260, 162, 30)

# eyes
brushColor('white')

circle(140, 165, 35)
circle(260, 165, 35)

# that thing inside eyes
brushColor(175, 133, 133)
Beispiel #19
0
from graph import windowSize, canvasSize, run
from graph import brushColor, penColor
from graph import polygon, circle, label
from math import sin, cos

windowSize(3000, 1000)
canvasSize(1760, 769)


def hair(color, x_coord):
    brushColor(color)
    default_hair = [[(293 - 463 + x_coord, 275), (336 - 463 + x_coord, 219),
                     (267 - 463 + x_coord, 205)],
                    [(316 - 463 + x_coord, 230), (378 - 463 + x_coord, 200),
                     (329 - 463 + x_coord, 166)],
                    [(362 - 463 + x_coord, 201), (431 - 463 + x_coord, 186),
                     (377 - 463 + x_coord, 149)],
                    [(417 - 463 + x_coord, 184), (476 - 463 + x_coord, 180),
                     (436 - 463 + x_coord, 144)],
                    [(457 - 463 + x_coord, 187), (509 - 463 + x_coord, 186),
                     (486 - 463 + x_coord, 143)],
                    [(498 - 463 + x_coord, 178), (543 - 463 + x_coord, 200),
                     (525 - 463 + x_coord, 151)],
                    [(532 - 463 + x_coord, 187), (586 - 463 + x_coord, 220),
                     (573 - 463 + x_coord, 152)],
                    [(576 - 463 + x_coord, 206), (621 - 463 + x_coord, 253),
                     (615 - 463 + x_coord, 182)],
                    [(608 - 463 + x_coord, 235), (644 - 463 + x_coord, 289),
                     (674 - 463 + x_coord, 218)]]
    for i in range(8):
        polygon(default_hair[i])
Beispiel #20
0
                       (x + 1.5 * r + h_m, y - 3 * r)]))
    a.append(
        graph.polygon([(x + 1.5 * r + h_m, y), (x + 2 * r + h_m, y - 1.5 * r),
                       (x + 3 * r + h_m, y - 1.5 * r),
                       (x + 1.5 * r + h_m, y)]))
    graph.brushColor('#000000')
    a.append(graph.circle(x + 13 / 3 * r, y + 1 / 3 * r, 1 / 4 * r))
    graph.brushColor('#ffffff')
    a.append(graph.circle(x + 13 / 3 * r, y + 1 / 3 * r, 1 / 5 * r))

    return a


d = 1000
h = 700
graph.windowSize(d, h)
graph.canvasSize(d, h)
background(h, d)
clouds(0.6 * d, (10 / 75) * h, 0.9)
clouds(0.38 * d, (7 / 75) * h, 0.7)
clouds(0.1 * d, (13 / 75) * h, 1.2)
Sun(d - 0.123 * d, 0.167 * d, 50)

obj1 = ship(3.8 / 5 * d, 8 / 15 * h, 1)
obj2 = ship(3.5 / 7 * d, 8.5 / 15 * h, 0.7)
umbrella(0.25 * d, 0.55 * h, 1)
umbrella(0.50 * d, 0.65 * h, 0.7)

graph.onKey(keyPressed)
graph.onTimer(update, 50)
graph.run()
Beispiel #21
0
import graph as gr
import sys
import json
import os
import tty
import termios
from time import sleep

width = 1190
height = 950

gr.windowSize(width, height)
gr.canvasSize(width, height)

gr.brushColor(90, 90, 90)
gr.penColor(90, 90, 90)
gr.rectangle(0, 0, width, height)

scene = []
with open('anim.scene', 'r') as file:
    scene = json.loads(file.read())

polygons_screen = []
polygons = []
polygonTypeV = 'full'


def updatePolygons():
    global polygons_screen, polygonTypeV, polygons
    for polygon in polygons_screen:
        gr.deleteObject(polygon)
Beispiel #22
0
    brushColor(255, 255, 255)
    rectangle(x1, y1, x2, y2)

    penColor(0, 231, 255)
    brushColor(141, 207, 255)
    rectangle(0.95 * x1 + 0.05 * x2, 0.95 * y1 + 0.05 * y2,
              0.55 * x1 + 0.45 * x2, 0.75 * y1 + 0.25 * y2)
    rectangle(0.45 * x1 + 0.55 * x2, 0.95 * y1 + 0.05 * y2,
              0.05 * x1 + 0.95 * x2, 0.75 * y1 + 0.25 * y2)
    rectangle(0.95 * x1 + 0.05 * x2, 0.67 * y1 + 0.33 * y2,
              0.55 * x1 + 0.45 * x2, 0.05 * y1 + 0.95 * y2)
    rectangle(0.45 * x1 + 0.55 * x2, 0.67 * y1 + 0.33 * y2,
              0.05 * x1 + 0.95 * x2, 0.05 * y1 + 0.95 * y2)


windowSize(500, 650)

penColor(85, 68, 0)
brushColor(85, 68, 0)
rectangle(0, 0, 500, 200)

penColor(128, 102, 0)
brushColor(128, 102, 0)
rectangle(0, 200, 500, 650)

window(250, 15, 450, 185)
cat(8, 216, 5, 5, 1)
ball(274, 467, 5, 5)

run()
Beispiel #23
0
    polygon([(1000, 500), (0, 500), (0, 240), (100, 265), (200, 365),
             (xf5[0], yf5[0]), (xf5[1], yf5[1]), (xf5[2], yf5[2]),
             (xf5[3], yf5[3]), (xf5[4], yf5[4]), (xf5[5], yf5[5]),
             (xf5[6], yf5[6]), (xf5[7], yf5[7]), (xf5[8], yf5[8]),
             (xf5[9], yf5[9]), (650, 435), (675, 450), (xf6[0], yf6[0]),
             (xf6[1], yf6[1]), (xf6[2], yf6[2]), (xf6[3], yf6[3]),
             (xf6[4], yf6[4]), (xf6[5], yf6[5]), (xf6[6], yf6[6]),
             (xf6[7], yf6[7]), (xf6[8], yf6[8]), (xf6[9], yf6[9]),
             (xf6[10], yf6[10]), (xf6[11], yf6[11]), (xf6[12], yf6[12]),
             (xf6[13], yf6[13])])


# рисует третью линию гор, используя для рисования кривых массивы xf5, yf5 и xf6, yf6

canvasSize(1000, 500)
windowSize(1000, 500)
points_filling()
backstage()
mtn_line1()
mtn_line2()
mtn_line3()
sun(475, 95, 50)
penColor(51, 0, 29)
brushColor(51, 0, 29)
bird(750, 400, 1)
bird(650, 330, 0.8)
bird(775, 340, 0.5)
bird(675, 350, 0.5)
bird(475, 207, 0.5)
bird(475, 170, 0.5)
bird(425, 225, 0.5)
Beispiel #24
0
    if y0 > 800:
        y0 = 0


def bird(x, y, color):
    graph.penColor(color)
    graph.line(x, y, x + 20, y)
    graph.line((x + 20), y, (x + 37), y + 10)


def cir(a, b, r):
    graph.brushColor('yellow')
    graph.circle(a, b, r)


graph.windowSize(1200, 800)
graph.canvasSize(1200, 800)
graph.penSize(0)

graph.brushColor("#fed5a2")
graph.rectangle(0, 0, 1200, 200)
graph.brushColor("#fed5c4")
graph.rectangle(0, 200, 1200, 400)
graph.brushColor("#fed594")
graph.rectangle(0, 400, 1200, 600)
graph.brushColor("#b38694")
graph.rectangle(0, 600, 1200, 800)


def update():
    for i in range(1, 11):
Beispiel #25
0
from graph import windowSize, canvasSize, polygon, brushColor, rectangle, penColor, circle, line, run

windowSize(600, 600)
canvasSize(600, 600)


def ellipse(a, b, x0, y0):
    x = a
    y = 0
    s = [(x0 + a, y0)]
    for i in range(2 * a):
        x -= 1
        y = ((1 - x**2 / (a**2)) * b**2)**0.5
        s.append((x + x0, y + y0))
    for i in range(2 * a):
        x += 1
        y = -(((1 - x**2 / (a**2)) * b**2)**0.5)
        s.append((x + x0, y + y0))
    polygon(s)


def man(a, b):
    penColor(133, 133, 133)
    brushColor(133, 133, 133)
    ellipse(50, 95, a, b + 120)
    penColor(229, 194, 152)
    brushColor(229, 194, 152)
    circle(a, b, 45)
    penColor(0, 0, 0)
    # отрисовывает руки : первая строка - правую, а вторая строка - левую;
    line(a + 40, b + 60, a + 80, b + 140)
Beispiel #26
0

def ellipse(x0, y0, c, f):
    n = 1000
    a = []

    for num in range(n):
        x = x0 + c * m.cos(2 * m.pi * num / n)
        y = y0 + f * m.sin(2 * m.pi * num / n)
        a.append((x, y))

    result = graph.polygon(a)
    return result


graph.windowSize(450, 600)
graph.canvasSize(450, 600)

graph.brushColor("#00FFFF")
graph.rectangle(0, 0, 450, 600)

graph.brushColor("#00FF00")
graph.rectangle(0, 300, 450, 600)

graph.penColor("black")
graph.brushColor("#DEB887")
x1 = 0
y1 = 80

for i in range(15):
    graph.rectangle(x1, y1, (x1 + 30), (y1 + 250))