Ejemplo n.º 1
0
def handle_mousedown(x,y):
  global lastx, lasty
  
  if button == "right":
    line(lastx, lasty, x, y)
    lastx = x
    lasty = y 
Ejemplo n.º 2
0
def handle_mousemove(x, y, button):
    global lastx, lasty

    if button == "left":
        line(lastx, lasty, x, y)
        lastx = x
        lasty = y
Ejemplo n.º 3
0
def handle_mousemove(x,y,button):
  global lastx, lasty
  
  if button == "left":
    line(lastx, lasty, x, y)
    lastx = x
    lasty = y
def handle_message(message):
    if message["type"] == "reset":
        initialPlayer2()

    if message["type"] == "line":
        color(message["color"])
        line(message["x1"], message["y1"], message["x2"], message["y2"])
def handle_message(message):
  if message["type"] == "reset":
    initialPlayer2()
  
  if message["type"] == "line":    
    color(message["color"])
    line(message["x1"], message["y1"], message["x2"], message["y2"])
Ejemplo n.º 6
0
def linethree(x1,y1,z1,x2,y2,z2):

  a1=x1*math.cos(phi)-y1*math.sin(phi)
  b1=x1*math.sin(phi)+y1*math.cos(phi)
  
  c1=b1*math.cos(theta)-z1*math.sin(theta)
  d1=b1*math.sin(theta)+z1*math.cos(theta)
  
  e1=screen_width/2+a1*math.cos(alpha)-c1*math.sin(alpha)
  f1=screen_height/2+a1*math.sin(alpha)+c1*math.cos(alpha)
  
  
  a2=x2*math.cos(phi)-y2*math.sin(phi)
  b2=x2*math.sin(phi)+y2*math.cos(phi)
  
  c2=b2*math.cos(theta)-z2*math.sin(theta)
  d2=b2*math.sin(theta)+z2*math.cos(theta)
  
  e2=screen_width/2+a2*math.cos(alpha)-c2*math.sin(alpha)
  f2=screen_height/2+a2*math.sin(alpha)+c2*math.cos(alpha)
  
#  a1=screen_width/2+x1*math.sqrt(3)/2-y1/2
#  b1=screen_height/2+x1/2+y1*math.sqrt(3)/2-z1
#  a2=screen_width/2+x2*math.sqrt(3)/2-y2/2
#  b2=screen_height/2+x2/2+y2*math.sqrt(3)/2-z2
  line(e1,f1,e2,f2)
Ejemplo n.º 7
0
def handle_mousemove(x, y, button):
   global xpos, ypos
    
   if button == "left":
    line(xpos, ypos, x, y)
    send({"xpos":xpos, "ypos":ypos, "x":x,"y":y})
    xpos = x
    ypos = y
def handle_mousemove(x,y,button):
  global lastx, lasty
  
  if button == "left":
    line(lastx, lasty, x, y)
    send({"x1": lastx, "y1": lasty, "x2": x, "y2": y})
    lastx = x
    lasty = y
Ejemplo n.º 9
0
def handle_mousemove(x, y, button):
    global lastx, lasty

    if button == "left":
        line(lastx, lasty, x, y)
        send({"x1": lastx, "y1": lasty, "x2": x, "y2": y})
        lastx = x
        lasty = y
Ejemplo n.º 10
0
def handle_mousemove(x, y, button):
    global xpos, ypos

    if button == "left":
        line(xpos, ypos, x, y)
        send({"xpos": xpos, "ypos": ypos, "x": x, "y": y})
        xpos = x
        ypos = y
Ejemplo n.º 11
0
def handle_mousemove(x,y,button):
  global lastx, lasty, hue
  
  if button == "left":
    line(lastx, lasty, x, y)
    lastx = x
    lasty = y
    color("hsl(%d,100%%,50%%)" % hue)
    hue += 1
Ejemplo n.º 12
0
def parallel(x1,y1,x2,y2,x3,y3):
  x1=int(x1)
  y1=int(y1)
  x2=int(x2)
  y2=int(y2)
  x3=int(x3)
  y3=int(y3)
  for i in range(x1,x2):
    line(i,(y2-y1)*(i-x1)/(x2-x1)+y1,x3-x1+i,(y2-y1)*(i-x1)/(x2-x1)+y3)
