Пример #1
0
def draw_a_circle(game_array):
    for j in range(9):
        for k in range(7):
            if game_array[j][k] == 4:
                stddraw.circle(k + 0.5, j + 0.5, 0.3)
                stddraw.setPenColor(stddraw.RED)
                stddraw.filledCircle(k + 0.5 , j + 0.5 , 0.3)
def draw_marker(x, y, turn_number):
    if turn_number % 2 != 0:
        #player one clicked
        #draw an X
        stddraw.line(x + 0.1, y + (1 / 3) - 0.1, x + (1 / 3) - 0.1, y + 0.1)
        stddraw.line(x + 0.1, y + 0.1, x + (1 / 3) - 0.1, y + (1 / 3) - 0.1)
    else:
        #player two clicked
        #draw an O
        stddraw.circle(x + (1 / 3) / 2, y + (1 / 3) - (1 / 3) / 2, 0.1)
Пример #3
0
def player_one_draw(game_array_in_def):
    x = stddraw.mouseX()
    y = stddraw.mouseY()
    for j in range(3):
        for k in range(3):
            if x >= j and x <= j + 1 and y >= k and y <= k + 1:
                stddraw.circle(j + 0.5, k + 0.5, 0.3)
                game_array_in_def[j][k] = 1

    return game_array_in_def
Пример #4
0
def draw_the_picture(game_array):
    stddraw.line(0, 2, 3, 2)
    stddraw.line(0, 1, 3, 1)
    stddraw.line(1, 0, 1, 3)
    stddraw.line(2, 0, 2, 3)
    stddraw.line(3, 0, 3, 3)
    stddraw.line(0, 3, 3, 3)
    for i in range(3):
        for x in range(3):
            if game_array[i][x] == 1:
                stddraw.circle(i + 0.5, x + 0.5, 0.3)
            if game_array[i][x] == 2:
                stddraw.line(i + 0.3, x + 0.7, i + 0.7, x + 0.3)
                stddraw.line(i + 0.3, x + 0.3, i + 0.7, x + 0.7)
def draw_hanging_man(guesses_remaining):
    #draw floor
    stddraw.line(0.2, 0.4, 0.8, 0.4)
    stddraw.rectangle(0.3, 0.4, 0.4, 0.04)
    if guesses_remaining <= 7:
        #head
        stddraw.circle(0.5, 0.8, 0.07)
        if guesses_remaining <= 6:
            #torso
            stddraw.line(0.5, 0.73, 0.5, 0.55)
            if guesses_remaining <= 5:
                #left arm
                stddraw.line(0.5, 0.73, 0.425, 0.655)
                if guesses_remaining <= 4:
                    #right arm
                    stddraw.line(0.5, 0.73, 0.575, 0.655)
                    if guesses_remaining <= 3:
                        #left leg
                        stddraw.line(0.5, 0.55, 0.425, 0.465)
                        if guesses_remaining <= 2:
                            #right leg
                            stddraw.line(0.5, 0.55, 0.575, 0.465)
                            if guesses_remaining <= 1:
                                #gallows
                                stddraw.line(0.7, 0.404, 0.7, 0.9)
                                stddraw.line(0.7, 0.9, 0.5, 0.9)
                                stddraw.line(0.5, 0.9, 0.5, 0.87)
                                if guesses_remaining == 0:
                                    #face
                                    #left eye
                                    stddraw.line(0.465, 0.82, 0.485, 0.8)
                                    stddraw.line(0.485, 0.82, 0.465, 0.8)

                                    #right eye
                                    stddraw.line(0.515, 0.82, 0.535, 0.8)
                                    stddraw.line(0.535, 0.82, 0.515, 0.8)
                                    #mouth
                                    stddraw.line(0.475, 0.775, 0.525, 0.775)
