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()
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))
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()
def fon(): canvasSize(1200, 800) # drawing size penColor(0, 255, 0) # grass brushColor(0, 245, 0) rectangle(0, 400, 1200, 800) penColor(200, 230, 255) # sky brushColor(200, 230, 255) rectangle(0, 0, 1200, 400)
def background(): # Draws sky. canvasSize(1000, 600) brushColor(135, 206, 250) rectangle(0, 0, 1000, 300) # Draws sand. brushColor(255, 229, 124) rectangle(0, 600, 1000, 500) # Draws sea. brushColor(0, 0, 205) rectangle(0, 300, 1000, 500)
# 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),
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)
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) fancy_cloud(180, 30, 60, 70)
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:
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
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
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)
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)
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) color(40, 120, 150)
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)
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)
#!/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:
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, 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])
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()
def elips(x1, y1, x2, r): el = [] for x in range(int(x1), int(x2) + 1): el.append( (x, y1 + math.sqrt(abs(((x1 - x2) / 2)**2 / r - (x - (x1 + x2) / 2)**2 / r)))) for x in range(int(x2), int(x1), -1): el.append( (x, y1 - math.sqrt(abs(((x1 - x2) / 2)**2 / r - (x - (x1 + x2) / 2)**2 / r)))) graph.polygon(el) graph.canvasSize(794 * 900 / 1123, 900) graph.brushColor(0, 255, 255) graph.rectangle(0, 900 * 0.6, 794, 0) graph.brushColor(230, 230, 230) graph.rectangle(0, 900 * 0.6, 794 * 900 / 1123, 900) elips(794 * 900 / 1123 * 0.15, 900 * 0.49, 794 * 900 / 1123 * 0.35, 3) elips(2, 900 * 0.7, 794 * 900 / 1123 * 0.3, 0.3) graph.penSize(5) graph.polyline([(794 * 900 / 1123 * 0.3 + 5, 900 * 0.65), (794 * 900 / 1123 * 0.37, 900 * 0.565), (794 * 900 / 1123 * 0.8, 900 * 0.3)]) graph.penSize(1) graph.elips(794 * 900 / 1123 * 0.25, 900 * 0.595, 794 * 900 / 1123 * 0.4, 4) graph.elips(794 * 900 / 1123 * 0.15, 900 * 0.84, 794 * 900 / 1123 * 0.4, 1.7) graph.elips(794 * 900 / 1123 * 0.32, 900 * 0.9, 794 * 900 / 1123 * 0.5, 6) graph.circle(794 * 900 / 1123 * 0.18, 900 * 0.46, 10)
from math import sin, cos, pi from graph import canvasSize from graph import penSize, brushColor, penColor from graph import circle, rectangle, polygon from graph import run penSize(2) canvasSize(1200, 800) # основа penColor(0, 255, 0) brushColor(0, 245, 0) rectangle(0, 400, 1200, 800) penColor(200, 230, 255) brushColor(200, 230, 255) rectangle(0, 0, 1200, 400) penColor(255, 50, 200) brushColor("yellow") # солнце verts = [] t = 0 while t < 241: z_1 = pi / 120 * t z_2 = pi / 8 * t x = 100 + 50 * (1 + 0.05 * sin(z_2)) * cos(z_1) y = 100 + 50 * (1 + 0.05 * sin(z_2)) * sin(z_1) verts.append((x, y)) t += 1 polygon(verts) penColor(0, 0, 0) brushColor(210, 200, 10) # дом1
brushColor(51, 0, 51) 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)
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): x = 1.1**i
def ghost(x, y, r, g, b): brushColor(r, g, b) a = polygon([(350 + x, 400 + y), (355 + x, 410 + y), (360 + x, 405 + y), (365 + x, 410 + y), (370 + x, 407 + y), (375 + x, 403 + y), (380 + x, 400 + y), (385 + x, 403 + y), (390 + x, 400 + y), (395 + x, 407 + y), (400 + x, 405 + y), (405 + x, 407 + y), (400 + x, 420 + y), (395 + x, 390 + y), (393 + x, 393 + y), (390 + x, 390 + y), (385 + x, 387 + y), (380 + x, 385 + y), (376 + x, 380 + y), (373 + x, 376 + y), (370 + x, 360 + y), (368 + x, 345 + y), (365 + x, 343 + y), (360 + x, 340 + y), (357 + x, 343 + y), (351 + x, 357 + y), (350 + x, 400 + y)]) return a windowSize(500, 600) canvasSize(800, 800) brushColor(101, 67, 33) rectangle(0, 300, 500, 800) brushColor("#c7fcec") rectangle(0, 0, 500, 300) dom(0, 0, 0, 0, 0) brushColor(176, 196, 222) a = ghost(-100, -100, 33, 232, 33) penColor(255, 255, 254) brushColor(255, 255, 254) circle(460, 50, 40) el(370, 170, 0, 255, 255) el(350, 70, 10, 243, 30) el(250, 50, 20, 255, 255) penColor(0, 0, 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)) x1 = x1 + 30 # 30 is wieght of zabor