コード例 #1
0
ファイル: svg_reader.py プロジェクト: CNCBASHER/skeinforge-1
def processSVGElementellipse(svgReader, xmlElement):
    "Process xmlElement by svgReader."
    attributeDictionary = xmlElement.attributeDictionary
    center = euclidean.getComplexDefaultByDictionaryKeys(
        complex(), attributeDictionary, 'cx', 'cy')
    radius = euclidean.getComplexDefaultByDictionaryKeys(
        complex(), attributeDictionary, 'rx', 'ry')
    if radius.real == 0.0 or radius.imag == 0.0:
        print(
            'Warning, in processSVGElementellipse in svgReader radius is zero in:'
        )
        print(attributeDictionary)
        return
    global globalNumberOfCirclePoints
    global globalSideAngle
    loop = []
    rotatedLoopLayer = svgReader.getRotatedLoopLayer()
    for side in xrange(globalNumberOfCirclePoints):
        unitPolar = euclidean.getWiddershinsUnitPolar(
            float(side) * globalSideAngle)
        loop.append(center +
                    complex(unitPolar.real * radius.real, unitPolar.imag *
                            radius.imag))
    rotatedLoopLayer.loops += getTransformedFillOutline(
        loop, xmlElement, svgReader.yAxisPointingUpward)
コード例 #2
0
ファイル: svg_reader.py プロジェクト: CNCBASHER/skeinforge-1
def processSVGElementline(svgReader, xmlElement):
    "Process xmlElement by svgReader."
    begin = euclidean.getComplexDefaultByDictionaryKeys(
        complex(), xmlElement.attributeDictionary, 'x1', 'y1')
    end = euclidean.getComplexDefaultByDictionaryKeys(
        complex(), xmlElement.attributeDictionary, 'x2', 'y2')
    rotatedLoopLayer = svgReader.getRotatedLoopLayer()
    rotatedLoopLayer.loops += getTransformedOutlineByPath(
        [begin, end], xmlElement, svgReader.yAxisPointingUpward)
コード例 #3
0
def processSVGElementline(elementNode, svgReader):
    "Process elementNode by svgReader."
    begin = euclidean.getComplexDefaultByDictionaryKeys(
        complex(), elementNode.attributes, 'x1', 'y1')
    end = euclidean.getComplexDefaultByDictionaryKeys(complex(),
                                                      elementNode.attributes,
                                                      'x2', 'y2')
    loopLayer = svgReader.getLoopLayer()
    loopLayer.loops += getTransformedOutlineByPath(
        elementNode, [begin, end], svgReader.yAxisPointingUpward)
コード例 #4
0
def processSVGElementrect( svgReader, xmlElement ):
	"Process xmlElement by svgReader."
	attributeDictionary = xmlElement.attributeDictionary
	height = euclidean.getFloatDefaultByDictionary( 0.0, attributeDictionary, 'height')
	if height == 0.0:
		print('Warning, in processSVGElementrect in svgReader height is zero in:')
		print(attributeDictionary)
		return
	width = euclidean.getFloatDefaultByDictionary( 0.0, attributeDictionary, 'width')
	if width == 0.0:
		print('Warning, in processSVGElementrect in svgReader width is zero in:')
		print(attributeDictionary)
		return
	center = euclidean.getComplexDefaultByDictionaryKeys(complex(), attributeDictionary, 'x', 'y')
	inradius = 0.5 * complex( width, height )
	cornerRadius = euclidean.getComplexDefaultByDictionaryKeys( complex(), attributeDictionary, 'rx', 'ry')
	rotatedLoopLayer = svgReader.getRotatedLoopLayer()
	if cornerRadius.real == 0.0 and cornerRadius.imag == 0.0:
		inradiusMinusX = complex( - inradius.real, inradius.imag )
		loop = [center + inradius, center + inradiusMinusX, center - inradius, center - inradiusMinusX]
		rotatedLoopLayer.loops += getTransformedFillOutline(loop, xmlElement, svgReader.yAxisPointingUpward)
		return
	if cornerRadius.real == 0.0:
		cornerRadius = complex( cornerRadius.imag, cornerRadius.imag )
	elif cornerRadius.imag == 0.0:
		cornerRadius = complex( cornerRadius.real, cornerRadius.real )
	cornerRadius = complex( min( cornerRadius.real, inradius.real ), min( cornerRadius.imag, inradius.imag ) )
	ellipsePath = [ complex( cornerRadius.real, 0.0 ) ]
	inradiusMinusCorner = inradius - cornerRadius
	loop = []
	global globalNumberOfCornerPoints
	global globalSideAngle
	for side in xrange( 1, globalNumberOfCornerPoints ):
		unitPolar = euclidean.getWiddershinsUnitPolar( float(side) * globalSideAngle )
		ellipsePath.append( complex( unitPolar.real * cornerRadius.real, unitPolar.imag * cornerRadius.imag ) )
	ellipsePath.append( complex( 0.0, cornerRadius.imag ) )
	cornerPoints = []
	for point in ellipsePath:
		cornerPoints.append( point + inradiusMinusCorner )
	cornerPointsReversed = cornerPoints[: : -1]
	for cornerPoint in cornerPoints:
		loop.append( center + cornerPoint )
	for cornerPoint in cornerPointsReversed:
		loop.append( center + complex( - cornerPoint.real, cornerPoint.imag ) )
	for cornerPoint in cornerPoints:
		loop.append( center - cornerPoint )
	for cornerPoint in cornerPointsReversed:
		loop.append( center + complex( cornerPoint.real, - cornerPoint.imag ) )
	loop = euclidean.getLoopWithoutCloseSequentialPoints( 0.0001 * abs(inradius), loop )
	rotatedLoopLayer.loops += getTransformedFillOutline(loop, xmlElement, svgReader.yAxisPointingUpward)