Пример #6
0
def draw_hangman(guesses):
		stddraw.setPenColor(stddraw.BLACK)
		if guesses == 7:
			#head
			stddraw.circle(0.5,0.8,0.07)
		elif guesses == 6:
			#body
			stddraw.line(0.5,0.73,0.5,0.5)
		elif guesses == 5:
			#left hand
			stddraw.line(0.5,0.67,0.55,0.53)
		elif guesses == 4:
			#right hand
			stddraw.line(0.5,0.67,0.45,0.53)
		elif guesses ==3:
			#left leg
			stddraw.line(0.5,0.5,0.55,0.36)
		elif guesses == 2:
			#right leg
			stddraw.line(0.5,0.5,0.45,0.36)
		elif guesses == 1:
			#gallows
			stddraw.line(0.5,0.87,0.5,0.95)
			stddraw.line(0.5,0.95,0.8,0.95)
			stddraw.line(0.8,0.95,0.8,0.3)
			stddraw.line(0.9,0.3,0.4,0.3)
			stddraw.line(0.4,0.3,0.4,0.28)
			stddraw.line(0.9,0.3,0.9,0.28)
			stddraw.line(0.0,0.28,1.0,0.28)
		else:
			#face
			stddraw.line(0.47,0.8,0.488,0.82)
			stddraw.line(0.488,0.8,0.47,0.82)
			stddraw.line(0.518,0.8,0.536,0.82)
			stddraw.line(0.536,0.8,0.518,0.82)
			stddraw.line(0.47,0.77,0.53,0.77)
		stddraw.show(0)
Пример #7
0
def drawShapes(number,x,y):
    stddraw.setPenColor(stddraw.BLACK)
    stddraw.setPenRadius(0.01)
    if number == 0:
        stddraw.square(x,y,0.4)
        stddraw.setPenColor(stddraw.YELLOW)
        stddraw.filledSquare(x,y,0.4)
    if number == 1:
        stddraw.setPenColor(stddraw.RED)
        stddraw.filledCircle(x,y,0.4)
        stddraw.setPenColor(stddraw.BLACK)
        stddraw.setPenRadius(0.004)
        stddraw.circle(x,y,0.4)
    if number == 2:
        xs = [x-0.4,x+0.4,x]
        ys = [y-0.4,y-0.4,y+0.4]
        stddraw.polygon(xs,ys)
        stddraw.setPenColor(stddraw.ORANGE)
        stddraw.filledPolygon(xs,ys)
    if number == 3:
        xs = [x-0.4,x,x+0.4,x]
        ys = [y,y+0.4,y,y-0.4]
        stddraw.polygon(xs,ys)
        stddraw.setPenColor(stddraw.GREEN)
        stddraw.filledPolygon(xs,ys)
    if number == 4:
        xs = [x-0.4,x-0.2,x+0.2,x+0.4,x]
        ys = [y,y+0.4,y+0.4,y,y-0.4]
        stddraw.polygon(xs,ys)
        stddraw.setPenColor(stddraw.MAGENTA)
        stddraw.filledPolygon(xs,ys)
    if number == 5:
        xs = [x-0.4,x-0.2,x+0.4,x+0.2]
        ys = [y-0.4,y+0.4,y+0.4,y-0.4]
        stddraw.polygon(xs,ys)
        stddraw.setPenColor(stddraw.BLUE)
        stddraw.filledPolygon(xs,ys)
Пример #8
0
def main():
    R = 3
    stddraw.setXscale(-5*R,5*R)
    stddraw.setYscale(-5*R,5*R)
    stddraw.setCanvasSize(700,700)
    stddraw.circle(0,0,R)
    centerPointArray1 = centers(0,0,R)

    # stddraw.setPenColor(stddraw.RED)
    # for i in range(-6*R,6*R):
    #     for j in range(-6*R,6*R):
    #         stddraw.line(i,j,i,(6*R)-j)
    #         stddraw.line(i, j, (6*R)-i, j)

    # stddraw.setPenColor(stddraw.BLACK)
    for i in range(6):
        stddraw.circle(centerPointArray1[i][0], centerPointArray1[i][1], R)
        stddraw.show(50)

    for i in range(6):
        centerPointArray2 = centers(centerPointArray1[i][0], centerPointArray1[i][1], R)
        for j in range(6):
            stddraw.circle(centerPointArray2[j][0], centerPointArray2[j][1], R)
            # stddraw.picture('python.png' ,centerPointArray2[j][0], centerPointArray2[j][1] )
            for k in range(6):
                centerPointArray3 = centers(centerPointArray2[k][0], centerPointArray2[k][1], R)
                for p in range(6):
                    stddraw.circle(centerPointArray3[p][0], centerPointArray3[p][1], R)
                    # stddraw.picture('python.png', centerPointArray3[p][0], centerPointArray3[p][1])
                    stddraw.show(15)

    # for i in range(6):
    #     centerPointArray3 = centers(centerPointArray2[i][0], centerPointArray2[i][1], R)
    #     for j in range(6):
    #         stddraw.circle(centerPointArray3[j][0], centerPointArray3[j][1], R)
    #         stddraw.show(50)

    stddraw.show()