Ejemplo n.º 13
0
def handle_mousemove(x, y):
    global lastx, lasty, hue

    line(lastx or x, lasty or y, x, y)
    color("hsl(%d,100%%,50%%)" % hue)

    hue += 1

    lastx = x
    lasty = y
Ejemplo n.º 14
0
def handle_message(message):
    global stopCount
    if message["type"] == "stop":
        reset()
        stopCount = "true"
        finishButtons()

    if message["type"] == "line":
        color(message["color"])
        line(message["x1"], message["y1"], message["x2"], message["y2"])
Ejemplo n.º 15
0
def handle_mousemove(x,y):
  global lastx, lasty, hue
  
  line(lastx or x, lasty or y, x, y)
  color("hsl(%d,100%%,50%%)" % hue)
  
  hue += 1
  
  lastx = x
  lasty = y
Ejemplo n.º 16
0
def star(x, y, c, w, h, spines):

    color(c)

    angle = 0

    for i in range(0, spines):
        x0 = x + (w * cos(angle))
        y0 = y + (h * sin(angle))
        line(x, y, x0, y0)
        angle = angle + (2 * pi / spines)
Ejemplo n.º 17
0
def star(x, y, c, w, h, spines):
  
  color(c)
  
  angle = 0
  
  for i in range(0, spines):
    x0 = x + (w * cos(angle))
    y0 = y + (h * sin(angle))
    line(x, y, x0, y0)
    angle = angle + (2 * pi / spines)
Ejemplo n.º 18
0
def handle_mousemove(x,y,button):
  global lastx, lasty
  
  if button == "left":
    line(lastx, lasty, x, y)
    lastx = x
    lasty = y
  elif button == "right":
    color("red")
    line(lastx, lasty, x, y)
    lastx = x
    lasty = y
Ejemplo n.º 19
0
 def star(self, x, y, c, size, spines):
   color(c)
   
   angle = 0
   
   for i in range(0, spines):
     x0 = x + (size * cos(angle))
     y0 = y + (size * sin(angle))
     
     line(x, y, x0, y0)
     
     angle = angle + (2 * pi / spines)
Ejemplo n.º 20
0
def handle_mousemove(x, y, button):
    global lastx, lasty

    if button == "left":
        line(lastx, lasty, x, y)
        lastx = x
        lasty = y
    elif button == "right":
        color("red")
        line(lastx, lasty, x, y)
        lastx = x
        lasty = y
Ejemplo n.º 21
0
def elipses(x, y, c, size, size2):
  
  color(c)
  
  angle = 0
  
  for i in range(0,size2):
    x0 = x + (size * cos(angle))
    y0 = y + (size * sin(angle))
    
    line(x, y, x0, y0)
    
    angle = angle + (2 * pi / size2)
Ejemplo n.º 22
0
def ellipse(x, y, c, height, width):
  
  color(c)
  
  angle = 90
  
  for i in range(0, width):
    x0 = x + (height * cos(angle) * 2)
    y0 = y + (height * sin(angle))
    
    line(x, y, x0, y0)
    
    angle = angle + (2 * pi / width)
Ejemplo n.º 23
0
def elipses(x, y, c, size, size2):

    color(c)

    angle = 0

    for i in range(0, size2):
        x0 = x + (size * cos(angle))
        y0 = y + (size * sin(angle))

        line(x, y, x0, y0)

        angle = angle + (2 * pi / size2)
Ejemplo n.º 24
0
def handle_mousemove(x,y,button):
  global lastx, lasty
  
  if button == "left":
    color("red")
  elif button == "right":
    color("blue")
  else:
    return
  
  line(lastx, lasty, x, y)
  lastx = x
  lasty = y
Ejemplo n.º 25
0
def handle_mousemove(x,y,button):
  global lastx, lasty
  
  if button == "left":
    color("blue")
    line(lastx, lasty, x, y)
    lastx = x
    lasty = y
  if button == "right":
    color("black")
    line(lastx, lasty, x, y)
    lastx = x
    lasty = y