コード例 #5
0
def processSVGElementrect( svgReader, xmlElement ):
	"Process xmlElement by svgReader."
	attributeDictionary = xmlElement.attributeDictionary
	height = euclidean.getFloatDefaultByDictionary( 0.0, attributeDictionary, 'height')
	if height == 0.0:
		print('Warning, in processSVGElementrect in svgReader height is zero in:')
		print(attributeDictionary)
		return
	width = euclidean.getFloatDefaultByDictionary( 0.0, attributeDictionary, 'width')
	if width == 0.0:
		print('Warning, in processSVGElementrect in svgReader width is zero in:')
		print(attributeDictionary)
		return
	center = euclidean.getComplexDefaultByDictionaryKeys(complex(), attributeDictionary, 'x', 'y')
	inradius = 0.5 * complex( width, height )
	cornerRadius = euclidean.getComplexDefaultByDictionaryKeys( complex(), attributeDictionary, 'rx', 'ry')
	rotatedLoopLayer = svgReader.getRotatedLoopLayer()
	if cornerRadius.real == 0.0 and cornerRadius.imag == 0.0:
		inradiusMinusX = complex( - inradius.real, inradius.imag )
		loop = [center + inradius, center + inradiusMinusX, center - inradius, center - inradiusMinusX]
		rotatedLoopLayer.loops += getTransformedFillOutline(loop, xmlElement, svgReader.yAxisPointingUpward)
		return
	if cornerRadius.real == 0.0:
		cornerRadius = complex( cornerRadius.imag, cornerRadius.imag )
	elif cornerRadius.imag == 0.0:
		cornerRadius = complex( cornerRadius.real, cornerRadius.real )
	cornerRadius = complex( min( cornerRadius.real, inradius.real ), min( cornerRadius.imag, inradius.imag ) )
	ellipsePath = [ complex( cornerRadius.real, 0.0 ) ]
	inradiusMinusCorner = inradius - cornerRadius
	loop = []
	global globalNumberOfCornerPoints
	global globalSideAngle
	for side in xrange( 1, globalNumberOfCornerPoints ):
		unitPolar = euclidean.getWiddershinsUnitPolar( float(side) * globalSideAngle )
		ellipsePath.append( complex( unitPolar.real * cornerRadius.real, unitPolar.imag * cornerRadius.imag ) )
	ellipsePath.append( complex( 0.0, cornerRadius.imag ) )
	cornerPoints = []
	for point in ellipsePath:
		cornerPoints.append( point + inradiusMinusCorner )
	cornerPointsReversed = cornerPoints[: : -1]
	for cornerPoint in cornerPoints:
		loop.append( center + cornerPoint )
	for cornerPoint in cornerPointsReversed:
		loop.append( center + complex( - cornerPoint.real, cornerPoint.imag ) )
	for cornerPoint in cornerPoints:
		loop.append( center - cornerPoint )
	for cornerPoint in cornerPointsReversed:
		loop.append( center + complex( cornerPoint.real, - cornerPoint.imag ) )
	loop = euclidean.getLoopWithoutCloseSequentialPoints( 0.0001 * abs(inradius), loop )
	rotatedLoopLayer.loops += getTransformedFillOutline(loop, xmlElement, svgReader.yAxisPointingUpward)