Пример #9
0
def set_the_head():
    stddraw.setPenRadius(0.005)
    stddraw.circle(6, 6, 1)
Пример #10
0
import stddraw as d
import sys

d.square(.2, .8, .1)

d.filledSquare(.8, .8, .2)

d.circle(.8, .2, .2)

d.show(0)

c = ''
while c != '.':
    c = input()
Пример #11
0
import time
import stddraw
import math

time_aggregate = time.localtime()
hour = time_aggregate.tm_hour
minute = time_aggregate.tm_min
second = time_aggregate.tm_sec

stddraw.setXscale(-1.5, 1.5)
stddraw.setYscale(-1.5, 1.5)

#draw circle
stddraw.setPenColor(stddraw.BLACK)
stddraw.setPenRadius(0.005)
stddraw.circle(0.0, 0.0, 1.2)
stddraw.setPenColor(stddraw.CYAN)
stddraw.circle(0.0, 0.0, 1.3)

#set up 1-12
stddraw.setFontSize(30)
stddraw.text(0, 1, '12')
stddraw.text(1 / 2, math.sqrt(3) / 2, '1')
stddraw.text(math.sqrt(3) / 2, 1 / 2, '2')
stddraw.text(1, 0, '3')
stddraw.text(math.sqrt(3) / 2, -1 / 2, '4')
stddraw.text(1 / 2, math.sqrt(3) / -2, '5')
stddraw.text(0, -1, '6')
stddraw.text(-1 / 2, math.sqrt(3) / -2, '7')
stddraw.text(math.sqrt(3) / -2, -1 / 2, '8')
stddraw.text(-1, 0, '9')
Пример #12
0
time_aggregate = time.localtime()
hour = time_aggregate.tm_hour
minute = time_aggregate.tm_min
second = time_aggregate.tm_sec

if hour > 12:
    hour = hour - 12
seconds = hour * 60 * 60 + minute * 60 + second
angle_hour = 450 - ((seconds / (12 * 60 * 60)) * 360)

minutes_angle = 450 - (minute / 60) * 360

seconds_angle = 450 - (second / 60) * 360

stddraw.circle(0.5, 0.5, .5)
stddraw.circle(0.5, 0.5, .45)

x = (math.cos(math.radians(seconds_angle)) * 0.5 * 0.7) + 0.5
y = (math.sin(math.radians(seconds_angle)) * 0.5 * 0.7) + 0.5

x1 = (math.cos(math.radians(minutes_angle)) * 0.5 * 0.5) + 0.5
y1 = (math.sin(math.radians(minutes_angle)) * 0.5 * 0.5) + 0.5

x2 = (math.cos(math.radians(angle_hour)) * 0.5 * 0.3) + 0.5
y2 = (math.sin(math.radians(angle_hour)) * 0.5 * 0.3) + 0.5

