示例#1
0
 def buildRayBurst(self, rays, radius, rayIsCentered):
     rayGroup = inkex.etree.Element('g', id='rays')
     whiteRays = inkex.etree.Element('g', id='whiterays')
     blackRays = inkex.etree.Element('g', id='blackrays')
    
     rayGroup.append(whiteRays)
     rayGroup.append(blackRays)
     
     rayStyle = None
     vertices = geom.createRadialPlots(geom.Point(0,0), radius, rays*2, rayIsCentered)
     for i in range(rays*2):
         rayPath = path.PathData("").moveTo(geom.Point(0,0)).lineTo(vertices[i]).lineTo(vertices[(i+1)%(rays*2)])
         if i%2 == 1:
             whiteRays.append(element.buildPath(rayPath, {'style':' stroke:none; fill:white' }))
         else:
             blackRays.append(element.buildPath(rayPath, {'style':' stroke:none; fill:black' }))
     return rayGroup
示例#2
0
 def polygonGradientIris(self, position,sides, radius,  startColor, endColor, divisionOfPieRotation,  sideTurnings, reverse=0, passiveopt=0):
     
     gradientIrisGroup = inkex.etree.Element("g")
     #calculate creepRatio from rotationAngle,
     #where rotationAngle is the angle each polygon is rotated
     #and creepRatio is the percentage of the polygon side to move from one corner to the other
     rotations = divisionOfPieRotation*sideTurnings/2
     colorGradation = color.tupleGradient(color.hexToRGB(startColor), color.hexToRGB(endColor),rotations )
     
     pieCornerAngle = 1.0/sides*math.pi*2
     rotationAngle = 1.0/divisionOfPieRotation*pieCornerAngle
     
     polygonCornerAngle =  (sides-2)*math.pi/(2*sides)
     adjacentAngle = math.pi - rotationAngle - polygonCornerAngle
     
     adjacentSide = math.sin(rotationAngle)/math.sin(adjacentAngle)*radius
     innerSide = math.sin(rotationAngle)*radius/math.sin(adjacentAngle)
     outerSegmentLength = math.sin(pieCornerAngle)*radius/math.sin(polygonCornerAngle)
     creepRatio = innerSide/outerSegmentLength
     if reverse : creepRatio = 1 - creepRatio
     
     
     linePoints = geom.createRadialPlots(position, radius, sides, passive=passiveopt )
     
     for i in range(rotations+1):
         polygonAttributes = {u'style':u'stroke:black;stroke-width:1;fill:' + unicode(colorGradation[i])}
         trianglePath = path.PathData().moveTo(linePoints[0])
         for j in range(1,sides):
             trianglePath.lineTo(linePoints[j])
         trianglePath.closePath()
         gradientIrisGroup.append(element.buildPath( trianglePath, polygonAttributes))
         newLinePoints = []
         for j in range(sides):
             newLinePoints.append(geom.getLineDivision(linePoints[j], linePoints[(j+1)%sides], creepRatio))
         linePoints = newLinePoints
     return gradientIrisGroup