本文整理汇总了Python中tealight.art.color函数的典型用法代码示例。如果您正苦于以下问题:Python color函数的具体用法?Python color怎么用?Python color使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了color函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_mousemove
def handle_mousemove(x,y,button):
if button == "left":
color("cyan")
circle(x,y,10)
if button == "right":
color("random")
circle(x,y,5)
示例2: draw
def draw(self, position = [30, 30], size = [200,200]):
#Convert rgba vector to string
def coltostr(col):
string_out = "rgba("
for i in range(0,3):
string_out = string_out + str(int(col[i])) + ","
string_out = string_out + str(col[3]) + ")"
return string_out
for i in range(0, self.i_size):
for j in range(0, self.j_size):
#Set rgba value based on max value
#Convert to color string "rgba(...)
#Positive values are red, negative are blue
#Values close to zero will be paler
if self.array[i][j] >= 0 :
alpha_value = 1.0 * self.array[i][j]/self.max()
rgba_string = coltostr([255, 0, 0, alpha_value])
else:
alpha_value = 1.0 * self.array[i][j]/self.min()
rgba_string = coltostr([0, 0, 255, alpha_value])
#Draw box
color(rgba_string)
box(position[0] + j * size[0]/self.j_size,
position[1] + i * size[1]/self.i_size,
size[0]/self.j_size - 1,
size[1]/self.i_size - 1)
示例3: handle_frame
def handle_frame():
global x,y,vx,vy,ax,ay
color("white")
spot(x,y,8)
vx = vx + ax
vy = vy + ay
#gravity
vy = vy + gravity
apply_gravity()
#friction
vx = apply_friction(vx)
vy = apply_friction(vy)
x = x + vx
y = y + vy
color("blue")
spot(x,y,8)
示例4: DrawPalette
def DrawPalette(x,y, colors, w, h):
for c in colors:
color(c)
box(x, y, w, h)
y = y + h
colors = ["black", "grey"]
示例5: handle_frame
def handle_frame():
global x,y,vx,vy,ax,ay
if 1000 < y:
vy=-vy
elif y < 1:
vy=-vy
if 910 < x:
vx=-vx
elif x < 1:
vx=-vx
color("white")
spot(x,y,8)
vx = vx + ax
vy = vy + ay
x = x + vx
y = y + vy
color("blue")
spot(x,y,8)
示例6: handle_frame
def handle_frame():
global x,y,vx,vy,constant,n
n = n + 1
for i in range(0,len(x)):
color("white")
spot(x[i],y[i],2)
vx[i] = vx[i] + constant[i]
angle = math.atan2(-vy[i],vx[i]) + (math.pi / 2)
fx = 1 * math.cos(angle)
fy = -1 * math.sin(angle)
vxa = vx[i] + fx
vya = vy[i] + fy
factor = math.sqrt(vx[i]**2 + vy[i]**2) / math.sqrt(vxa**2 + vya**2)
vx[i] = vxa * factor
vy[i] = vya * factor
x[i] = x[i] + vx[i]
y[i] = y[i] + vy[i]
color("black")
spot(x[i],y[i],2)
示例7: DrawClear
def DrawClear(x,y):
color("white")
box(x*34+182,y*34+202,32,32)
color("Black")
if check(x,y) > 0:
text(x*34+192,y*34+207,check(x,y))
flags[x][y] = 3
示例8: handle_frame
def handle_frame():
global x,y,vx,vy,ax,ay
color("white")
spot(x,y,8)
vx = vx + ax
vy = vy + ay
x2 = x + vx
y2 = y + vy
if x2 < 0:
x=-x2
vx=-vx
elif x2 > screen_width:
x=screen_width*2-x2
vx=-vx
else:
x=x2
if y2 < 0:
y=-y2
vy=-vy
elif y2 > screen_height:
y=screen_height*2-y2
vy=-vy
else:
y=y2
color("blue")
spot(x,y,8)
示例9: flag
def flag(i,j):
color("red")
tx = startx + size/2 + i * size
ty = starty + size/2 + j * size
spot(tx, ty, size/3)
color("black")
text(tx - size/10, ty - size/10, "F")
示例10: handle_frame
def handle_frame():
global x,y,vx,vy,ax,ay
color("white")
spot(x,y,8)
vx = (vx*0.95) + ax
vy = (vy*0.95) + ay + 0.1
x = x + vx
y = y + vy
color("blue")
if x<=0 or x>=900:
vx = -vx
ax = (-0.8*ax)
elif y<=0 or y>=1000:
vy = -vy
ay = (-0.8*ay)
spot(x,y,8)
示例11: handle_frame
def handle_frame():
global x,y,vx,vy
color("white")
spot(x,y,8)
rx = x - screen_width / 2
ry = y - screen_height / 2
magsq = rx**2 + ry**2
if magsq != 0:
# normalise
mag = sqrt(magsq)
rx /= mag
ry /= mag
# apply inverse square rule
rx *= g/magsq
ry *= g/magsq
vx -= rx / m
vy -= ry / m
x = x + vx
y = y + vy
color("blue")
drawship(x, y, 0)
示例12: draw_debug
def draw_debug(self, position = [30, 30], size = [200,200]):
for i in range(0, self.i_size):
for j in range(0, self.j_size):
#Set rgba value based on max value
#Convert to color string "rgba(...)
#Positive values are red, negative are blue
#Values close to zero will be paler
if self.array[i][j] >= 0 :
colour = "red"
else:
colour = "blue"
#Draw box
color(colour)
box(position[0] + j * size[0]/self.j_size,
position[1] + i * size[1]/self.i_size,
size[0]/self.j_size - 1,
size[1]/self.i_size - 1)
#Draw text
color("white")
text(position[0] + j * size[0]/self.j_size,
position[1] + i * size[1]/self.i_size,
str(i) + str(j) + " " + str(self.array[i][j]))
示例13: DrawGrid
def DrawGrid():
global OffsetX, OffsetY
OffsetX = 0
OffsetY = 0
color("#cccccc")
box(StartingX - 2,StartingY - 2,SquareSize * WLimit + 8,SquareSize * HLimit +8)
for x in range(0,HLimit):
for y in range(0,WLimit):
if VisibleArray[x][y]==0:
DrawCoveredSquare()
elif VisibleArray[x][y] == 1:
DrawUncoveredSquare()
if BombArray[x][y] > 0:
BombNumber = BombArray[x][y]
DrawNumber(x,y,BombNumber)
elif BombArray[x][y] == -1:
if x == lastx and y == lasty:
DrawMine(x,y, "red")
else:
DrawMine(x,y, "black")
elif VisibleArray[x][y] == 2:
DrawFlag(x,y)
OffsetY += SquareSize
OffsetX += SquareSize
OffsetY = 0
示例14: draw_points
def draw_points(self,points):
global hue
color("hsl(%d,100%%,40%%)" % hue)
hue = hue + 1
line(points[0],points[1],points[2],points[3])
line(points[2],points[3],points[4],points[5])
line(points[4],points[5],points[0],points[1])
示例15: draw_static_things
def draw_static_things():
blue_top = [(0,0),
(0,screen_height/10),
(screen_width,screen_height/10),
(screen_width,0)]
color("blue")
fill_polygon(blue_top)