Ejemplo n.º 26
0
def handle_mousemove(x,y,button):
  global lastx, lasty
  
  if button == "left":
    color("blue")
    line(lastx, lasty, x, y)
    lastx = x
    lasty = y
  elif button== 'right':
    color("yellow")
    line(lastx, lasty, x, y)
    lastx = x
    lasty = y
Ejemplo n.º 27
0
def star(x, y, c, vertical, horizontal, spines):
  
  color(c)
  
  angle = 0
  
  for i in range(0, spines):
    x0 = x + (horizontal * cos(angle))
    y0 = y + (vertical * sin(angle))
    
    line(x, y, x0, y0)
    
    angle = angle + (2 * pi / spines)
Ejemplo n.º 28
0
def ellipse(x, y, c, sizex, sizey, spines):
  
  color(c)
  
  angle = 0
  
  for i in range(0, spines):
    x0 = x + (sizex * cos(angle))
    y0 = y + (sizey * sin(angle))
    
    line(x, y, x0, y0)
    
    angle = angle + 1
Ejemplo n.º 29
0
def handle_mousemove(x, y, button):
    global lastx, lasty

    if button == "left":
        color("red")
    elif button == "right":
        color("blue")
    else:
        return

    line(lastx, lasty, x, y)
    lastx = x
    lasty = y
Ejemplo n.º 30
0
def star(x, y, c, rx, ry, spines):
  
  color(c)
  
  angle = 0
  
  for i in range(0, spines):
    x0 = x + (rx * cos(angle))
    y0 = y + (ry * sin(angle))
    
    line(x, y, x0, y0)
    
    angle = angle + (2 * pi / spines)
Ejemplo n.º 31
0
def handle_mousemove(x, y, button):
    global lastx, lasty

    if button == "left":
        color("blue")
        line(lastx, lasty, x, y)
        lastx = x
        lasty = y

    if button == "right":
        color("purple")
        line(lastx, lasty, x, y)
        lastx = x
        lasty = y
Ejemplo n.º 32
0
def star(x, y, c, size, spines, xstretch, ystretch):
  
  color(c)
  
  angle = 0
  
  for i in range(0, spines):
    
    x0 = x + (size * cos(angle) * xstretch)
    y0 = y + (size * sin(angle) * ystretch)
    
    line(x, y, x0, y0)
    
    angle = angle + (2 * pi / spines)
Ejemplo n.º 33
0
def handle_mousemove(x, y, button):
    global lastx, lasty
    if button == "left":
        color(chosen_color)
        line(lastx, lasty, x, y)
        send({
            "type": "line",
            "x1": lastx,
            "y1": lasty,
            "x2": x,
            "y2": y,
            "color": chosen_color
        })
        lastx = x
        lasty = y
Ejemplo n.º 34
0
def star(x, y, c, Xsize, Ysize, spines):
  
  color(c)
  
  angle = 0
  
  for i in range(0, spines):
    x0 = x + (Xsize * cos(angle))
    y0 = y + (Ysize * sin(angle))
    
    line(x, y, x0, y0)
    
    angle = angle + (2 * pi / spines)
    x = x0
    y = y0
Ejemplo n.º 35
0
def star(x, y, c, size, spines, height, width):
  
  color(c)
  
  angle = 0
  
  for i in range(0, spines):
    x0 = x + ((size*width) * cos(angle))
    y0 = y + ((size*height) * sin(angle))
   
    x1 = x + ((size*width) * cos(angle + (2 * pi/spines)))
    y1 = y + ((size*height) * sin(angle + (2 * pi/spines)))
    
    line(x0, y0, x1, y1)
    
    angle = angle + (2 * pi/spines)
