Ejemplo n.º 1
0
 def _createBackground(self):
     frame = GRect(0, 0, self._frameWidth, self._frameHeight)
     frame.setFilled(True)
     frame.setColor(FRAME_COLOR)
     self.add(frame)
     x1 = self._frameWidth / 2
     x0 = x1 - PIECE_WIDTH - COLUMN_SEP
     x2 = x1 + PIECE_WIDTH + COLUMN_SEP
     y0 = TOP_MARGIN + PIECE_HEIGHT / 2
     y1 = self._frameHeight - BOTTOM_MARGIN - PIECE_HEIGHT / 2
     h = CHANNEL_WIDTH / 2
     poly = GPolygon()
     poly.addVertex(x0 - h, y1 + h)
     poly.addVertex(x0 - h, y0 - h)
     poly.addVertex(x2 + h, y0 - h)
     poly.addVertex(x2 + h, y1 + h)
     poly.addVertex(x2 - h, y1 + h)
     poly.addVertex(x2 - h, y0 + h)
     poly.addVertex(x1 + h, y0 + h)
     poly.addVertex(x1 + h, y1 + h)
     poly.addVertex(x1 - h, y1 + h)
     poly.addVertex(x1 - h, y0 + h)
     poly.addVertex(x0 + h, y0 + h)
     poly.addVertex(x0 + h, y1 + h)
     poly.addVertex(x0 - h, y1 + h)
     poly.setFilled(True)
     poly.setColor(CHANNEL_COLOR)
     self.add(poly)
Ejemplo n.º 2
0
def drawDiamond(height,theta,color,diamondAngle):  #draws diamond of given height and color, with its' right edge on line with angle theta
    l=((.5*height)*cos((radians(.5*diamondAngle))))
    diamond=GPolygon()
    t=theta+diamondAngle
    diamond.addVertex(0,0)
    diamond.addPolarEdge(l,t)
    t=t-diamondAngle
    diamond.addPolarEdge(l,t)
    t=t-(180-diamondAngle)
    diamond.addPolarEdge(l,t)
    diamond.setFillColor(color)
    diamond.setFilled(True)
    return diamond 
Ejemplo n.º 3
0
 def __init__(self, color, level, puzzle):
     """Creates a piece with the indicated color and initial level"""
     GCompound.__init__(self)
     self._level = level
     self._puzzle = puzzle
     self.setColor(color)
     frame = GRect(PIECE_WIDTH, PIECE_HEIGHT)
     frame.setFilled(True)
     frame.setColor(PIECE_COLOR)
     self.add(frame, -PIECE_WIDTH / 2, 0)
     poly = GPolygon()
     dw = PIECE_WIDTH / puzzle.getNLevels()
     w0 = (level - 1) * dw
     w1 = level * dw
     poly.addVertex(-w0 / 2, 0)
     poly.addVertex(w0 / 2, 0)
     poly.addVertex(w1 / 2, PIECE_HEIGHT)
     poly.addVertex(-w1 / 2, PIECE_HEIGHT)
     poly.setFilled(True)
     poly.setColor(color)
     self.add(poly)
     border = GRect(PIECE_WIDTH, PIECE_HEIGHT)
     border.setColor(BORDER_COLOR)
     self.add(border, -PIECE_WIDTH / 2, 0)