test3 = 0
adjust_number = 9
adjust_number2 = 3
for i in range(12):
def draw_hangman(i):
    stddraw.setXscale(-1, 1)
    stddraw.setYscale(-1, 1)

    stddraw.setPenColor(stddraw.BLACK)


    if i == 8:                      #Draw the gallows ( without the hanging rope )
        stddraw.line(-0.7, 0.90, -0.5, 0.90)
        stddraw.line(-0.5, 0.90, -0.5, 0.10)
        stddraw.line(-0.5, 0.10, -0.9, 0.10)
        stddraw.line(-0.9, 0.10, -0.9, 0)
        stddraw.line(-0.9, 0, -0.1, 0)
        stddraw.line(-0.1, 0, -0.1, 0.10)
        stddraw.line(-0.1, 0.10, -0.8,0.10)
        stddraw.show(0)

    elif i== 7:                     #Draw face

        stddraw.circle(-0.7, 0.75, 0.05)

        stddraw.line(-0.7, 0.90, -0.5, 0.90)
        stddraw.line(-0.5, 0.90, -0.5, 0.10)
        stddraw.line(-0.5, 0.10, -0.9, 0.10)
        stddraw.line(-0.9, 0.10, -0.9, 0)
        stddraw.line(-0.9, 0, -0.1, 0)
        stddraw.line(-0.1, 0, -0.1, 0.10)
        stddraw.line(-0.1, 0.10, -0.8, 0.10)

        stddraw.show(0)

    elif i==6:                       #Draw neck
        stddraw.circle(-0.7, 0.75, 0.05)
        stddraw.line(-0.7, 0.70, -0.7, 0.65)

        stddraw.line(-0.7, 0.90, -0.5, 0.90)
        stddraw.line(-0.5, 0.90, -0.5, 0.10)
        stddraw.line(-0.5, 0.10, -0.9, 0.10)
        stddraw.line(-0.9, 0.10, -0.9, 0)
        stddraw.line(-0.9, 0, -0.1, 0)
        stddraw.line(-0.1, 0, -0.1, 0.10)
        stddraw.line(-0.1, 0.10, -0.8, 0.10)

        stddraw.show(0)

    elif i==5:                       #Draw left hand
        stddraw.circle(-0.7, 0.75, 0.05)

        stddraw.line(-0.7, 0.70, -0.7, 0.65)
        stddraw.line(-0.7, 0.65, -0.8, 0.60)
        stddraw.line(-0.7, 0.90, -0.5, 0.90)
        stddraw.line(-0.5, 0.90, -0.5, 0.10)
        stddraw.line(-0.5, 0.10, -0.9, 0.10)
        stddraw.line(-0.9, 0.10, -0.9, 0)
        stddraw.line(-0.9, 0, -0.1, 0)
        stddraw.line(-0.1, 0, -0.1, 0.10)
        stddraw.line(-0.1, 0.10, -0.8, 0.10)

        stddraw.show(0)

    elif i==4:                        #Draw right hand
        stddraw.circle(-0.7, 0.75, 0.05)
        stddraw.line(-0.7, 0.70, -0.7, 0.65)
        stddraw.line(-0.7, 0.65, -0.8, 0.60)
        stddraw.line(-0.7, 0.65, -0.6, 0.60)
        stddraw.line(-0.7, 0.90, -0.5, 0.90)
        stddraw.line(-0.5, 0.90, -0.5, 0.10)
        stddraw.line(-0.5, 0.10, -0.9, 0.10)
        stddraw.line(-0.9, 0.10, -0.9, 0)
        stddraw.line(-0.9, 0, -0.1, 0)
        stddraw.line(-0.1, 0, -0.1, 0.10)
        stddraw.line(-0.1, 0.10, -0.8, 0.10)

        stddraw.show(0)

    elif i==3:                                 #Draw body
        stddraw.circle(-0.7, 0.75, 0.05)
        stddraw.line(-0.7, 0.70, -0.7, 0.65) #neck
        stddraw.line(-0.7, 0.65, -0.8, 0.60) #left hand
        stddraw.line(-0.7, 0.65, -0.6, 0.60) #right hand
        stddraw.line(-0.7, 0.65, -0.7, 0.40) #body

        stddraw.line(-0.7, 0.90, -0.5, 0.90)
        stddraw.line(-0.5, 0.90, -0.5, 0.10)
        stddraw.line(-0.5, 0.10, -0.9, 0.10)
        stddraw.line(-0.9, 0.10, -0.9, 0)
        stddraw.line(-0.9, 0, -0.1, 0)
        stddraw.line(-0.1, 0, -0.1, 0.10)
        stddraw.line(-0.1, 0.10, -0.8, 0.10)
        stddraw.show(0)

    elif i == 2:                        #Draw left leg
        stddraw.circle(-0.7, 0.75, 0.05)
        stddraw.line(-0.7, 0.70, -0.7, 0.65)  # neck
        stddraw.line(-0.7, 0.65, -0.8, 0.60)  # left hand
        stddraw.line(-0.7, 0.65, -0.6, 0.60)  # right hand
        stddraw.line(-0.7, 0.65, -0.7, 0.40)  # body
        stddraw.line(-0.7, 0.40, -0.8, 0.35)  # left leg

        stddraw.line(-0.7, 0.90, -0.5, 0.90)
        stddraw.line(-0.5, 0.90, -0.5, 0.10)
        stddraw.line(-0.5, 0.10, -0.9, 0.10)
        stddraw.line(-0.9, 0.10, -0.9, 0)
        stddraw.line(-0.9, 0, -0.1, 0)
        stddraw.line(-0.1, 0, -0.1, 0.10)
        stddraw.line(-0.1, 0.10, -0.8, 0.10)

        stddraw.show(0)

    elif i == 1:                           #Draw right leg
        stddraw.circle(-0.7, 0.75, 0.05)

        stddraw.line(-0.7, 0.70, -0.7, 0.65)  # neck
        stddraw.line(-0.7, 0.65, -0.8, 0.60)  # left hand
        stddraw.line(-0.7, 0.65, -0.6, 0.60)  # right hand
        stddraw.line(-0.7, 0.65, -0.7, 0.40)  # body
        stddraw.line(-0.7, 0.40, -0.8, 0.35)  # left leg
        stddraw.line(-0.7, 0.40, -0.6, 0.35)  # right leg
        stddraw.line(-0.7, 0.40, -0.6, 0.35)
        stddraw.line(-0.7, 0.90, -0.5, 0.90)
        stddraw.line(-0.5, 0.90, -0.5, 0.10)
        stddraw.line(-0.5, 0.10, -0.9, 0.10)
        stddraw.line(-0.9, 0.10, -0.9, 0)
        stddraw.line(-0.9, 0, -0.1, 0)
        stddraw.line(-0.1, 0, -0.1, 0.10)
        stddraw.line(-0.1, 0.10, -0.8, 0.10)

        stddraw.show(0)

    elif i == 0:                            # finally draw the hanging rope
        stddraw.circle(-0.7, 0.75, 0.05)
        stddraw.setPenColor(stddraw.RED)
        stddraw.line(-0.7, 0.90, -0.7, 0.80)  #hangrope
        stddraw.setPenColor(stddraw.BLACK)
        stddraw.line(-0.7, 0.70, -0.7, 0.65)  # neck
        stddraw.line(-0.7, 0.65, -0.8, 0.60)  # left hand
        stddraw.line(-0.7, 0.65, -0.6, 0.60)  # right hand
        stddraw.line(-0.7, 0.65, -0.7, 0.40)  # body
        stddraw.line(-0.7, 0.40, -0.8, 0.35)  # left leg
        stddraw.line(-0.7, 0.40, -0.6, 0.35)  # right leg
        stddraw.line(-0.7, 0.40, -0.6, 0.35)
        stddraw.line(-0.7, 0.90, -0.5, 0.90)
        stddraw.line(-0.5, 0.90, -0.5, 0.10)
        stddraw.line(-0.5, 0.10, -0.9, 0.10)
        stddraw.line(-0.9, 0.10, -0.9, 0)
        stddraw.line(-0.9, 0, -0.1, 0)
        stddraw.line(-0.1, 0, -0.1, 0.10)
        stddraw.line(-0.1, 0.10, -0.8, 0.10)


        stddraw.show(0)