Ejemplo n.º 36
0
def star(x, y, c, x_rad, y_rad, spines):
  
  color(c)
  
  angle = 30
  
  for i in range(0, spines):
    x0 = x + (x_rad * cos(angle))
    y0 = y + (y_rad * sin(angle))
    x1 = x + (x_rad * cos(angle + (2* pi / spines))) 
    y1 = y + (y_rad * sin(angle + (2* pi / spines))) 
    
    
    line(x1, y1, x0, y0)
    
    angle = angle + (2* pi / spines)
Ejemplo n.º 37
0
def drawship(x, y, angle):
    tri = [(0, 10), (5, -5), (-5, -5)]

    c = cos(angle)
    s = sin(angle)
    for i in range(0, 3):
        x = tri[i][0]
        y = tri[i][1]
        tri[i] = (x * c - y * s, x * s + y * c)

    for i in range(0, 3):
        x0 = tri[i][0]
        y0 = tri[i][1]
        x1 = tri[(i + 1) % 3][0]
        y1 = tri[(i + 1) % 3][1]
        print(x + x0, y + y0, x + x1, y + y1)
        line(x + x0, y + y0, x + x1, y + y1)
Ejemplo n.º 38
0
def drawship(x, y, angle):
  tri = [(0, 10), (5, -5), (-5, -5)]
  
  c = cos(angle)
  s = sin(angle)
  for i in range(0, 3):
    x = tri[i][0]
    y = tri[i][1]
    tri[i] = (x*c - y*s, x*s + y*c)
  
  for i in range(0, 3):
    x0 = tri[i][0]
    y0 = tri[i][1]
    x1 = tri[(i+1)%3][0]
    y1 = tri[(i+1)%3][1]
    print(x + x0, y + y0, x + x1, y + y1)
    line(x + x0, y + y0, x + x1, y + y1)
Ejemplo n.º 39
0
def draw(Num_1,Num_2):
  if Winner == 3:
   image(850,50,"http://i.imgur.com/0zoXV5h.png")
   color("White")
   box(840,120,500,200)
   color("Black")
   text(850,125, "Player 1: %d" % Num_1)
   text(1050,125, "Player 2: %d" % Num_2)
   image(850,155,"animals/Diplodocus.png")
   image(1050,180,"animals/Stegosaurus.png")
  
   x = 25
   y = 25

   color("green")
   box(25,25,800,800)

   color("black")
   for i in range(0,9):
    line(x,y,x,(y+800))
    x += 100
   x = 25

   for j in range(0,9):
    line(x,y,(x+800),y)
    y += 100
  
   for a in range(0,8):
    for b in range(0,8):
      if Grid[a][b] == 1:
        y1 = a
        x1 = b
        y1 *= 100
        y1 += 30
        x1 *= 100
        x1 += 30
        image(x1,y1,"animals/Diplodocus.png")
      elif Grid[a][b] == 2:
       y1 = a
       x1 = b
       y1 *= 100
       y1 += 55
       x1 *= 100
       x1 += 35
       image(x1,y1,"animals/Stegosaurus.png")
Ejemplo n.º 40
0
def draw(Num_1,Num_2):
  if Winner == 3:
   image(450,50,"http://i.imgur.com/0zoXV5h.png")
   text(450,150, "Player 1: (%d)" % Num_1)
   text(450,250, "Player 2: (%d)" % Num_2)
  
   x = 25
   y = 25

   color("green")
   box(25,25,400,400)

   color("black")
   for i in range(0,9):
    line(x,y,x,(y+400))
    x += 50
   x = 25

   for j in range(0,9):
    line(x,y,(x+400),y)
    y += 50
  
   for a in range(0,8):
    for b in range(0,8):
      if Grid[a][b] == 1:
        y1 = a
        x1 = b
        y1 *= 125
        y1 += 15
        y1 /= 2.0
        x1 *= 125
        x1 += 15
        x1 /= 2.0
        image(x1,y1,"http://i.imgur.com/Ef7rj15.png")
      elif Grid[a][b] == 2:
       y1 = a
       x1 = b
       y1 *= 125
       y1 += 15
       y1 /= 2.0
       x1 *= 125
       x1 += 5
       x1 /= 2
       image(x1,y1,"http://i.imgur.com/mTw75jg.png")
