示例#1
0
 def run(self):
     global canvas, layer, shape, shape_choosen, shape_length, shape_orientation
     print("Rotate")
     print shape_choosen
     print shape_length
     print shape_orientation
     if shape.id == 0:
         # Rotating a dot does nothing
         pass
     elif shape.id == 1:
         # Line - default orientation = 0 (horizontal)
         # 0 _    1 /    2 |     3 \
         # rotation scheme:
         #   0 -> 1 -> 2 -> 3 -> 0 -> ...
         if shape.orientation == 0:
             shape.pix = shapes.line_d(shape.length, 1)
             shape_orientation = 1
             shape.orientation = 1
         elif shape.orientation == 1:
             shape.pix = shapes.line_v(shape.length)
             shape_orientation = 2
             shape.orientation = 2
         elif shape.orientation == 2:
             shape.pix = shapes.line_d(shape.length, 0)
             shape_orientation = 3
             shape.orientation = 3
         else:
             shape.pix = shapes.line_h(shape.length)
             shape_orientation = 0
             shape.orientation = 0
     elif shape.id == 2:
         # Square - default orientation = 0 (horizontal & vertical sides)
         # 0 |_|     1 v (diamond)
         if shape.orientation == 0:
             shape.pix = shapes.square_d(shape.length, shape.fill)
             shape_orientation = 1
             shape.orientation = 1
         else:
             shape.pix = shapes.square(shape.length, shape.fill)
             shape_orientation = 0
             shape.orientation = 0
     else:
         print "something went terribly wrong"
示例#2
0
def select_shape():
    #    shape_choosen = -1
    user_input = raw_input("Select shape: dot [d] | line [l] | square [s] ")
    if user_input == 'QUIT':
        state = 9
    elif int(user_input) == 0:
        print("You choose [dot]")
        shape_choosen = int(user_input)
        shape.pix = 1
        state = 3
    elif int(user_input) == 1:
        print("You choose [line]")
        shape_choosen = int(user_input)
        shape.pix = shapes.line_h(shape_length)
        state = 3
    elif int(user_input) == 2:
        print("You choose [square]")
        shape_choosen = int(user_input)
        shape.pix = shapes.rect(shape_length,shape_length,0)
        state = 3
    else:
        print("Shape not found")
示例#3
0
 def next(self,input):
     global canvas, layer, shape, shape_choosen, shape_length, shape_orientation
     user_input = raw_input("Select shape: dot [0] | line [1] | square [2] | Clear Canvas [9]")
     if user_input == 'QUIT':
         return DrawingApp.end_program
     elif int(user_input) == 0:
         print("You choose [dot]")
         shape_choosen = int(user_input)
         shape_orientation = 0
         shape.id = 0
         shape.orientation = 0
         shape.length = 1
         shape.pix[2][2] = 1
         return DrawingApp.create
     elif int(user_input) == 1:
         print("You choose [line]")
         shape_choosen = int(user_input)
         shape_orientation = 0
         shape.id = 1
         shape.orientation = 0
         shape.length = 5
         shape.pix = shapes.line_h(shape_length)
         return DrawingApp.create
     elif int(user_input) == 2:
         print("You choose [square]")
         shape_choosen = int(user_input)
         shape_orientation = 0
         shape.id = 2
         shape.orientation = 0
         shape.length = 5
         shape.fill = 0
         shape.pix = shapes.rect(shape_length, shape_length, 0)
         return DrawingApp.create
     elif int(user_input) == 9:
         print "Clearing Canvas..."
         return DrawingApp.clear_canvas
     else:
         print("Shape not found")
         return DrawingApp.select
 def next(self,input):
     user_input = raw_input("Select shape: dot [0] | line [1] | square [2] ")
     if user_input == 'QUIT':
         return DrawingApp.end_program
     elif int(user_input) == 0:
         print("You choose [dot]")
         shape_choosen = int(user_input)
         # shape.pix = 1
         shape.pix[2][2] = 1
         return DrawingApp.create
     elif int(user_input) == 1:
         print("You choose [line]")
         shape_choosen = int(user_input)
         shape.pix = shapes.line_h(shape_length)
         return DrawingApp.create
     elif int(user_input) == 2:
         print("You choose [square]")
         shape_choosen = int(user_input)
         shape.pix = shapes.rect(shape_length, shape_length, 0)
         return DrawingApp.create
     else:
         print("Shape not found")
         return DrawingApp.select
示例#5
0
 def next(self, input):
     global canvas, layer, shape, shape_choosen, shape_length, shape_orientation, secret_mode
     user_input = raw_input(
         "Select shape: dot [0] | line [1] | square [2] | Clear Canvas [9]")
     if user_input == 'QUIT':
         return DrawingApp.end_program
     elif user_input == 'rainbow':
         if secret_mode:
             secret_mode = 0
         else:
             secret_mode = 1
         return DrawingApp.select
     elif int(user_input) == 0:
         print("You choose [dot]")
         shape_choosen = int(user_input)
         shape_orientation = 0
         shape.id = 0
         shape.orientation = 0
         shape.length = 1
         shape.pix[2][2] = 1
         return DrawingApp.create
     elif int(user_input) == 1:
         print("You choose [line]")
         shape_choosen = int(user_input)
         user_input = raw_input("Size: small[s] | medium[m] | large[l]")
         shape_orientation = 0
         shape.id = 1
         shape.orientation = 0
         if user_input == 's':
             shape.length = 5
         elif user_input == 'm':
             shape.length = 9
         elif user_input == 'l':
             shape.length = 16
     #  shape.pix = shapes.line_h(shape_length)
         shape.pix = shapes.line_h(shape.length)
         return DrawingApp.create
     elif int(user_input) == 2:
         print("You choose [square]")
         shape_choosen = int(user_input)
         user_input = raw_input("Size: small[s] | medium[m] | large[l]")
         shape_orientation = 0
         shape.id = 2
         shape.orientation = 0
         if user_input == 's':
             shape.length = 5
         elif user_input == 'm':
             shape.length = 9
         elif user_input == 'l':
             shape.length = 16
         user_input = raw_input("Fill: yes [f] | no [any]")
         if user_input == 'f':
             shape.fill = 1
         else:
             shape.fill = 0
     #    shape.pix = shapes.rect(shape_length, shape_length, 0)
         shape.pix = shapes.rect(shape.length, shape.length, shape.fill)
         return DrawingApp.create
     elif int(user_input) == 9:
         print "Clearing Canvas..."
         return DrawingApp.clear_canvas
     else:
         print("Shape not found")
         return DrawingApp.select