Пример #14
0
def drawO(x, y):
    stddraw.setPenColor(stddraw.BLACK)
    stddraw.setPenRadius(0.01)
    stddraw.circle(x, y, 2.5)
Пример #15
0
import stdio
import stddraw
y = 1
check = False
for i in range(1000):
	stddraw.clear()
	stddraw.circle(0.5,y,0.1)
	stddraw.show(120)
	if y <= 0:
		check = False
	if y >= 1:
		check = True
	if check == True:
		y = y - 0.1
	else:
		y = y + 0.1
    
Пример #16
0
def drawRCircle(x, y):
    erase(x, y)
    stddraw.setPenColor(stddraw.RED)
    stddraw.filledCircle(x, y, r)
    stddraw.setPenColor(stddraw.BLACK)
    stddraw.circle(x, y, r)
Пример #17
0
import stddraw

radius = 0.5
keep_drawing = True

while keep_drawing:
	stddraw.circle(0.5, 0.5, radius)
	stddraw.show(0.0)
	radius *= 0.8
	response = input("Draw another circle? ")
	keep_drawing = (response == 'y')
Пример #18
0
import stddraw as d

N = 20
d.setXscale(0, N)
d.setYscale(0, N)

d.circle(10, 10, 10)

for i in range(1, 10):
    d.circle(10, 10, 10 - i)
    d.show(1000)