コード例 #6
0
def processSVGElementellipse( svgReader, xmlElement ):
	"Process xmlElement by svgReader."
	attributeDictionary = xmlElement.attributeDictionary
	center = euclidean.getComplexDefaultByDictionaryKeys( complex(), attributeDictionary, 'cx', 'cy')
	radius = euclidean.getComplexDefaultByDictionaryKeys( complex(), attributeDictionary, 'rx', 'ry')
	if radius.real == 0.0 or radius.imag == 0.0:
		print('Warning, in processSVGElementellipse in svgReader radius is zero in:')
		print(attributeDictionary)
		return
	global globalNumberOfCirclePoints
	global globalSideAngle
	loop = []
	rotatedLoopLayer = svgReader.getRotatedLoopLayer()
	for side in xrange( globalNumberOfCirclePoints ):
		unitPolar = euclidean.getWiddershinsUnitPolar( float(side) * globalSideAngle )
		loop.append( center + complex( unitPolar.real * radius.real, unitPolar.imag * radius.imag ) )
	rotatedLoopLayer.loops += getTransformedFillOutline(loop, xmlElement, svgReader.yAxisPointingUpward)
コード例 #7
0
def processSVGElementtext(svgReader, xmlElement):
	"Process xmlElement by svgReader."
	if svgReader.yAxisPointingUpward:
		return
	fontFamily = getStyleValue('Gentium Basic Regular', 'font-family', xmlElement)
	fontSize = getRightStripAlphabetPercent(getStyleValue('12.0', 'font-size', xmlElement))
	matrixSVG = getChainMatrixSVGIfNecessary(xmlElement, svgReader.yAxisPointingUpward)
	rotatedLoopLayer = svgReader.getRotatedLoopLayer()
	translate = euclidean.getComplexDefaultByDictionaryKeys(complex(), xmlElement.attributeDictionary, 'x', 'y')
	for textComplexLoop in getTextComplexLoops(fontFamily, fontSize, xmlElement.text, svgReader.yAxisPointingUpward):
		translatedLoop = []
		for textComplexPoint in textComplexLoop:
			translatedLoop.append(textComplexPoint + translate )
		rotatedLoopLayer.loops.append(matrixSVG.getTransformedPath(translatedLoop))
コード例 #8
0
def processSVGElementtext(svgReader, xmlElement):
	"Process xmlElement by svgReader."
	if svgReader.yAxisPointingUpward:
		return
	fontFamily = getStyleValue('Gentium Basic Regular', 'font-family', xmlElement)
	fontSize = getRightStripAlphabetPercent(getStyleValue('12.0', 'font-size', xmlElement))
	matrixSVG = getChainMatrixSVGIfNecessary(xmlElement, svgReader.yAxisPointingUpward)
	rotatedLoopLayer = svgReader.getRotatedLoopLayer()
	translate = euclidean.getComplexDefaultByDictionaryKeys(complex(), xmlElement.attributeDictionary, 'x', 'y')
	for textComplexLoop in getTextComplexLoops(fontFamily, fontSize, xmlElement.text, svgReader.yAxisPointingUpward):
		translatedLoop = []
		for textComplexPoint in textComplexLoop:
			translatedLoop.append(textComplexPoint + translate )
		rotatedLoopLayer.loops.append(matrixSVG.getTransformedPath(translatedLoop))