Ejemplo n.º 41
0
def handle_mousemove(x,y):
  global lastx, lasty, hue
  
  line(lastx or x, lasty or y, x, y)
  circle(lastx or x, lasty or y, x)
  
  #color("hsl(%d,100%%,50%%)" % hue)
  color("rgba(400,9,0,0.7)" % hue)
  
  box(lastx or x, lasty or y, x, y)
  
  #spot(lastx or x, lasty or y, x)
  #color("hsl(%d,100%%,50%%)" % hue)
  
  hue += 1
 
  
  lastx = x
  lasty = y
Ejemplo n.º 42
0
 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])
Ejemplo n.º 43
0
def drawToolbar():
  tools = ["line","bold","circle","bird","stars","italics","triangle","hearts","eraser"]

  text (screen_width - 300, 10, "Toolbar:")
  rectangle(screen_width - 300,35,25,25)
  line(screen_width - 286, 40, screen_width - 286, 52)
  rectangle(screen_width - 275,35,25,25)
  box (screen_width - 264, 37, 5, 20)
  rectangle(screen_width - 250,35,25,25)
  spot (screen_width - 238, 47, 8)
  rectangle(screen_width - 225,35,25,25)
  text(screen_width - 219, 38, "B")
  rectangle(screen_width - 200,35,25,25)
  text(screen_width - 193, 38, "*")
  rectangle(screen_width - 175,35,25,25)
  text(screen_width - 165, 38, "/")
  rectangle(screen_width - 150,35,25,25)
  text(screen_width - 145, 38, "T")
  rectangle(screen_width - 125,35,25,25) 
  text(screen_width - 120, 38, "H")
  rectangle(screen_width - 100,35,25,25) 
  text(screen_width - 95, 38, "X")
Ejemplo n.º 44
0
def drawBezier(points,n,drawControl):
  if drawControl:
    color("red")
    lastDrawn = points[0]
    
    for i in xrange(0,len(points)):
      line(lastDrawn[0],lastDrawn[1],points[i][0],points[i][1])
      lastDrawn = points[i]
    
  color("black")
  lastDrawn = points[0]
  
  for i in xrange(1,int(n+1)):
    k = i*(100.0/n)
    tempPoints = list(points)
    
    while len(tempPoints) > 1:
      for j in xrange(0,len(tempPoints)-1):
        tempPoints[j] = partWayBetween(tempPoints[j],tempPoints[j+1],k)
      
      tempPoints.pop()
   
    line(lastDrawn[0],lastDrawn[1],tempPoints[0][0],tempPoints[0][1])
    lastDrawn = tempPoints[0]
Ejemplo n.º 45
0
def fill(colour):
    color(colour)
    for x in range(screen_width):
        line(x, 0, x, screen_height)
        send({"x1": x, "y1": 0, "x2": x, "y2": screen_height})
Ejemplo n.º 46
0
def handle_message(message):
    line(message["xpos"], message["ypos"], message["x"], message["y"])
Ejemplo n.º 47
0
def handle_message(message):
    line(message["x1"], message["y1"], message["x2"], message["y2"])
Ejemplo n.º 48
0
from tealight.art import (color, line, spot, circle, box, image, text,
                          background)

from tealight.art import (screen_width, screen_height)

print "This is art mode!"

print screen_width
print screen_height

background("paper.jpg")

line(0, 0, screen_width, screen_height)

spot(200, 300, 20)

circle(300, 200, 20)

box(500, 500, 60, 60)

image(200, 200, "bird.png")

line(560, 0, 560, 495)

text(600, 100, "Hello Tealight!")

lastx = None
lasty = None
hue = 0

Ejemplo n.º 49
0
for Ycounter in range(0,16):
  for Xcounter in range(0,16):
    color("grey")
    box(x,y,32,32)
    x = x + 34
  y = y + 34
  x = 182

color("black")
spot(231,354,10)

color("white")
spot(227,349,2)

color("black")
line(231,342,231,339)

color("black")
line(231,366,231,369)

color("black")
line(242,354,245,354)

color("black")
line(220,354,217,354)


color("black")
spot(222,345,1)

color("black")