Пример #19
0
#-----------------------------------------------------------------------
# shapestext.py
#-----------------------------------------------------------------------

import stddraw

# Draw some shapes and some text.
stddraw.createWindow()
stddraw.square(.2, .8, .1)

stddraw.filledSquare(.8, .8, .2)

stddraw.circle(.8, .2, .2)

xd = [.1, .2, .3, .2]
yd = [.2, .3, .2, .1]
stddraw.filledPolygon(xd, yd)

stddraw.setFontFamily('Times')
stddraw.setFontSize(40)
stddraw.text(.2, .5, 'black')

stddraw.setPenColor(stddraw.WHITE)
stddraw.setFontFamily('Courier')
stddraw.setFontSize(30)
stddraw.text(.8, .8, 'white')

stddraw.show()
stddraw.wait()
Пример #20
0
def drawPiece(x, y, ay):

    stddraw.setPenRadius(0.008)

    if board[y][x] == 0: #diamond
        FILL = Color(250,252,255)
        stddraw.setPenColor(FILL)
        xs = [x+0.5, x+0.2, x+0.35, x+0.65, x+0.8]
        ys = [y+ay+0.2, y+ay+0.5, y+ay+0.7, y+ay+0.7, y+ay+0.5]
        stddraw.filledPolygon(xs, ys)

        OUTLINE = Color(220,225,255)
        stddraw.setPenColor(OUTLINE)
        xs = [x+0.5, x+0.2, x+0.35, x+0.65, x+0.8]
        ys = [y+ay+0.2, y+ay+0.5, y+ay+0.7, y+ay+0.7, y+ay+0.5]
        stddraw.polygon(xs, ys)

    if board[y][x] == 1: #emerald
        FILL = Color(180,255,180)
        stddraw.setPenColor(FILL)
        xs = [x+0.5, x+0.7, x+0.7, x+0.5, x+0.3, x+0.3]
        ys = [y+ay+0.8, y+ay+0.6, y+ay+0.4, y+ay+0.2, y+ay+0.4, y+ay+0.6]
        stddraw.filledPolygon(xs, ys)

        FILL = Color(210,255,210)
        stddraw.setPenColor(FILL)
        xs = [x+0.5, x+0.7, x+0.5, x+0.3]
        ys = [y+ay+0.8, y+ay+0.6, y+ay+0.4, y+ay+0.6]
        stddraw.filledPolygon(xs, ys)

        OUTLINE = Color(100,225,100)
        stddraw.setPenColor(OUTLINE)
        xs = [x+0.5, x+0.7, x+0.7, x+0.5, x+0.3, x+0.3]
        ys = [y+ay+0.8, y+ay+0.6, y+ay+0.4, y+ay+0.2, y+ay+0.4, y+ay+0.6]
        stddraw.polygon(xs, ys)

    if board[y][x] == 2: #ruby
        FILL = Color(245,140,140)
        stddraw.setPenColor(FILL)
        xs = [x+0.65, x+0.75, x+0.75, x+0.65, x+0.35, x+0.25, x+0.25, x+0.35]
        ys = [y+ay+0.8, y+ay+0.7, y+ay+0.3, y+ay+0.2, y+ay+0.2, y+ay+0.3, y+ay+0.7, y+ay+0.8]
        stddraw.filledPolygon(xs, ys)

        FILL2 = Color(255,180,180)
        stddraw.setPenColor(FILL2)
        xs = [x+0.65, x+0.75, x+0.5, x+0.25, x+0.35]
        ys = [y+ay+0.8, y+ay+0.7, y+ay+0.5, y+ay+0.7, y+ay+0.8]
        stddraw.filledPolygon(xs, ys)

        OUTLINE = Color(205,80,80)
        stddraw.setPenColor(OUTLINE)
        xs = [x+0.65, x+0.75, x+0.75, x+0.65, x+0.35, x+0.25, x+0.25, x+0.35]
        ys = [y+ay+0.8, y+ay+0.7, y+ay+0.3, y+ay+0.2, y+ay+0.2, y+ay+0.3, y+ay+0.7, y+ay+0.8]
        stddraw.polygon(xs, ys)

    if board[y][x] == 3: #saphhire
        FILL = Color(60,120,255)
        stddraw.setPenColor(FILL)
        stddraw.filledCircle(x+0.5, y+ay+0.5, 0.3)

        FILL = Color(80,190,255) 
        stddraw.setPenColor(FILL)
        stddraw.filledCircle(x+0.4, y+ay+0.6, 0.1)

        OUTLINE = Color(20,50,255) 
        stddraw.setPenColor(OUTLINE)
        stddraw.circle(x+0.5, y+ay+0.5, 0.3)

    if board[y][x] == 4: #topaz
        FILL = Color(255,255,200)
        stddraw.setPenColor(FILL)
        xs = [x+0.5, x+0.2, x+0.3, x+0.7]
        ys = [y+ay+0.2, y+ay+0.5, y+ay+0.7, y+ay+0.7]
        stddraw.filledPolygon(xs, ys)

        OUTLINE = Color(225,225,100)
        stddraw.setPenColor(OUTLINE)
        stddraw.polygon(xs, ys)

    if board[y][x] == 5: #amethyst
        FILL = Color(225,170,225)
        stddraw.setPenColor(FILL)
        xs = [x+0.5, x+0.8, x+0.5, x+0.2]
        ys = [y+ay+0.8, y+ay+0.5, y+ay+0.2, y+ay+0.5]
        stddraw.filledPolygon(xs, ys)

        FILL = Color(245,180,245)
        stddraw.setPenColor(FILL)
        xs = [x+0.5, x+0.5, x+0.2]
        ys = [y+ay+0.8, y+ay+0.4, y+ay+0.5]
        stddraw.filledPolygon(xs, ys)

        OUTLINE = Color(155,100,155)
        stddraw.setPenColor(OUTLINE)
        xs = [x+0.5, x+0.8, x+0.5, x+0.2]
        ys = [y+ay+0.8, y+ay+0.5, y+ay+0.2, y+ay+0.5]
        stddraw.polygon(xs, ys)

    if board[y][x] == 6: #aquamarine
        FILL = Color(100,250,220)
        stddraw.setPenColor(FILL)
        xs = [x+0.5, x+0.8, x+0.7, x+0.3, x+0.2]
        ys = [y+ay+0.8, y+ay+0.4, y+ay+0.2, y+ay+0.2, y+ay+0.4]
        stddraw.filledPolygon(xs, ys)

        FILL = Color(190,255,250)
        stddraw.setPenColor(FILL)
        xs = [x+0.5, x+0.7, x+0.6, x+0.4, x+0.3]
        ys = [y+ay+0.7, y+ay+0.45, y+ay+0.3, y+ay+0.3, y+ay+0.45]
        stddraw.filledPolygon(xs, ys)

        OUTLINE = Color(50,200,170) 
        stddraw.setPenColor(OUTLINE)
        xs = [x+0.5, x+0.8, x+0.7, x+0.3, x+0.2]
        ys = [y+ay+0.8, y+ay+0.4, y+ay+0.2, y+ay+0.2, y+ay+0.4]
        stddraw.polygon(xs, ys)

    if board[y][x] == 7: #citrine
        FILL = Color(255,160,70)
        stddraw.setPenColor(FILL)
        xs = [x+0.3, x+0.2, x+0.7, x+0.7]
        ys = [y+ay+0.2, y+ay+0.6, y+ay+0.8, y+ay+0.3]
        stddraw.filledPolygon(xs, ys)

        FILL = Color(255,190,90)
        stddraw.setPenColor(FILL)
        xs = [x+0.5, x+0.2, x+0.7, x+0.7]
        ys = [y+ay+0.5, y+ay+0.6, y+ay+0.8, y+ay+0.6]
        stddraw.filledPolygon(xs, ys)

        OUTLINE = Color(205,100,30) 
        stddraw.setPenColor(OUTLINE)
        xs = [x+0.3, x+0.2, x+0.7, x+0.7]
        ys = [y+ay+0.2, y+ay+0.6, y+ay+0.8, y+ay+0.3]
        stddraw.polygon(xs, ys)
