Example #1
0
def reset():
	set_size(512, 512)
	set_line_width(3)
	set_stroke_color(0,0,0)
	draw_rect(0, 0, 512, 512)
	set_line_width(1)
	set_stroke_color(0, 0, 1)
	return True
Example #2
0
def drawMinorTickmarks():
	for i in range(60):
		canvas.save_gstate()
		canvas.translate(centerX, centerY)
		canvas.rotate(-2 * pi / 60.0 * i)
		canvas.set_fill_color(0.4, 0.4, 0.4, 0.6)
		width = 1
		height = 5
		canvas.set_line_width(1)
		canvas.draw_rect(-width/2, clockWidth * 0.505, width, height)
		canvas.restore_gstate()		
Example #3
0
def drawMajorTickmarks2():
	for i in range(12):
		canvas.save_gstate()
		canvas.set_fill_color(0.3, 0.3, 0.3, 0.6)		
		width = height = 5
		angle = -2 * pi / 12.0 * (i - 3)
		length = clockWidth * 0.52
		rads = radians(angle)
		x = int(cos(angle) * length) + centerX
		y = int(sin(angle) * length) + centerY
		canvas.draw_rect(x - width/2, y - height/2, width, height)
		canvas.restore_gstate()		
Example #4
0
def reset():
    set_size(512, 512)
    home()
    set_stroke_color(0, 0, 0)
    draw_rect(0, 0, 512, 512)
    set_stroke_color(0, 0, 1)
Example #5
0
                 start_y - (0.5 * circle_size))

    rstrokedline(start_x - step, start_y + (1.5 * circle_size), start_x + step,
                 start_y - (1.5 * circle_size))
    rstrokedline(start_x - step, start_y - (1.5 * circle_size), start_x + step,
                 start_y + (1.5 * circle_size))

    rstrokedline(start_x - step, start_y + (2.5 * circle_size), start_x + step,
                 start_y - (2.5 * circle_size))
    rstrokedline(start_x - step, start_y - (2.5 * circle_size), start_x + step,
                 start_y + (2.5 * circle_size))

    rstrokedline(start_x - (3.0 * step), start_y + (0.5 * circle_size),
                 start_x + (3.0 * step), start_y - (0.5 * circle_size))
    rstrokedline(start_x - (3.0 * step), start_y - (0.5 * circle_size),
                 start_x + (3.0 * step), start_y + (0.5 * circle_size))


for x in xrange(int(math.ceil(width / circle_size)) + 1):
    for y in xrange(int(math.ceil(height / circle_size)) + 1):
        center_x = x * (2.0 * step)
        center_y = y * circle_size
        hexacircle(center_x, center_y)
        hexacircle(center_x + step, center_y + (0.5 * circle_size))

# Mute with a 15% black overlay
canvas.set_fill_color(0, 0, 0, 0.15)
canvas.draw_rect(0, 0, width, height)

canvas.end_updates()
Example #6
0
def fill_square(x, y, size, theme):
    canvas.set_fill_color(*shade_of(random.choice(theme.colors)))
    canvas.draw_rect(x, y, x + size, y + size)
Example #7
0
	canvas.fill_ellipse(*circle)

	# draw lines
	rstrokedline(start_x, start_y - circle_size, start_x, start_y + circle_size)
	rstrokedline(start_x - step, start_y, start_x + step, start_y)

	rstrokedline(start_x - step, start_y - (0.5 * circle_size), start_x + step, start_y + (0.5 * circle_size))
	rstrokedline(start_x - step, start_y + (0.5 * circle_size), start_x + step, start_y - (0.5 * circle_size))

	rstrokedline(start_x - step, start_y + (1.5 * circle_size), start_x + step, start_y - (1.5 * circle_size))
	rstrokedline(start_x - step, start_y - (1.5 * circle_size), start_x + step, start_y + (1.5 * circle_size))
    
	rstrokedline(start_x - step, start_y + (2.5 * circle_size), start_x + step, start_y - (2.5 * circle_size))
	rstrokedline(start_x - step, start_y - (2.5 * circle_size), start_x + step, start_y + (2.5 * circle_size))
    
	rstrokedline(start_x - (3.0 * step), start_y + (0.5 * circle_size), start_x + (3.0 * step), start_y - (0.5 * circle_size))
	rstrokedline(start_x - (3.0 * step), start_y - (0.5 * circle_size), start_x + (3.0 * step), start_y + (0.5 * circle_size))

for x in xrange(int(math.ceil(width/circle_size))+1):
	for y in xrange(int(math.ceil(height/circle_size))+1):
		center_x = x * (2.0 * step)
		center_y = y * circle_size
		hexacircle(center_x, center_y)
		hexacircle(center_x + step, center_y + (0.5 * circle_size))

# Mute with a 15% black overlay
canvas.set_fill_color(0,0,0,0.15)
canvas.draw_rect(0,0,width,height)

canvas.end_updates()
Example #8
0
# coding: utf-8

# https://forum.omz-software.com/topic/3191/can-t-fill-path

# use the canvas to draw a trapezoid

import canvas
b = 10
canvas.set_size(500, 500 + b)
canvas.draw_rect(0, 0 + b, 500, 500)
canvas.set_fill_color(1, 0.1, 0.1)
canvas.set_stroke_color(1, 0, 0)
canvas.set_line_width(4)
canvas.begin_path()
canvas.add_line(150, 100 + b)
canvas.add_line(350, 100 + b)
canvas.add_line(400, 200 + b)
canvas.add_line(100, 200 + b)
canvas.add_line(150, 100 + b)
canvas.draw_path()
canvas.fill_path()
canvas.close_path()

Example #9
0
 def draw_rect(self, x, y, width, height):
     return canvas.draw_rect(*self.xyWorld(x, y),
                             *self.whWorld(width, height))
Example #10
0
def reset():
	set_size(512, 512)
	home()
	set_stroke_color(0, 0, 0)
	draw_rect(0, 0, 512, 512)
	set_stroke_color(0, 0, 1)
Example #11
0
def fill_square(x, y, size, theme):
	canvas.set_fill_color(*shade_of(random.choice(theme.colors)))
	canvas.draw_rect(x, y, x + size, y + size)
		y = origin + y * scale + scale*2
		# hide first line
		if first:
			canvas.move_to(x, y)
			first = False
		else:
			canvas.add_line(x, y)
	# set color
	canvas.set_fill_color(1,0.5,0.5)
	canvas.set_stroke_color(0.5,0,0)
	canvas.set_line_width(detail/2)
	# draw heart
	if outline:
		canvas.draw_path()
	else:
		canvas.close_path()
		canvas.fill_path()
		
clear()
print 'Calculating... d =',detail
start = datetime.now()
canvas.set_size(w,h)
canvas.draw_rect(0,0, w,h)
#canvas.draw_line(0,h/2,w,h/2)
#canvas.draw_line(w/2,0,w/2,h)
draw_heart(True) # outlined
draw_heart() # filled
stop = datetime.now()
print(stop-start)