コード例 #9
0
ファイル: svg_reader.py プロジェクト: 1060460048/Cura
def processSVGElementcircle( elementNode, svgReader ):
	"Process elementNode by svgReader."
	attributes = elementNode.attributes
	center = euclidean.getComplexDefaultByDictionaryKeys( complex(), attributes, 'cx', 'cy')
	radius = euclidean.getFloatDefaultByDictionary( 0.0, attributes, 'r')
	if radius == 0.0:
		print('Warning, in processSVGElementcircle in svgReader radius is zero in:')
		print(attributes)
		return
	global globalNumberOfCirclePoints
	global globalSideAngle
	loop = []
	loopLayer = svgReader.getLoopLayer()
	for side in xrange( globalNumberOfCirclePoints ):
		unitPolar = euclidean.getWiddershinsUnitPolar( float(side) * globalSideAngle )
		loop.append( center + radius * unitPolar )
	loopLayer.loops += getTransformedFillOutline(elementNode, loop, svgReader.yAxisPointingUpward)
コード例 #10
0
ファイル: svg_reader.py プロジェクト: clothbot/DotSkeinforge
def processSVGElementtext(svgReader, xmlElement):
	"Process xmlElement by svgReader."
	if svgReader.yAxisPointingUpward:
		return
	translate = euclidean.getComplexDefaultByDictionaryKeys(complex(), xmlElement.attributeDictionary, 'x', 'y')
	fontFamily = getStyleValue('Gentium Basic Regular', 'font-family', xmlElement)
	global globalFontReaderDictionary
	fontReader = getFontReader(fontFamily)
	fontSize = getRightStripAlphabetPercent(getStyleValue('12.0', 'font-size', xmlElement))
	rotatedLoopLayer = svgReader.getRotatedLoopLayer()
	horizontalAdvanceX = 0.0
	matrixSVG = getChainMatrixSVGIfNecessary(xmlElement, svgReader.yAxisPointingUpward)
	for character in xmlElement.text:
		glyph = fontReader.getGlyph(character, svgReader)
		glyphLoops = glyph.getSizedAdvancedLoops(fontSize, horizontalAdvanceX, translate, svgReader.yAxisPointingUpward)
		rotatedLoopLayer.loops += matrixSVG.getTransformedPaths(glyphLoops)
		horizontalAdvanceX += glyph.horizontalAdvanceX
コード例 #11
0
ファイル: svg_reader.py プロジェクト: maestroflema/asimov
def processSVGElementcircle( elementNode, svgReader ):
	"Process elementNode by svgReader."
	attributes = elementNode.attributes
	center = euclidean.getComplexDefaultByDictionaryKeys( complex(), attributes, 'cx', 'cy')
	radius = euclidean.getFloatDefaultByDictionary( 0.0, attributes, 'r')
	if radius == 0.0:
		print('Warning, in processSVGElementcircle in svgReader radius is zero in:')
		print(attributes)
		return
	global globalNumberOfCirclePoints
	global globalSideAngle
	loop = []
	loopLayer = svgReader.getLoopLayer()
	for side in xrange( globalNumberOfCirclePoints ):
		unitPolar = euclidean.getWiddershinsUnitPolar( float(side) * globalSideAngle )
		loop.append( center + radius * unitPolar )
	loopLayer.loops += getTransformedFillOutline(elementNode, loop, svgReader.yAxisPointingUpward)
コード例 #12
0
def processSVGElementline(svgReader, xmlElement):
	"Process xmlElement by svgReader."
	begin = euclidean.getComplexDefaultByDictionaryKeys(complex(), xmlElement.attributeDictionary, 'x1', 'y1')
	end = euclidean.getComplexDefaultByDictionaryKeys(complex(), xmlElement.attributeDictionary, 'x2', 'y2')
	rotatedLoopLayer = svgReader.getRotatedLoopLayer()
	rotatedLoopLayer.loops += getTransformedOutlineByPath([begin, end], xmlElement, svgReader.yAxisPointingUpward)
コード例 #13
0
ファイル: svg_reader.py プロジェクト: 1060460048/Cura
def processSVGElementline(elementNode, svgReader):
	"Process elementNode by svgReader."
	begin = euclidean.getComplexDefaultByDictionaryKeys(complex(), elementNode.attributes, 'x1', 'y1')
	end = euclidean.getComplexDefaultByDictionaryKeys(complex(), elementNode.attributes, 'x2', 'y2')
	loopLayer = svgReader.getLoopLayer()
	loopLayer.loops += getTransformedOutlineByPath(elementNode, [begin, end], svgReader.yAxisPointingUpward)