Пример #21
0
def Head(guess):
    if guess <= 7:
        stddraw.setPenRadius(0.09 * 400 / ((10 - -10) * 256))
        stddraw.circle(-2, 6, 2.0)
        stddraw.show(100)
Пример #22
0
def hand_end_point(point, hour_hand):
    #each hands scale down factor is multiple of scale_down and translation to insure proper scaling
    if hour_hand:
        #scales the hour hand down by radius of clock/2
        return (point + 2.5) / 5
    else:
        #scales the minute hand down by radius of clock/1.5
        return (point + 1.875) / 3.75


#loop to make clock animate
while True:
    stddraw.clear()
    stddraw.setPenRadius(0.007)
    #draw clock borders
    stddraw.circle(0.5, 0.5, 0.48)
    stddraw.circle(0.5, 0.5, 0.45)

    #draw in numbers
    for i in range(12):
        stddraw.text(point_to_scale(x_value_unit_circle[i]),
                     point_to_scale(y_value_unit_circle[i]),
                     str(i) if not i == 0 else "12")

    #get current time
    time_aggregate = datetime.datetime.now()
    hour = time_aggregate.hour
    minute = time_aggregate.minute
    second = time_aggregate.second

    stddraw.text(0.1, 0.95, str(hour) + ":" + str(minute) + ":" + str(second))
