def createHexagon(side):

    hex = GPolygon()
    hex.addVertex(-side, 0)
    angle = 60
    for i in range(6):
        hex.addPolarEdge(side, angle)
        angle -= 60
    return hex
Пример #2
0
def createHexagon(side):
    """
    Creates a GCompound representing a regular hexagon with the specified
    side length.  The reference point is the center.
    """
    hex = GPolygon()
    hex.addVertex(-side, 0)
    angle = 60
    for i in range(6):
        hex.addPolarEdge(side, angle)
        angle -= 60
    return hex
Пример #3
0
def drawTriangle(edge, dx, dy, whole):

    tri = GPolygon()
    x = -edge / 2
    y = edge / (2 * math.sqrt(3))
    print(x, y)
    tri.addVertex(x, y)
    tri.addPolarEdge(edge, 0)
    tri.addPolarEdge(edge, 120)
    tri.addPolarEdge(edge, -120)
    whole.add(tri, dx - edge / 2, dy - edge * (math.sqrt(3) / 2))
Пример #4
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 
Пример #5
0
def drawTriangle(size):
    t = GPolygon()
    t.addVertex(0, -(size / (2 * sqrt(3))))
    t.addPolarEdge(size, 300)
    t.addPolarEdge(size, 180)
    return t