Пример #23
0
import stddraw
from reloj import *
import time


def iniciarSegundero(x0, y0, x1, y1, reloj):
    stddraw.line(x0, y0, x1, y1)
    reloj.sumarSegundos()
    print(reloj.segundos)


reloj = Reloj(1, 2, 3)

stddraw.setCanvasSize(700, 700)
stddraw.setXscale(-1.0, 1.0)
stddraw.setYscale(-1.0, 1.0)
stddraw.setPenRadius(0.001)
stddraw.circle(0.0, 0.0, 1.0)

stddraw.line(0, 0, 0, 1)
stddraw.show(0)

while True:
    stddraw.clear(stddraw.LIGHT_GRAY)
    stddraw.circle(0.0, 0.0, 1.0)
    punto = reloj.actualizarSegundero()
    iniciarSegundero(0, 0, punto[0] * -1, punto[1], reloj)
    stddraw.show(0)
    time.sleep(1)
stddraw.setXscale(-1.0, 1.0)
stddraw.setYscale(-1.0, 1.0)

rx = .480
ry = .860
vx = .015
vy = .023

rx_ = None
ry_ = None

stddraw.clear(stddraw.GRAY)
while True:
    if abs(rx + vx) + RADIUS > 1.0:
        vx = -vx
    if abs(ry + vy) + RADIUS > 1.0:
        vy = -vy
    rx = rx + vx
    ry = ry + vy * 0.8

    # stddraw.clear(stddraw.GRAY)
    if rx_ is not None and ry_ is not None:
        stddraw.setPenColor(stddraw.GRAY)
        stddraw.filledCircle(rx_, ry_, RADIUS)
        stddraw.setPenColor(stddraw.BLACK)
        stddraw.circle(rx_, ry_, RADIUS)
    stddraw.filledCircle(rx, ry, RADIUS)
    rx_ = rx
    ry_ = ry
    stddraw.show(0)