├── paket.lock ├── paket.dependencies ├── ProjectSettings ├── ProjectVersion.txt ├── NavMeshLayers.asset ├── ClusterInputManager.asset ├── EditorBuildSettings.asset ├── NetworkManager.asset ├── TimeManager.asset ├── AudioManager.asset ├── EditorSettings.asset ├── TagManager.asset ├── DynamicsManager.asset ├── UnityConnectSettings.asset ├── NavMeshAreas.asset ├── Physics2DSettings.asset ├── GraphicsSettings.asset ├── QualitySettings.asset └── InputManager.asset ├── .paket ├── paket.exe ├── paket.bootstrapper.exe └── paket.targets ├── Assets ├── Demo.meta ├── Editor.meta ├── SVGFiles.meta ├── Test.unity.meta ├── BigBatch.unity.meta ├── Demo │ ├── Invoke.cs.meta │ ├── Material.mat.meta │ ├── Shader.shader.meta │ ├── Shader.shader │ ├── Material.mat │ └── Invoke.cs ├── Editor │ └── UnityREPL.meta ├── SVGFiles │ ├── arc1.txt.meta │ ├── arc2.txt.meta │ ├── arc3.txt.meta │ ├── lion.txt.meta │ ├── none.txt.meta │ ├── path1.txt.meta │ ├── path2.txt.meta │ ├── path3.txt.meta │ ├── rect1.txt.meta │ ├── rect2.txt.meta │ ├── test1.txt.meta │ ├── test2.txt.meta │ ├── tiger.txt.meta │ ├── butterfly.svg.meta │ ├── butterfly.txt.meta │ ├── circle1.txt.meta │ ├── lines1.txt.meta │ ├── polyline1.txt.meta │ ├── polyline2.txt.meta │ ├── radgrad1.txt.meta │ ├── lineargradient1.txt.meta │ ├── rect1.svg.meta │ ├── lineargradient1.svg.meta │ ├── none.txt │ ├── path1.txt │ ├── rect2.txt │ ├── path2.txt │ ├── arc1.txt │ ├── path3.txt │ ├── arc3.txt │ ├── rect1.svg │ ├── rect1.txt │ ├── polyline2.txt │ ├── circle1.txt │ ├── arc2.txt │ ├── polyline1.txt │ ├── test1.txt │ ├── radgrad1.txt │ ├── lines1.txt │ ├── lineargradient1.svg │ ├── lineargradient1.txt │ └── test2.txt ├── UnityGUIExtensions.meta ├── UnitySVG │ ├── Interface.meta │ ├── Implement.cs.meta │ ├── Implementation.meta │ ├── Implementation │ │ ├── SVG.meta │ │ ├── SVG │ │ │ ├── DOM.meta │ │ │ └── DOM │ │ │ │ ├── Paths.meta │ │ │ │ ├── BasicShapes.meta │ │ │ │ ├── BasicTypes.meta │ │ │ │ ├── Utilities.meta │ │ │ │ ├── Paths │ │ │ │ ├── Interfaces.meta │ │ │ │ ├── SVGPathSeg.cs.meta │ │ │ │ ├── SVGPathElement.cs.meta │ │ │ │ ├── SVGPathSegArcAbs.cs.meta │ │ │ │ ├── SVGPathSegArcRel.cs.meta │ │ │ │ ├── SVGPathSegList.cs.meta │ │ │ │ ├── SVGPathSegClosePath.cs.meta │ │ │ │ ├── SVGPathSegCurvetoCubic.cs.meta │ │ │ │ ├── SVGPathSegLinetoAbs.cs.meta │ │ │ │ ├── SVGPathSegLinetoRel.cs.meta │ │ │ │ ├── SVGPathSegMovetoAbs.cs.meta │ │ │ │ ├── SVGPathSegMovetoRel.cs.meta │ │ │ │ ├── Interfaces │ │ │ │ │ ├── ISVGDrawable.cs.meta │ │ │ │ │ ├── ISVGDrawableSeg.cs.meta │ │ │ │ │ ├── ISVGDrawableSeg.cs │ │ │ │ │ ├── ISVGDrawable.cs │ │ │ │ │ ├── ISVGPathSegment.cs │ │ │ │ │ └── ISVGPathSegment.cs.meta │ │ │ │ ├── SVGPathSegCurvetoCubicAbs.cs.meta │ │ │ │ ├── SVGPathSegCurvetoCubicRel.cs.meta │ │ │ │ ├── SVGPathSegCurvetoQuadratic.cs.meta │ │ │ │ ├── SVGPathSegLinetoVerticalAbs.cs.meta │ │ │ │ ├── SVGPathSegLinetoVerticalRel.cs.meta │ │ │ │ ├── SVGPathSegCurvetoCubicSmoothAbs.cs.meta │ │ │ │ ├── SVGPathSegCurvetoCubicSmoothRel.cs.meta │ │ │ │ ├── SVGPathSegCurvetoQuadraticAbs.cs.meta │ │ │ │ ├── SVGPathSegCurvetoQuadraticRel.cs.meta │ │ │ │ ├── SVGPathSegLinetoHorizontalAbs.cs.meta │ │ │ │ ├── SVGPathSegLinetoHorizontalRel.cs.meta │ │ │ │ ├── SVGPathSegCurvetoQuadraticSmoothAbs.cs.meta │ │ │ │ ├── SVGPathSegCurvetoQuadraticSmoothRel.cs.meta │ │ │ │ ├── SVGPathSegCurvetoQuadratic.cs │ │ │ │ ├── SVGPathSegCurvetoCubic.cs │ │ │ │ ├── SVGPathSegLinetoAbs.cs │ │ │ │ ├── SVGPathSegMovetoAbs.cs │ │ │ │ ├── SVGPathSegClosePath.cs │ │ │ │ ├── SVGPathSegLinetoVerticalAbs.cs │ │ │ │ ├── SVGPathSegLinetoHorizontalAbs.cs │ │ │ │ ├── SVGPathSegLinetoVerticalRel.cs │ │ │ │ ├── SVGPathSegLinetoHorizontalRel.cs │ │ │ │ ├── SVGPathSegLinetoRel.cs │ │ │ │ ├── SVGPathSegMovetoRel.cs │ │ │ │ ├── SVGPathSegCurvetoQuadraticAbs.cs │ │ │ │ ├── SVGPathSegArcAbs.cs │ │ │ │ ├── SVGPathSegList.cs │ │ │ │ ├── SVGPathSegCurvetoQuadraticSmoothAbs.cs │ │ │ │ ├── SVGPathSegArcRel.cs │ │ │ │ ├── SVGPathSegCurvetoCubicAbs.cs │ │ │ │ ├── SVGPathSeg.cs │ │ │ │ ├── SVGPathSegCurvetoCubicSmoothAbs.cs │ │ │ │ ├── SVGPathSegCurvetoQuadraticSmoothRel.cs │ │ │ │ ├── SVGPathSegCurvetoQuadraticRel.cs │ │ │ │ ├── SVGPathSegCurvetoCubicSmoothRel.cs │ │ │ │ └── SVGPathSegCurvetoCubicRel.cs │ │ │ │ ├── DocumentStructure.meta │ │ │ │ ├── GradientsNPatterns.meta │ │ │ │ ├── BasicTypes │ │ │ │ ├── SVGColor.cs.meta │ │ │ │ ├── SVGLength.cs.meta │ │ │ │ ├── SVGPaintable.cs.meta │ │ │ │ ├── SVGTransformable.cs.meta │ │ │ │ ├── SVGColor.cs │ │ │ │ ├── SVGTransformable.cs │ │ │ │ └── SVGLength.cs │ │ │ │ ├── CoordinateTransformUnits.meta │ │ │ │ ├── Utilities │ │ │ │ ├── DOMException.cs.meta │ │ │ │ ├── LiteStack.cs.meta │ │ │ │ ├── SVGException.cs.meta │ │ │ │ ├── SVGColorExtractor.cs.meta │ │ │ │ ├── SVGStringExtractor.cs.meta │ │ │ │ ├── SVGException.cs │ │ │ │ ├── LiteStack.cs │ │ │ │ ├── DOMException.cs │ │ │ │ └── SVGStringExtractor.cs │ │ │ │ ├── BasicShapes │ │ │ │ ├── SVGCircleElement.cs.meta │ │ │ │ ├── SVGLineElement.cs.meta │ │ │ │ ├── SVGRectElement.cs.meta │ │ │ │ ├── SVGEllipseElement.cs.meta │ │ │ │ ├── SVGPolygonElement.cs.meta │ │ │ │ ├── SVGPolylineElement.cs.meta │ │ │ │ ├── SVGBasicElement.cs.meta │ │ │ │ ├── SVGCircleElement.cs │ │ │ │ ├── SVGEllipseElement.cs │ │ │ │ ├── SVGRectElement.cs │ │ │ │ ├── SVGPolylineElement.cs │ │ │ │ ├── SVGPolygonElement.cs │ │ │ │ ├── SVGLineElement.cs │ │ │ │ └── SVGBasicElement.cs │ │ │ │ ├── DocumentStructure │ │ │ │ ├── SVGDocument.cs.meta │ │ │ │ ├── SVGGElement.cs.meta │ │ │ │ ├── SVGSVGElement.cs.meta │ │ │ │ ├── SVGDocument.cs │ │ │ │ ├── SVGGElement.cs │ │ │ │ └── SVGSVGElement.cs │ │ │ │ ├── GradientsNPatterns │ │ │ │ ├── SVGStopElement.cs.meta │ │ │ │ ├── SVGGradientElement.cs.meta │ │ │ │ ├── SVGLinearGradientElement.cs.meta │ │ │ │ ├── SVGRadialGradientElement.cs.meta │ │ │ │ ├── SVGStopElement.cs │ │ │ │ ├── SVGLinearGradientElement.cs │ │ │ │ ├── SVGRadialGradientElement.cs │ │ │ │ └── SVGGradientElement.cs │ │ │ │ └── CoordinateTransformUnits │ │ │ │ ├── Matrix2x3.cs.meta │ │ │ │ ├── SVGTransform.cs.meta │ │ │ │ ├── SVGTransformList.cs.meta │ │ │ │ ├── SVGTransformList.cs │ │ │ │ ├── Matrix2x3.cs │ │ │ │ └── SVGTransform.cs │ │ ├── XMLParser.meta │ │ ├── RenderingEngine.meta │ │ ├── XMLParser │ │ │ ├── SVGParser.cs.meta │ │ │ ├── SmallXmlParser.cs.meta │ │ │ └── SVGParser.cs │ │ └── RenderingEngine │ │ │ ├── BasicType.meta │ │ │ ├── RenderingDevices.meta │ │ │ ├── SVGBasicDraw.cs.meta │ │ │ ├── SVGGraphics.cs.meta │ │ │ ├── SVGGraphicsFill.cs.meta │ │ │ ├── SVGGraphicsPath.cs.meta │ │ │ ├── BasicType │ │ │ ├── SVGGArcAbs.cs.meta │ │ │ ├── SVGGCircle.cs.meta │ │ │ ├── SVGGCubicAbs.cs.meta │ │ │ ├── SVGGEllipse.cs.meta │ │ │ ├── SVGGQuadraticAbs.cs.meta │ │ │ ├── SVGGLineTo.cs.meta │ │ │ ├── SVGGMoveTo.cs.meta │ │ │ ├── SVGGRect.cs.meta │ │ │ ├── SVGGPolyLine.cs.meta │ │ │ ├── SVGGPolygon.cs.meta │ │ │ ├── SVGGLineTo.cs │ │ │ ├── SVGGCircle.cs │ │ │ ├── SVGGMoveTo.cs │ │ │ ├── SVGGQuadraticAbs.cs │ │ │ ├── SVGGEllipse.cs │ │ │ ├── SVGGPolygon.cs │ │ │ ├── SVGGPolyLine.cs │ │ │ ├── SVGGCubicAbs.cs │ │ │ ├── SVGGArcAbs.cs │ │ │ └── SVGGRect.cs │ │ │ ├── SVGGraphicsStroke.cs.meta │ │ │ ├── SVGLinearGradientBrush.cs.meta │ │ │ ├── SVGRadialGradientBrush.cs.meta │ │ │ ├── RenderingDevices │ │ │ ├── SVGDeviceFast.cs.meta │ │ │ ├── ISVGDevice.cs.meta │ │ │ ├── SVGDeviceSmall.cs.meta │ │ │ ├── ISVGDevice.cs │ │ │ ├── SVGDeviceFast.cs │ │ │ └── SVGDeviceSmall.cs │ │ │ ├── SVGGraphicsPath.cs │ │ │ └── SVGLinearGradientBrush.cs │ ├── Interface │ │ ├── RenderingEngine.meta │ │ └── RenderingEngine │ │ │ ├── ISVGPathDraw.cs.meta │ │ │ └── ISVGPathDraw.cs │ ├── Extensions.cs │ ├── Extensions.cs.meta │ └── Implement.cs └── UnitySVG.meta ├── SharpVectorGraphics.0.4.alpha.zip ├── bin ├── paket └── format_code ├── .gitmodules ├── .editorconfig ├── .gitignore ├── UnitySVG.sublime-project ├── LICENSE ├── README.md └── benchmarks.txt /paket.lock: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /paket.dependencies: -------------------------------------------------------------------------------- 1 | source https://www.nuget.org/api/v2 2 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.5.2f1 2 | -------------------------------------------------------------------------------- /.paket/paket.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrJoy/UnitySVG/HEAD/.paket/paket.exe -------------------------------------------------------------------------------- /Assets/Demo.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 08b24598dd117a63d0004889613f5639 3 | -------------------------------------------------------------------------------- /Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb6f2cbdc33c14793b345ecd7f501d9d 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 7329e7dfae9e2432db0c51e8e06d74e5 3 | -------------------------------------------------------------------------------- /Assets/Test.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 72ae05d36e51449b0953c3184b18d653 3 | -------------------------------------------------------------------------------- /Assets/BigBatch.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 56684fc74466b46f28607eee7cc186c2 3 | -------------------------------------------------------------------------------- /Assets/Demo/Invoke.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: f681b4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/Demo/Material.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 51edb96bdd118a63d000decb613f5639 3 | -------------------------------------------------------------------------------- /Assets/Demo/Shader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: d5e8e6383c1f3428ead6d80078cb8daf 3 | -------------------------------------------------------------------------------- /Assets/Editor/UnityREPL.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e57f43ecc64d3472f9559232a339d63b 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/arc1.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 9c11505acd3334dd49c26981ad8853a9 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/arc2.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: f7a83dad7eccd4f39812661fee7bf285 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/arc3.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: e4c0cc2d4572f45a1b29a021feb7e1b9 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/lion.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 8a395d64ef14b443a87fd383c19bb58c 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/none.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 4769247eb286a4faabbd21567ef7d5d2 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/path1.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 2268932f9d8c84ae28ffd0a78885f00e 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/path2.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 1805eee13a2014d5ea9a586e0d0560ee 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/path3.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: a040285ffb356451198844403cc242b3 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/rect1.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: bd68f1af0cd774dc4bde7d2e161fea35 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/rect2.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: c2545c8d9994746c092fb7a7023206e2 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/test1.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 1a881d02cd6d34d0f8814e6a92b19c2f 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/test2.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 97cc7aa9aaa064cb38b78afc029b5aac 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/tiger.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 5526ef80d6d7342859fad7964808fdca 3 | -------------------------------------------------------------------------------- /Assets/UnityGUIExtensions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e79c3645c60fa4bda870cf5bd4570cfd 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Interface.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 74ffa4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/butterfly.svg.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 1b1a9256d13844471877bf5f5ea6d670 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/butterfly.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 2d59d53084f184b8bae8db891ed1dfe8 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/circle1.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 4b1d125e9c8d84780a99629ca0a7d768 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/lines1.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 9ed41d2b626b344d2bd96a4f792485b5 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/polyline1.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: bdd68603fbf20464fa6d8ecffbb07690 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/polyline2.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 421a8db9b6ed841c394c51edd695620e 3 | -------------------------------------------------------------------------------- /Assets/SVGFiles/radgrad1.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: c7b0d77386e2b426dbc764553e601799 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 43ce94a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 83de94a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /.paket/paket.bootstrapper.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrJoy/UnitySVG/HEAD/.paket/paket.bootstrapper.exe -------------------------------------------------------------------------------- /Assets/SVGFiles/lineargradient1.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: e3f6aaf8394bc4ed7b78185625feac37 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 8ca2a4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 3c53a4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/XMLParser.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 7b0fa4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: a40aa4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Interface/RenderingEngine.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 7b70b4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /SharpVectorGraphics.0.4.alpha.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrJoy/UnitySVG/HEAD/SharpVectorGraphics.0.4.alpha.zip -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 878f94a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicShapes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 2714a4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicTypes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: d855a4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Utilities.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 62bda4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshLayers.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrJoy/UnitySVG/HEAD/ProjectSettings/NavMeshLayers.asset -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/Interfaces.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: be5ba4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/XMLParser/SVGParser.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 8b3aa7b3f9ae941fba31c7e5bbb28275 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 6b70a4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/DocumentStructure.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: ac28a4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/GradientsNPatterns.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: b519a4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSeg.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 2b70f56a6b52646feb27c50962075d93 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/XMLParser/SmallXmlParser.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 47bfa4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Interface/RenderingEngine/ISVGPathDraw.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 5dae9f92bb40f445cb3b4fb004e0beab 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/RenderingDevices.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 399c088f42a0e439a8496ad381d37749 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/SVGBasicDraw.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: ad8691ad30aea46b79363aa335981238 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/SVGGraphics.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: d6b07b7adb54544308ed236c59c56d5e 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/SVGGraphicsFill.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 2cf9037eaf1584c05a217166a6003430 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/SVGGraphicsPath.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: fbaa5b797a3f74caaadcf5401c96e167 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicTypes/SVGColor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 2f1b12114bdc245079e618b539314d07 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicTypes/SVGLength.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: f3d08beca8f154357896be1c1574affc 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicTypes/SVGPaintable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: ab6a956192fbe4116a407a477fcc9de3 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/CoordinateTransformUnits.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 1a07a4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 88a9fccb49d2f4ee3b758e27335d83e5 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegArcAbs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 92c1b32b014fb480cbe35fc55c1ce6f8 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegArcRel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 1f940484fe758429faf4660dab138224 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegList.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: c3a5a12d5cfdf459a96bd7602960e338 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Utilities/DOMException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: fdd76c284ee7d45f5840b0009dba0fe7 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Utilities/LiteStack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: c9cea4a6dd117063d000a35b613f5639 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Utilities/SVGException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 0cef747541703440e86340b5cca84580 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGArcAbs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: ba81054021fcb4662880c509b914471b 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGCircle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 380499dc426414b3eaa324a44ab2da06 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/SVGGraphicsStroke.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: a334b83904b414926ab32f8c851d16b9 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicShapes/SVGCircleElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 758082430f9644092985eec7f5ddb372 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicShapes/SVGLineElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 297daae153b5843be80d0669a553faaa 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicShapes/SVGRectElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 77b819b47807149ac91314cd15c0fab1 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicTypes/SVGTransformable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 3c0154a4c8db64dcbb16fc691a9f45dd 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegClosePath.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 7a89d3f4073fb49ffae831dfe556df98 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoCubic.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: a2d7cc7c68bf24b5bab0fefbb0851fa5 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegLinetoAbs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: c369e9d2111a44839a555ece2f8cc0c7 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegLinetoRel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 598fbae76f429454dbcd251986937ba2 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegMovetoAbs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: fbe527def63804b9d8c621e098c769ed 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegMovetoRel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 5ca7104214e9e4b86bea3ad704c56994 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Utilities/SVGColorExtractor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: e59e39c6de3a64773a555ba42a3d4447 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Utilities/SVGStringExtractor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: c74d09cf2a00d43b08571a2f5c7fdc43 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGCubicAbs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 7b411c68dc084478d83f468252f77ba8 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGEllipse.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 6ca78d12aa6ad4e7bbd2b8f492c0e4e9 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/SVGLinearGradientBrush.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 9085dec39bfbd44d8b33cd0051736df7 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/SVGRadialGradientBrush.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 9dfbeb88b4e5b4f1ab687fc2e191c704 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicShapes/SVGEllipseElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: a2bc70aeb171e4ce1929950dcfa578f7 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicShapes/SVGPolygonElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 49f635bd579a240108976538d83cbaa7 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicShapes/SVGPolylineElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 15af5e10b0d1a4e48b4cf38d4a9537d0 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/DocumentStructure/SVGDocument.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 351f8e4d9caca45deb72797bd9accd88 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/DocumentStructure/SVGGElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 92743eda825db45f6a0725f43f95c520 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/DocumentStructure/SVGSVGElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 62c14cc19744a449d861e2dc24d17e1a 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/GradientsNPatterns/SVGStopElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 9eca5f7bd51d74ad1adbfd5813ee1d60 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/Interfaces/ISVGDrawable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 8c5161da6c9f74a89a45bde33685326e 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/Interfaces/ISVGDrawableSeg.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: df377ead808a74361af6bd1093a36c54 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoCubicAbs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 8af6997e3963c4b7d9aa8bc78a51ecff 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoCubicRel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 421a648b36a774323b5a89b88ace9e04 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoQuadratic.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 7ccc78f38046e46959a0bd5e500242c4 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegLinetoVerticalAbs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: edbd2f73ed0ca498a81fed71c51fb3a6 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegLinetoVerticalRel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: df2e19d82da4d426a816cb5475896b60 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGQuadraticAbs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 06e81d861b5bd4d1daf673947f95f53b 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/RenderingDevices/SVGDeviceFast.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: d5c6b3a8c2afa4255bf63e48acf25e9a 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/CoordinateTransformUnits/Matrix2x3.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: b762a9f8a98e343d2b6517b865fad1c7 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/CoordinateTransformUnits/SVGTransform.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 73fb19954f55c41469ca4a891e89237d 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/GradientsNPatterns/SVGGradientElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 23c55137f8cff4504ad7ade00514723b 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoCubicSmoothAbs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: b32c10b86636e47d8a5e702b636c2338 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoCubicSmoothRel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 2a88dc4645b3c4158bdba5f715545423 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoQuadraticAbs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: e78801a1b0be646ac8714c8245722e9d 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoQuadraticRel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 5c1257a4d950c473abf4fc913cce080a 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegLinetoHorizontalAbs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 5ca1e8b4086414bbb99559fc824a2aa2 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegLinetoHorizontalRel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 7e25b3aae953f474d9178fed3ebeca13 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/CoordinateTransformUnits/SVGTransformList.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 5a4367b24dcce4a168354870cba6f04d 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/GradientsNPatterns/SVGLinearGradientElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 888d54f7bc6bb482ca16f0bd23127dec 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/GradientsNPatterns/SVGRadialGradientElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 6ca1ed628a6764b268c49aecf1d5779f 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoQuadraticSmoothAbs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 09dca972c6d4b4ee1bce0e37509c23d0 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoQuadraticSmoothRel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 50dda37f18ebe40f38c78aa0f2114ffc 3 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/Interfaces/ISVGDrawableSeg.cs: -------------------------------------------------------------------------------- 1 | public interface ISVGDrawableSeg { 2 | void Render(SVGGraphicsPath graphicsPath); 3 | } 4 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/Interfaces/ISVGDrawable.cs: -------------------------------------------------------------------------------- 1 | public interface ISVGDrawable { 2 | void BeforeRender(SVGTransformList transformList); 3 | 4 | void Render(); 5 | } 6 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /bin/paket: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | BASE_DIR=$( 6 | cd "$(dirname "$(readlink "$0" || echo "$0")")/.." 7 | /bin/pwd 8 | ) 9 | 10 | mono "${BASE_DIR}"/.paket/paket.exe "$@" 11 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoQuadratic.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public abstract class SVGPathSegCurvetoQuadratic : SVGPathSeg { 4 | public abstract Vector2 controlPoint1 { get; } 5 | } 6 | -------------------------------------------------------------------------------- /Assets/SVGFiles/rect1.svg.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f8c823ecef3b764ea6d1ed784fb870d 3 | timeCreated: 1446924938 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/Interfaces/ISVGPathSegment.cs: -------------------------------------------------------------------------------- 1 | public interface ISVGPathSegment { 2 | void ExpandBounds(SVGGraphicsPath path); 3 | 4 | bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw); 5 | } 6 | -------------------------------------------------------------------------------- /Assets/SVGFiles/lineargradient1.svg.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a5adee1ea5c98543abe76a73ecc5ac4 3 | timeCreated: 1446891395 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnitySVG.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e9727643870f994c8a30a12753ac52e 3 | folderAsset: yes 4 | timeCreated: 1446488794 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Demo/Shader.shader: -------------------------------------------------------------------------------- 1 | Shader "Shader" { 2 | Properties { 3 | _MainTex ("Base (RGB)", 2D) = "white" { } 4 | } 5 | SubShader { 6 | Pass { 7 | Lighting Off 8 | SetTexture [_MainTex] { combine texture } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGLineTo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9b5fe785f51eb4b47aa9e37f83de71d6 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGMoveTo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e80992fbb771419599417b7123cbefc 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGRect.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1a82212972e94781a24db7b61b247ca 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGPolyLine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 72d2c18216b5f4a86a22a9097ee17132 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGPolygon.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c25cfb9cb96d7423790920f8e54f0208 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/Interfaces/ISVGPathSegment.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd25c55913f04475b84c09e3eae3e29b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Assets/Editor/UnityREPL"] 2 | path = Assets/Editor/UnityREPL 3 | url = git://github.com/MrJoy/UnityREPL.git 4 | [submodule "Assets/UnityGUIExtensions"] 5 | path = Assets/UnityGUIExtensions 6 | url = git://github.com/MrJoy/UnityGUIExtensions.git 7 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/RenderingDevices/ISVGDevice.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0ebd8d14349e40dba7085eb34ec5979 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/RenderingDevices/SVGDeviceSmall.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86adde7f4428642f4bb6bef0cb806168 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoCubic.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public abstract class SVGPathSegCurvetoCubic : SVGPathSeg { 4 | public abstract Vector2 controlPoint1 { get; } 5 | 6 | public abstract Vector2 controlPoint2 { get; } 7 | } 8 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /Assets/SVGFiles/none.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | charset = utf-8 12 | indent_style = space 13 | indent_size = 2 14 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace UnitySVG { 4 | public static class Extensions { 5 | public static string GetValue(this Dictionary dictionary, TKey key) { 6 | return dictionary.ContainsKey(key) ? dictionary[key] : string.Empty; 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Extensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 61b56091334dcb747a729265d4af1013 3 | timeCreated: 1446488772 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicShapes/SVGBasicElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 220fd59c049e7174fae88b94817659fe 3 | timeCreated: 1446493984 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/RenderingDevices/ISVGDevice.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public interface ISVGDevice { 4 | int Width { get; } 5 | 6 | int Height { get; } 7 | 8 | void SetDevice(int width, int height); 9 | 10 | void SetPixel(int x, int y); 11 | 12 | Color GetPixel(int x, int y); 13 | 14 | void SetColor(Color color); 15 | 16 | Texture2D Render(); 17 | } 18 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 0 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_DisableAudio: 0 16 | m_VirtualizeEffects: 1 17 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_DefaultBehaviorMode: 0 10 | m_SpritePackerMode: 2 11 | m_SpritePackerPaddingPower: 1 12 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;svg 13 | m_ProjectGenerationRootNamespace: 14 | m_UserGeneratedProjectSuffix: 15 | -------------------------------------------------------------------------------- /Assets/SVGFiles/path1.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | Example triangle01- simple example of a 'path' 7 | A path that draws a triangle 8 | 10 | 11 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGLineTo.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGGLineTo : ISVGPathSegment { 4 | private readonly Vector2 point; 5 | 6 | public SVGGLineTo(Vector2 p) { 7 | point = p; 8 | } 9 | 10 | public void ExpandBounds(SVGGraphicsPath path) { 11 | path.ExpandBounds(point); 12 | } 13 | 14 | public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw) { 15 | pathDraw.LineTo(path.matrixTransform.Transform(point)); 16 | return false; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGCircle.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGGCircle : ISVGPathSegment { 4 | private readonly Vector2 point; 5 | private readonly float r; 6 | 7 | public SVGGCircle(Vector2 p, float r) { 8 | this.point = p; 9 | this.r = r; 10 | } 11 | 12 | public void ExpandBounds(SVGGraphicsPath path) { 13 | path.ExpandBounds(point, r, r); 14 | } 15 | 16 | public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw) { 17 | pathDraw.CircleTo(path.matrixTransform.Transform(point), r); 18 | 19 | return true; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Assets/SVGFiles/rect2.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Assets/SVGFiles/path2.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | Example triangle01- simple example of a 'path' 7 | Picture showing a simple example of path data 8 | using both a "C" and an "S" command, 9 | along with annotations showing the control points 10 | and end points 11 | 12 | 13 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGMoveTo.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Profiling; 3 | 4 | public class SVGGMoveTo : ISVGPathSegment { 5 | private readonly Vector2 point; 6 | 7 | public SVGGMoveTo(Vector2 p) { 8 | point = p; 9 | } 10 | 11 | public void ExpandBounds(SVGGraphicsPath path) { 12 | path.ExpandBounds(point); 13 | } 14 | 15 | public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw) { 16 | Profiler.BeginSample("SVGGMoveTo.Render"); 17 | pathDraw.MoveTo(path.matrixTransform.Transform(point)); 18 | Profiler.EndSample(); 19 | return false; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegLinetoAbs.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegLinetoAbs : SVGPathSeg, ISVGDrawableSeg { 4 | private float _x = 0f, _y = 0f; 5 | 6 | public float x { get { return this._x; } } 7 | 8 | public float y { get { return this._y; } } 9 | 10 | public SVGPathSegLinetoAbs(float x, float y) : base() { 11 | this._x = x; 12 | this._y = y; 13 | } 14 | 15 | public override Vector2 currentPoint { get { return new Vector2(this._x, this._y); } } 16 | 17 | public void Render(SVGGraphicsPath _graphicsPath) { 18 | _graphicsPath.AddLineTo(currentPoint); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegMovetoAbs.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegMovetoAbs : SVGPathSeg, ISVGDrawableSeg { 4 | private float _x = 0f, _y = 0f; 5 | 6 | public float x { get { return this._x; } } 7 | 8 | public float y { get { return this._y; } } 9 | 10 | public SVGPathSegMovetoAbs(float x, float y) : base() { 11 | this._x = x; 12 | this._y = y; 13 | } 14 | 15 | public override Vector2 currentPoint { get { return new Vector2(this._x, this._y); } } 16 | 17 | public void Render(SVGGraphicsPath _graphicsPath) { 18 | _graphicsPath.AddMoveTo(new Vector2(this._x, this._y)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Assets/SVGFiles/arc1.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | Example arcs01 - arc commands in path data 7 | Picture of a pie chart with two pie wedges and 8 | a picture of a line with arc blips 9 | 11 | 13 | 14 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGQuadraticAbs.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGGQuadraticAbs : ISVGPathSegment { 4 | private readonly Vector2 p1; 5 | private readonly Vector2 p; 6 | 7 | public SVGGQuadraticAbs(Vector2 q1, Vector2 q) { 8 | p1 = q1; 9 | p = q; 10 | } 11 | 12 | public void ExpandBounds(SVGGraphicsPath path) { 13 | path.ExpandBounds(p1); 14 | path.ExpandBounds(p); 15 | } 16 | 17 | public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw) { 18 | pathDraw.QuadraticCurveTo(path.matrixTransform.Transform(p1), path.matrixTransform.Transform(p)); 19 | return false; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegClosePath.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegClosePath : SVGPathSeg, ISVGDrawableSeg { 4 | private float _x = 0f, _y = 0f; 5 | 6 | public SVGPathSegClosePath(float x, float y) : base() { 7 | if(x == -1f && y == -1f) { 8 | this._x = previousPoint.x; 9 | this._y = previousPoint.y; 10 | } else { 11 | this._x = x; 12 | this._y = y; 13 | } 14 | } 15 | 16 | public override Vector2 currentPoint { get { return new Vector2(this._x, this._y); } } 17 | 18 | public void Render(SVGGraphicsPath _graphicsPath) { 19 | _graphicsPath.AddLineTo(currentPoint); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Assets/SVGFiles/path3.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | Example triangle01- simple example of a 'path' 7 | Picture showing a simple example of path data 8 | using both a "C" and an "S" command, 9 | along with annotations showing the control points 10 | and end points 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/DocumentStructure/SVGDocument.cs: -------------------------------------------------------------------------------- 1 | public class SVGDocument { 2 | private SVGSVGElement rootElement; 3 | private readonly SVGGraphics render; 4 | private readonly SVGParser parser; 5 | 6 | public SVGSVGElement RootElement { 7 | get { 8 | if(rootElement == null) { 9 | while(!parser.IsEOF && parser.Node.Name != SVGNodeName.SVG) 10 | parser.Next(); 11 | rootElement = new SVGSVGElement(parser, new SVGTransformList(), new SVGPaintable(), render); 12 | } 13 | return rootElement; 14 | } 15 | } 16 | 17 | public SVGDocument(string originalDocument, SVGGraphics r) { 18 | parser = new SVGParser(originalDocument); 19 | render = r; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGEllipse.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGGEllipse : ISVGPathSegment { 4 | private readonly Vector2 p; 5 | private readonly float r1; 6 | private readonly float r2; 7 | private readonly float angle; 8 | 9 | public SVGGEllipse(Vector2 p, float r1, float r2, float angle) { 10 | this.p = p; 11 | this.r1 = r1; 12 | this.r2 = r2; 13 | this.angle = angle; 14 | } 15 | 16 | public void ExpandBounds(SVGGraphicsPath path) { 17 | path.ExpandBounds(p, r1, r2); 18 | } 19 | 20 | public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw) { 21 | pathDraw.EllipseTo(path.matrixTransform.Transform(p), r1, r2, path.transformAngle + angle); 22 | return true; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGPolygon.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | 4 | public class SVGGPolygon : ISVGPathSegment { 5 | private readonly List points; 6 | 7 | public SVGGPolygon(List points) { 8 | this.points = points; 9 | } 10 | 11 | public void ExpandBounds(SVGGraphicsPath path) { 12 | path.ExpandBounds(points); 13 | } 14 | 15 | public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw) { 16 | int length = points.Count; 17 | Vector2[] tPoints = new Vector2[length]; 18 | 19 | for(int i = 0; i < length; i++) 20 | tPoints[i] = path.matrixTransform.Transform(points[i]); 21 | pathDraw.Polygon(tPoints); 22 | 23 | return true; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGPolyLine.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | 4 | public class SVGGPolyLine : ISVGPathSegment { 5 | private readonly List points; 6 | 7 | public SVGGPolyLine(List points) { 8 | this.points = points; 9 | } 10 | 11 | public void ExpandBounds(SVGGraphicsPath path) { 12 | path.ExpandBounds(points); 13 | } 14 | 15 | public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw) { 16 | int length = points.Count; 17 | pathDraw.MoveTo(path.matrixTransform.Transform(points[0])); 18 | for(int i = 1; i < length; i++) { 19 | Vector2 p = path.matrixTransform.Transform(points[i]); 20 | pathDraw.LineTo(p); 21 | } 22 | 23 | return false; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/SVGFiles/arc3.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 11 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegLinetoVerticalAbs.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegLinetoVerticalAbs : SVGPathSeg, ISVGDrawableSeg { 4 | private float _y = 0f; 5 | 6 | public float y { get { return this._y; } } 7 | 8 | public SVGPathSegLinetoVerticalAbs(float y) : base() { 9 | this._y = y; 10 | } 11 | 12 | public override Vector2 currentPoint { 13 | get { 14 | Vector2 _return = new Vector2(0f, 0f); 15 | SVGPathSeg _prevSeg = previousSeg; 16 | if(_prevSeg != null) { 17 | _return.x = _prevSeg.currentPoint.x; 18 | _return.y = this._y; 19 | } 20 | return _return; 21 | } 22 | } 23 | 24 | public void Render(SVGGraphicsPath _graphicsPath) { 25 | _graphicsPath.AddLineTo(currentPoint); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_EnablePCM: 1 18 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 19 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegLinetoHorizontalAbs.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegLinetoHorizontalAbs : SVGPathSeg, ISVGDrawableSeg { 4 | private float _x = 0f; 5 | 6 | public float x { get { return this._x; } } 7 | 8 | public SVGPathSegLinetoHorizontalAbs(float x) : base() { 9 | this._x = x; 10 | } 11 | 12 | public override Vector2 currentPoint { 13 | get { 14 | Vector2 _return = new Vector2(0f, 0f); 15 | SVGPathSeg _prevSeg = previousSeg; 16 | if(_prevSeg != null) { 17 | _return.x = this._x; 18 | _return.y = _prevSeg.currentPoint.y; 19 | } 20 | return _return; 21 | } 22 | } 23 | 24 | public void Render(SVGGraphicsPath _graphicsPath) { 25 | _graphicsPath.AddLineTo(currentPoint); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGCubicAbs.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGGCubicAbs : ISVGPathSegment { 4 | private readonly Vector2 p1; 5 | private readonly Vector2 p2; 6 | private readonly Vector2 point; 7 | 8 | public SVGGCubicAbs(Vector2 q1, Vector2 q2, Vector2 p) { 9 | p1 = q1; 10 | p2 = q2; 11 | point = p; 12 | } 13 | 14 | public void ExpandBounds(SVGGraphicsPath path) { 15 | path.ExpandBounds(p1); 16 | path.ExpandBounds(p2); 17 | path.ExpandBounds(point); 18 | } 19 | 20 | public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw) { 21 | pathDraw.CubicCurveTo(path.matrixTransform.Transform(p1), path.matrixTransform.Transform(p2), 22 | path.matrixTransform.Transform(point)); 23 | return false; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | m_Enabled: 0 7 | m_TestMode: 0 8 | m_TestEventUrl: 9 | m_TestConfigUrl: 10 | CrashReportingSettings: 11 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes 12 | m_Enabled: 0 13 | m_CaptureEditorExceptions: 1 14 | UnityPurchasingSettings: 15 | m_Enabled: 0 16 | m_TestMode: 0 17 | UnityAnalyticsSettings: 18 | m_Enabled: 0 19 | m_InitializeOnStartup: 1 20 | m_TestMode: 0 21 | m_TestEventUrl: 22 | m_TestConfigUrl: 23 | UnityAdsSettings: 24 | m_Enabled: 0 25 | m_InitializeOnStartup: 1 26 | m_TestMode: 0 27 | m_EnabledPlatforms: 4294967295 28 | m_IosGameId: 29 | m_AndroidGameId: 30 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegLinetoVerticalRel.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegLinetoVerticalRel : SVGPathSeg, ISVGDrawableSeg { 4 | private float _y = 0f; 5 | 6 | public float y { get { return this._y; } } 7 | 8 | public SVGPathSegLinetoVerticalRel(float y) : base() { 9 | this._y = y; 10 | } 11 | 12 | public override Vector2 currentPoint { 13 | get { 14 | Vector2 _return = new Vector2(0f, 0f); 15 | SVGPathSeg _prevSeg = previousSeg; 16 | if(_prevSeg != null) { 17 | _return.x = _prevSeg.currentPoint.x; 18 | _return.y = _prevSeg.currentPoint.y + this._y; 19 | } 20 | return _return; 21 | } 22 | } 23 | 24 | public void Render(SVGGraphicsPath _graphicsPath) { 25 | _graphicsPath.AddLineTo(currentPoint); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegLinetoHorizontalRel.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegLinetoHorizontalRel : SVGPathSeg, ISVGDrawableSeg { 4 | private float _x = 0f; 5 | 6 | public float x { get { return this._x; } } 7 | 8 | public SVGPathSegLinetoHorizontalRel(float x) : base() { 9 | this._x = x; 10 | } 11 | 12 | public override Vector2 currentPoint { 13 | get { 14 | Vector2 _return = new Vector2(0f, 0f); 15 | SVGPathSeg _prevSeg = previousSeg; 16 | if(_prevSeg != null) { 17 | _return.x = _prevSeg.currentPoint.x + this._x; 18 | _return.y = _prevSeg.currentPoint.y; 19 | } 20 | return _return; 21 | } 22 | } 23 | 24 | public void Render(SVGGraphicsPath _graphicsPath) { 25 | _graphicsPath.AddLineTo(currentPoint); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Assets/SVGFiles/rect1.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Assets/SVGFiles/rect1.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/GradientsNPatterns/SVGStopElement.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnitySVG; 3 | 4 | public class SVGStopElement { 5 | private readonly float _offset; 6 | private readonly SVGColor _stopColor; 7 | 8 | public float offset { get { return _offset; } } 9 | 10 | public SVGColor stopColor { get { return _stopColor; } } 11 | 12 | public SVGStopElement(Dictionary attrList) { 13 | _stopColor = new SVGColor(attrList.GetValue("stop-color")); 14 | string temp = attrList.GetValue("offset").Trim(); 15 | if(temp != "") { 16 | if(temp.EndsWith("%")) 17 | _offset = float.Parse(temp.TrimEnd(new[] { '%' }), System.Globalization.CultureInfo.InvariantCulture); 18 | else 19 | _offset = float.Parse(temp, System.Globalization.CultureInfo.InvariantCulture) * 100; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Utilities/SVGException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | public enum SVGExceptionType { 5 | WrongType, 6 | InvalidValue, 7 | MatrixNotInvertable 8 | } 9 | 10 | public class SVGException : DOMException { 11 | public SVGException(SVGExceptionType errorCode) : this(errorCode, String.Empty, null) { 12 | } 13 | 14 | public SVGException(SVGExceptionType errorCode, string message) : this(errorCode, message, null) { 15 | } 16 | 17 | public SVGException(SVGExceptionType errorCode, string message, Exception innerException) 18 | : base(message, innerException) { 19 | code = errorCode; 20 | } 21 | 22 | protected SVGException(SerializationInfo info, StreamingContext context) : base(info, context) { 23 | } 24 | 25 | private SVGExceptionType code; 26 | 27 | public new SVGExceptionType Code { get { return code; } } 28 | } 29 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegLinetoRel.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegLinetoRel : SVGPathSeg, ISVGDrawableSeg { 4 | private float _x = 0f, _y = 0f; 5 | 6 | public float x { get { return this._x; } } 7 | 8 | public float y { get { return this._y; } } 9 | 10 | public SVGPathSegLinetoRel(float x, float y) : base() { 11 | this._x = x; 12 | this._y = y; 13 | } 14 | 15 | public override Vector2 currentPoint { 16 | get { 17 | Vector2 _return = new Vector2(0f, 0f); 18 | SVGPathSeg _prevSeg = previousSeg; 19 | if(_prevSeg != null) { 20 | _return.x = _prevSeg.currentPoint.x + this._x; 21 | _return.y = _prevSeg.currentPoint.y + this._y; 22 | } 23 | return _return; 24 | } 25 | } 26 | 27 | public void Render(SVGGraphicsPath _graphicsPath) { 28 | _graphicsPath.AddLineTo(currentPoint); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegMovetoRel.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegMovetoRel : SVGPathSeg, ISVGDrawableSeg { 4 | private float _x = 0f, _y = 0f; 5 | 6 | public float x { get { return this._x; } } 7 | 8 | public float y { get { return this._y; } } 9 | 10 | public SVGPathSegMovetoRel(float x, float y) : base() { 11 | this._x = x; 12 | this._y = y; 13 | } 14 | 15 | public override Vector2 currentPoint { 16 | get { 17 | Vector2 _return = new Vector2(0f, 0f); 18 | SVGPathSeg _prevSeg = previousSeg; 19 | if(_prevSeg != null) { 20 | _return.x = _prevSeg.currentPoint.x + this._x; 21 | _return.y = _prevSeg.currentPoint.y + this._y; 22 | } 23 | return _return; 24 | } 25 | } 26 | 27 | public void Render(SVGGraphicsPath _graphicsPath) { 28 | _graphicsPath.AddMoveTo(currentPoint); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Assets/SVGFiles/polyline2.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | Example arcs01 - arc commands in path data 7 | 9 | 10 | 11 | 13 | 14 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Interface/RenderingEngine/ISVGPathDraw.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public interface ISVGPathDraw { 4 | void MoveTo(Vector2 p); 5 | 6 | void CircleTo(Vector2 p, float r); 7 | 8 | void EllipseTo(Vector2 p, float r1, float r2, float angle); 9 | 10 | void ArcTo(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, Vector2 p); 11 | 12 | void CubicCurveTo(Vector2 p1, Vector2 p2, Vector2 p); 13 | 14 | void QuadraticCurveTo(Vector2 p1, Vector2 p); 15 | 16 | void LineTo(Vector2 p); 17 | 18 | void Rect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4); 19 | 20 | void RoundedRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 p5, Vector2 p6, Vector2 p7, Vector2 p8, 21 | float r1, float r2, float angle); 22 | 23 | void Circle(Vector2 p, float r); 24 | 25 | void Ellipse(Vector2 p, float rx, float ry, float angle); 26 | 27 | void Polygon(Vector2[] points); 28 | } 29 | -------------------------------------------------------------------------------- /Assets/SVGFiles/circle1.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | Example arcs01 - arc commands in path data 7 | Picture of a pie chart with two pie wedges and 8 | a picture of a line with arc blips 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Assets/SVGFiles/arc2.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | Example arcs01 - arc commands in path data 7 | Picture of a pie chart with two pie wedges and 8 | a picture of a line with arc blips 9 | 10 | 12 | 14 | 16 | 18 | 19 | -------------------------------------------------------------------------------- /Assets/Demo/Material.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Material 10 | m_Shader: {fileID: 4800000, guid: d5e8e6383c1f3428ead6d80078cb8daf, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 5 13 | m_CustomRenderQueue: -1 14 | stringTagMap: {} 15 | m_SavedProperties: 16 | serializedVersion: 2 17 | m_TexEnvs: 18 | - first: 19 | name: _MainTex 20 | second: 21 | m_Texture: {fileID: 0} 22 | m_Scale: {x: 1, y: 1} 23 | m_Offset: {x: 0, y: 0} 24 | m_Floats: [] 25 | m_Colors: 26 | - first: 27 | name: _Color 28 | second: {r: 1, g: 1, b: 1, a: 1} 29 | - first: 30 | name: _MainTex_ST 31 | second: {r: 1, g: 1, b: 0, a: 0} 32 | --- !u!1002 &2100001 33 | EditorExtensionImpl: 34 | serializedVersion: 6 35 | -------------------------------------------------------------------------------- /Assets/SVGFiles/polyline1.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | Example arcs01 - arc commands in path data 7 | 9 | 10 | 11 | 13 | 14 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoQuadraticAbs.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegCurvetoQuadraticAbs : SVGPathSegCurvetoQuadratic, ISVGDrawableSeg { 4 | private float _x = 0f, _y = 0f, _x1 = 0f, _y1 = 0f; 5 | 6 | public float x { get { return this._x; } } 7 | 8 | public float y { get { return this._y; } } 9 | 10 | public float x1 { get { return this._x1; } } 11 | 12 | public float y1 { get { return this._y1; } } 13 | 14 | public SVGPathSegCurvetoQuadraticAbs(float x1, float y1, float x, float y) : base() { 15 | this._x = x; 16 | this._y = y; 17 | this._x1 = x1; 18 | this._y1 = y1; 19 | } 20 | 21 | public override Vector2 currentPoint { get { return new Vector2(this._x, this._y); } } 22 | 23 | public override Vector2 controlPoint1 { get { return new Vector2(this._x1, this._y1); } } 24 | 25 | public void Render(SVGGraphicsPath _graphicsPath) { 26 | _graphicsPath.AddQuadraticCurveTo(controlPoint1, currentPoint); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegArcAbs.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegArcAbs : SVGPathSeg, ISVGDrawableSeg { 4 | private float _x = 0f, _y = 0f, _r1 = 0f, _r2 = 0f, _angle = 0f; 5 | private bool _largeArcFlag = false, _sweepFlag = false; 6 | 7 | public float x { get { return this._x; } } 8 | 9 | public float y { get { return this._y; } } 10 | 11 | public SVGPathSegArcAbs(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, float x, float y) : base() { 12 | this._r1 = r1; 13 | this._r2 = r2; 14 | this._angle = angle; 15 | this._largeArcFlag = largeArcFlag; 16 | this._sweepFlag = sweepFlag; 17 | this._x = x; 18 | this._y = y; 19 | } 20 | 21 | public override Vector2 currentPoint { get { return new Vector2(this._x, this._y); } } 22 | 23 | public void Render(SVGGraphicsPath _graphicsPath) { 24 | _graphicsPath.AddArcTo(this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag, currentPoint); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicTypes/SVGColor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public enum SVGColorType : ushort { 4 | Unknown = 0, 5 | RGB = 1, 6 | Current = 2, 7 | None = 3 8 | } 9 | 10 | public struct SVGColor { 11 | public SVGColorType colorType; 12 | public Color color; 13 | 14 | public SVGColor(string colorString) { 15 | if(SVGColorExtractor.IsHexColor(colorString)) { 16 | colorType = SVGColorType.RGB; 17 | color = SVGColorExtractor.HexColor(colorString); 18 | } else if(SVGColorExtractor.IsConstName(colorString)) { 19 | colorType = SVGColorType.RGB; 20 | color = SVGColorExtractor.ConstColor(colorString); 21 | } else if(colorString.ToLower() == "current") { 22 | colorType = SVGColorType.Current; 23 | color = Color.black; 24 | } else if(colorString.ToLower() == "none") { 25 | colorType = SVGColorType.None; 26 | color = Color.black; 27 | } else { 28 | colorType = SVGColorType.Unknown; 29 | color = Color.black; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/GradientsNPatterns/SVGLinearGradientElement.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnitySVG; 3 | 4 | public class SVGLinearGradientElement : SVGGradientElement { 5 | private readonly SVGLength _x1, _y1, _x2, _y2; 6 | 7 | public SVGLength x1 { get { return _x1; } } 8 | 9 | public SVGLength y1 { get { return _y1; } } 10 | 11 | public SVGLength x2 { get { return _x2; } } 12 | 13 | public SVGLength y2 { get { return _y2; } } 14 | 15 | public SVGLinearGradientElement(SVGParser xmlImp, Dictionary attrList) : base(xmlImp, attrList) { 16 | string temp; 17 | temp = _attrList.GetValue("x1"); 18 | _x1 = new SVGLength((temp == "") ? "0%" : temp); 19 | 20 | temp = this._attrList.GetValue("y1"); 21 | _y1 = new SVGLength((temp == "") ? "0%" : temp); 22 | 23 | temp = this._attrList.GetValue("x2"); 24 | _x2 = new SVGLength((temp == "") ? "100%" : temp); 25 | 26 | temp = this._attrList.GetValue("y2"); 27 | _y2 = new SVGLength((temp == "") ? "0%" : temp); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicShapes/SVGCircleElement.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnitySVG; 3 | 4 | public class SVGCircleElement : SVGBasicElement { 5 | private readonly SVGLength _cx, _cy, _r; 6 | 7 | public SVGLength cx { get { return _cx; } } 8 | 9 | public SVGLength cy { get { return _cy; } } 10 | 11 | public SVGLength r { get { return _r; } } 12 | 13 | public SVGCircleElement(Dictionary attrList, 14 | SVGTransformList inheritTransformList, 15 | SVGPaintable inheritPaintable, 16 | SVGGraphics render) : base(attrList, inheritTransformList, inheritPaintable, render) { 17 | _cx = new SVGLength(attrList.GetValue("cx")); 18 | _cy = new SVGLength(attrList.GetValue("cy")); 19 | _r = new SVGLength(attrList.GetValue("r")); 20 | } 21 | 22 | protected override void CreateGraphicsPath() { 23 | _graphicsPath = new SVGGraphicsPath(); 24 | _graphicsPath.Add(this); 25 | _graphicsPath.transformList = summaryTransformList; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegList.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public class SVGPathSegList { 4 | private List _segList; 5 | 6 | public SVGPathSegList(int size) { 7 | _segList = new List(size); 8 | } 9 | 10 | public int Count { get { return _segList.Count; } } 11 | 12 | public void Clear() { 13 | this._segList.Clear(); 14 | } 15 | 16 | public SVGPathSeg GetItem(int index) { 17 | if(index < 0 || index > _segList.Count) 18 | return null; 19 | return (SVGPathSeg)this._segList[index]; 20 | } 21 | 22 | public SVGPathSeg AppendItem(SVGPathSeg newItem) { 23 | this._segList.Add(newItem); 24 | SetList(newItem); 25 | return newItem; 26 | } 27 | 28 | internal SVGPathSeg GetPreviousSegment(SVGPathSeg seg) { 29 | int index = this._segList.IndexOf(seg); 30 | if(index <= 0) 31 | return null; 32 | else 33 | return (SVGPathSeg)GetItem(index - 1); 34 | } 35 | 36 | private void SetList(SVGPathSeg newItem) { 37 | if(newItem != null) 38 | newItem.SetList(this); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGArcAbs.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Profiling; 3 | 4 | public class SVGGArcAbs : ISVGPathSegment { 5 | private readonly Vector2 point; 6 | private readonly float r1; 7 | private readonly float r2; 8 | private readonly float angle; 9 | private readonly bool largeArcFlag; 10 | private readonly bool sweepFlag; 11 | 12 | public SVGGArcAbs(float r1, float r2, float angle, 13 | bool largeArcFlag, bool sweepFlag, Vector2 p) { 14 | this.r1 = r1; 15 | this.r2 = r2; 16 | this.angle = angle; 17 | this.largeArcFlag = largeArcFlag; 18 | this.sweepFlag = sweepFlag; 19 | point = p; 20 | } 21 | 22 | public void ExpandBounds(SVGGraphicsPath path) { 23 | int r = (int)r1 + (int)r2; 24 | path.ExpandBounds(point, r, r); 25 | } 26 | 27 | public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw) { 28 | Profiler.BeginSample("SVGGArcAbs.Render"); 29 | pathDraw.ArcTo(r1, r2, path.transformAngle + angle, largeArcFlag, sweepFlag, path.matrixTransform.Transform(point)); 30 | Profiler.EndSample(); 31 | return false; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Assets/SVGFiles/test1.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | Example radgrad01 - fill a rectangle by referencing a 7 | radial gradient paint server 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # =============== # 2 | # Unity generated # 3 | # =============== # 4 | # temporary files that you do not want to share with other users 5 | Temp/ 6 | Obj/ 7 | UnityGenerated/ 8 | Library/ 9 | # optional, but you likely do not want to store 10 | # your builds in your git repo due to size 11 | Builds/ 12 | # ===================================== # 13 | # Visual Studio / MonoDevelop generated # 14 | # ===================================== # 15 | # these are generated by Mono itself are specific to the user and machine 16 | # sharing these with others in your repo will lead to issues 17 | ExportedObj/ 18 | *.svd 19 | *.userprefs 20 | *.csproj 21 | *.pidb 22 | *.suo 23 | #*.sln 24 | *.user 25 | *.unityproj 26 | *.booproj 27 | packages/ 28 | # ============ # 29 | # OS generated # 30 | # ============ # 31 | # Mac OS X 32 | .DS_Store 33 | .DS_Store? 34 | ._* 35 | .Spotlight-V100 36 | .Trashes 37 | Icon? 38 | ehthumbs.db 39 | Thumbs.db 40 | 41 | # EXTRA 42 | InspectorExpandedItems.asset 43 | EditorUserBuildSettings.asset 44 | Assembly-CSharp.pidb 45 | Assembly-CSharp-Editor.pidb 46 | Assembly-UnityScript.pidb 47 | Assembly-UnityScript-Editor.pidb 48 | 49 | # Project-Specific Items 50 | SVG_Stuff/ 51 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoQuadraticSmoothAbs.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegCurvetoQuadraticSmoothAbs : SVGPathSegCurvetoQuadratic, ISVGDrawableSeg { 4 | private float _x = 0f, _y = 0f; 5 | 6 | public float x { get { return this._x; } } 7 | 8 | public float y { get { return this._y; } } 9 | 10 | public SVGPathSegCurvetoQuadraticSmoothAbs(float x, float y) : base() { 11 | this._x = x; 12 | this._y = y; 13 | } 14 | 15 | public override Vector2 currentPoint { get { return new Vector2(this._x, this._y); } } 16 | 17 | public override Vector2 controlPoint1 { 18 | get { 19 | Vector2 _return = new Vector2(0f, 0f); 20 | SVGPathSeg _prevSeg = previousSeg; 21 | if(_prevSeg != null) { 22 | Vector2 t_currP = previousPoint; 23 | Vector2 t_prevCP2 = ((SVGPathSegCurvetoQuadratic)_prevSeg).controlPoint1; 24 | Vector2 t_P = t_currP - t_prevCP2; 25 | _return = t_currP + t_P; 26 | } 27 | return _return; 28 | } 29 | } 30 | 31 | public void Render(SVGGraphicsPath _graphicsPath) { 32 | _graphicsPath.AddQuadraticCurveTo(controlPoint1, currentPoint); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Utilities/LiteStack.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | // A simple stack implementation to get around the fact that using 4 | // System.Collections.Generic.Stack pulls in an extra DLL on the webplayer. 5 | public class LiteStack { 6 | private int idx = 0; 7 | private readonly List stack; 8 | 9 | public LiteStack() { 10 | stack = new List(); 11 | } 12 | 13 | public LiteStack(int cap) { 14 | stack = new List(cap); 15 | } 16 | 17 | public void Push(T obj) { 18 | idx++; 19 | if(idx > stack.Count) 20 | stack.Add(obj); 21 | else 22 | stack[idx - 1] = obj; 23 | } 24 | 25 | public T Pop() { 26 | T tmp = Peek(); 27 | if(idx > 0) { 28 | idx--; 29 | stack[idx] = default(T); 30 | } 31 | return tmp; 32 | } 33 | 34 | public T Peek() { 35 | if(idx > 0) 36 | return stack[idx - 1]; 37 | return default(T); 38 | } 39 | 40 | public int Count { 41 | get { return idx; } 42 | } 43 | 44 | public void Clear() { 45 | stack.Clear(); 46 | idx = 0; 47 | } 48 | 49 | public int Capacity { 50 | get { return stack.Capacity; } 51 | set { stack.Capacity = value; } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegArcRel.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegArcRel : SVGPathSeg, ISVGDrawableSeg { 4 | private float _x = 0f, _y = 0f, _r1 = 0f, _r2 = 0f, _angle = 0f; 5 | private bool _largeArcFlag = false, _sweepFlag = false; 6 | 7 | public float x { get { return this._x; } } 8 | 9 | public float y { get { return this._y; } } 10 | 11 | public SVGPathSegArcRel(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, float x, float y) : base() { 12 | this._r1 = r1; 13 | this._r2 = r2; 14 | this._angle = angle; 15 | this._largeArcFlag = largeArcFlag; 16 | this._sweepFlag = sweepFlag; 17 | this._x = x; 18 | this._y = y; 19 | } 20 | 21 | public override Vector2 currentPoint { 22 | get { 23 | Vector2 _return = new Vector2(0f, 0f); 24 | SVGPathSeg _prevSeg = previousSeg; 25 | if(_prevSeg != null) { 26 | _return.x = _prevSeg.currentPoint.x + this._x; 27 | _return.y = _prevSeg.currentPoint.y + this._y; 28 | } 29 | return _return; 30 | } 31 | } 32 | 33 | public void Render(SVGGraphicsPath _graphicsPath) { 34 | _graphicsPath.AddArcTo(this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag, currentPoint); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicShapes/SVGEllipseElement.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnitySVG; 3 | 4 | public class SVGEllipseElement : SVGBasicElement { 5 | private readonly SVGLength _cx, _cy, _rx, _ry; 6 | 7 | public SVGLength cx { get { return _cx; } } 8 | 9 | public SVGLength cy { get { return _cy; } } 10 | 11 | public SVGLength rx { get { return _rx; } } 12 | 13 | public SVGLength ry { get { return _ry; } } 14 | 15 | public SVGEllipseElement(Dictionary attrList, 16 | SVGTransformList inheritTransformList, 17 | SVGPaintable inheritPaintable, 18 | SVGGraphics render) : base(attrList, inheritTransformList, inheritPaintable, render) { 19 | _cx = new SVGLength(attrList.GetValue("cx")); 20 | _cy = new SVGLength(attrList.GetValue("cy")); 21 | _rx = new SVGLength(attrList.GetValue("rx")); 22 | _ry = new SVGLength(attrList.GetValue("ry")); 23 | currentTransformList = new SVGTransformList(attrList.GetValue("transform")); 24 | } 25 | 26 | protected override void CreateGraphicsPath() { 27 | _graphicsPath = new SVGGraphicsPath(); 28 | _graphicsPath.Add(this); 29 | _graphicsPath.transformList = summaryTransformList; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/GradientsNPatterns/SVGRadialGradientElement.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnitySVG; 3 | 4 | public class SVGRadialGradientElement : SVGGradientElement { 5 | private readonly SVGLength _cx, _cy, _r, _fx, _fy; 6 | 7 | // TODO: Does C# have auto properties? 8 | public SVGLength cx { get { return _cx; } } 9 | 10 | public SVGLength cy { get { return _cy; } } 11 | 12 | public SVGLength r { get { return _r; } } 13 | 14 | public SVGLength fx { get { return _fx; } } 15 | 16 | public SVGLength fy { get { return _fy; } } 17 | 18 | public SVGRadialGradientElement(SVGParser xmlImp, Dictionary attrList) : base(xmlImp, attrList) { 19 | // TODO: Override GetValue to return `null` and use `||`. 20 | string temp = attrList.GetValue("cx"); 21 | _cx = new SVGLength((temp == "") ? "50%" : temp); 22 | 23 | temp = attrList.GetValue("cy"); 24 | _cy = new SVGLength((temp == "") ? "50%" : temp); 25 | 26 | temp = attrList.GetValue("r"); 27 | _r = new SVGLength((temp == "") ? "50%" : temp); 28 | 29 | temp = attrList.GetValue("fx"); 30 | _fx = new SVGLength((temp == "") ? "50%" : temp); 31 | 32 | temp = attrList.GetValue("fy"); 33 | _fy = new SVGLength((temp == "") ? "50%" : temp); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoCubicAbs.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegCurvetoCubicAbs : SVGPathSegCurvetoCubic, ISVGDrawableSeg { 4 | private float _x = 0f, _y = 0f, _x1 = 0f, _y1 = 0f, _x2 = 0f, _y2 = 0f; 5 | 6 | public float x { get { return this._x; } } 7 | 8 | public float y { get { return this._y; } } 9 | 10 | public float x1 { get { return this._x1; } } 11 | 12 | public float y1 { get { return this._y1; } } 13 | 14 | public float x2 { get { return this._x2; } } 15 | 16 | public float y2 { get { return this._y2; } } 17 | 18 | public SVGPathSegCurvetoCubicAbs(float x1, float y1, float x2, float y2, float x, float y) : base() { 19 | this._x = x; 20 | this._y = y; 21 | this._x1 = x1; 22 | this._y1 = y1; 23 | this._x2 = x2; 24 | this._y2 = y2; 25 | } 26 | 27 | public override Vector2 currentPoint { get { return new Vector2(this._x, this._y); } } 28 | 29 | public override Vector2 controlPoint1 { get { return new Vector2(this._x1, this._y1); } } 30 | 31 | public override Vector2 controlPoint2 { get { return new Vector2(this._x2, this._y2); } } 32 | 33 | public void Render(SVGGraphicsPath _graphicsPath) { 34 | _graphicsPath.AddCubicCurveTo(controlPoint1, controlPoint2, currentPoint); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSeg.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public enum SVGPathSegTypes : ushort { 4 | Unknown = 0, 5 | Close = 1, 6 | MoveTo_Abs = 2, 7 | MoveTo_Rel = 3, 8 | LineTo_Abs = 4, 9 | LineTo_Rel = 5, 10 | CurveTo_Cubic_Abs = 6, 11 | CurveTo_Cubic_Rel = 7, 12 | CurveTo_Quadratic_Abs = 8, 13 | CurveTo_Quadratic_Rel = 9, 14 | Arc_Abs = 10, 15 | Arc_Rel = 11, 16 | LineTo_Horizontal_Abs = 12, 17 | LineTo_Horizontal_Rel = 13, 18 | LineTo_Vertical_Abs = 14, 19 | LineTo_Vertical_Rel = 15, 20 | CurveTo_Cubic_Smooth_Abs = 16, 21 | CurveTo_Cubic_Smooth_Rel = 17, 22 | CurveTo_Quadratic_Smooth_Abs = 18, 23 | CurveTo_Quadratic_Smooth_Rel = 19 24 | } 25 | 26 | public abstract class SVGPathSeg { 27 | protected SVGPathSegList _segList; 28 | 29 | internal void SetList(SVGPathSegList segList) { 30 | this._segList = segList; 31 | } 32 | 33 | public SVGPathSeg previousSeg { get { return _segList.GetPreviousSegment(this); } } 34 | 35 | public abstract Vector2 currentPoint { get; } 36 | 37 | public Vector2 previousPoint { 38 | get { 39 | Vector2 _return = new Vector2(0f, 0f); 40 | SVGPathSeg _prevSeg = previousSeg; 41 | if(_prevSeg != null) 42 | _return = _prevSeg.currentPoint; 43 | return _return; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/RenderingDevices/SVGDeviceFast.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGDeviceFast : ISVGDevice { 4 | private Texture2D _texture; 5 | 6 | private int _width; 7 | private int _height; 8 | 9 | public int Width { get { return _width; } } 10 | 11 | public int Height { get { return _height; } } 12 | 13 | private Color _color = Color.white; 14 | private Color[] pixels; 15 | 16 | public void SetDevice(int width, int height) { 17 | _width = width; 18 | _height = height; 19 | if(pixels == null || _width != width || _height != height) 20 | pixels = new Color[_width * _height]; 21 | } 22 | 23 | public void SetPixel(int x, int y) { 24 | if((x >= 0) && (x < _width) && (y >= 0) && (y < _height)) 25 | pixels[y * _height + (_width - x) - 1] = _color; 26 | } 27 | 28 | public Color GetPixel(int x, int y) { 29 | return pixels[y * _height + x]; 30 | } 31 | 32 | public void SetColor(Color color) { 33 | _color = color; 34 | } 35 | 36 | public Texture2D Render() { 37 | if(_texture == null) { 38 | _texture = new Texture2D(_width, _height, TextureFormat.RGB24, false); 39 | _texture.hideFlags = HideFlags.HideAndDontSave; 40 | } 41 | _texture.SetPixels(pixels); 42 | _texture.Apply(); 43 | return _texture; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Utilities/DOMException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | public enum DOMExceptionType { 5 | IndexSizeErr, 6 | DomstringSizeErr, 7 | HierarchyRequestErr, 8 | WrongDocumentErr, 9 | InvalidCharacterErr, 10 | NoDataAllowedErr, 11 | NoModificationAllowedErr, 12 | NotFoundErr, 13 | NotSupportedErr, 14 | InuseAttributeErr, 15 | InvalidStateErr, 16 | SyntaxErr, 17 | InvalidModificationErr, 18 | NamespaceErr, 19 | InvalidAccessErr 20 | } 21 | 22 | [Serializable] 23 | public class DOMException : Exception { 24 | protected DOMException(string msg, Exception innerException) : base(msg, innerException) { 25 | } 26 | 27 | public DOMException(DOMExceptionType code) : this(code, String.Empty) { 28 | } 29 | 30 | public DOMException(DOMExceptionType code, string msg) : this(code, msg, null) { 31 | } 32 | 33 | public DOMException(DOMExceptionType code, 34 | string msg, 35 | Exception innerException) : base(msg, innerException) { 36 | this.code = code; 37 | } 38 | 39 | protected DOMException(SerializationInfo info, 40 | StreamingContext context) : base(info, context) { 41 | } 42 | 43 | private DOMExceptionType code; 44 | 45 | public DOMExceptionType Code { 46 | get { return code; } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Assets/SVGFiles/radgrad1.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | Example radgrad01 - fill a rectangle by referencing a 7 | radial gradient paint server 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /bin/format_code: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | BASE_DIR=$( 6 | cd "$(dirname "$(readlink "$0" || echo "$0")")/.." 7 | /bin/pwd 8 | ) 9 | 10 | # TODO: Find a solution for when the optional indicator on a type is used on the same line as the ternary operator, 11 | # TODO: triggering an AStyle bug in which it thinks the indicator is an operator. 12 | # TODO: E.G. The following: 13 | # TODO: public SVGColor? strokeColor { get { return IsStroke() ? _strokeColor : null; } } 14 | # TODO: Gets reformatted to: 15 | # TODO: public SVGColor ? strokeColor { get { return IsStroke() ? _strokeColor : null; } } 16 | astyle \ 17 | -n \ 18 | --mode=cs \ 19 | --recursive "${BASE_DIR}/Assets/*.cs" \ 20 | --exclude="${BASE_DIR}/Assets/UnityGUIExtensions" \ 21 | --exclude="${BASE_DIR}/Assets/Editor/UnityREPL" \ 22 | --style=google \ 23 | --indent=spaces=2 \ 24 | --lineend=linux \ 25 | --remove-brackets \ 26 | --keep-one-line-blocks \ 27 | --keep-one-line-statements \ 28 | --convert-tabs \ 29 | --min-conditional-indent=2 \ 30 | --max-instatement-indent=80 \ 31 | --unpad-paren \ 32 | --unpad-method-prefix \ 33 | --indent-classes \ 34 | --indent-labels \ 35 | --indent-namespaces \ 36 | --indent-preproc-block \ 37 | --indent-preproc-define \ 38 | --remove-brackets \ 39 | --align-pointer=type \ 40 | --align-reference=type \ 41 | --pad-oper 42 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicShapes/SVGRectElement.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnitySVG; 3 | 4 | public class SVGRectElement : SVGBasicElement { 5 | private readonly SVGLength _x, _y, _width, _height, _rx, _ry; 6 | 7 | public SVGLength x { get { return _x; } } 8 | 9 | public SVGLength y { get { return _y; } } 10 | 11 | public SVGLength width { get { return _width; } } 12 | 13 | public SVGLength height { get { return _height; } } 14 | 15 | public SVGLength rx { get { return _rx; } } 16 | 17 | public SVGLength ry { get { return _ry; } } 18 | 19 | public SVGRectElement(Dictionary attrList, 20 | SVGTransformList inheritTransformList, 21 | SVGPaintable inheritPaintable, 22 | SVGGraphics render) : base(attrList, inheritTransformList, inheritPaintable, render) { 23 | _x = new SVGLength(attrList.GetValue("x")); 24 | _y = new SVGLength(attrList.GetValue("y")); 25 | _width = new SVGLength(attrList.GetValue("width")); 26 | _height = new SVGLength(attrList.GetValue("height")); 27 | _rx = new SVGLength(attrList.GetValue("rx")); 28 | _ry = new SVGLength(attrList.GetValue("ry")); 29 | } 30 | 31 | protected override void CreateGraphicsPath() { 32 | _graphicsPath = new SVGGraphicsPath(); 33 | 34 | _graphicsPath.Add(this); 35 | _graphicsPath.transformList = summaryTransformList; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoCubicSmoothAbs.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegCurvetoCubicSmoothAbs : SVGPathSegCurvetoCubic, ISVGDrawableSeg { 4 | private float _x = 0f, _y = 0f, _x2 = 0f, _y2 = 0f; 5 | 6 | public float x { get { return this._x; } } 7 | 8 | public float y { get { return this._y; } } 9 | 10 | public float x2 { get { return this._x2; } } 11 | 12 | public float y2 { get { return this._y2; } } 13 | 14 | public SVGPathSegCurvetoCubicSmoothAbs(float x2, float y2, float x, float y) : base() { 15 | this._x = x; 16 | this._y = y; 17 | this._x2 = x2; 18 | this._y2 = y2; 19 | } 20 | 21 | public override Vector2 currentPoint { get { return new Vector2(this._x, this._y); } } 22 | 23 | public override Vector2 controlPoint1 { 24 | get { 25 | Vector2 _return = new Vector2(0f, 0f); 26 | SVGPathSeg _prevSeg = previousSeg; 27 | if(_prevSeg != null) { 28 | Vector2 t_currP = previousPoint; 29 | Vector2 t_prevCP2 = ((SVGPathSegCurvetoCubic)_prevSeg).controlPoint2; 30 | Vector2 t_P = t_currP - t_prevCP2; 31 | _return = t_currP + t_P; 32 | } 33 | return _return; 34 | } 35 | } 36 | 37 | public override Vector2 controlPoint2 { get { return new Vector2(this._x2, this._y2); } } 38 | 39 | public void Render(SVGGraphicsPath _graphicsPath) { 40 | _graphicsPath.AddCubicCurveTo(controlPoint1, controlPoint2, currentPoint); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_MinPenetrationForPenalty: 0.01 17 | m_BaumgarteScale: 0.2 18 | m_BaumgarteTimeOfImpactScale: 0.75 19 | m_TimeToSleep: 0.5 20 | m_LinearSleepTolerance: 0.01 21 | m_AngularSleepTolerance: 2 22 | m_QueriesHitTriggers: 1 23 | m_QueriesStartInColliders: 1 24 | m_ChangeStopsCallbacks: 0 25 | m_AlwaysShowColliders: 0 26 | m_ShowColliderSleep: 1 27 | m_ShowColliderContacts: 0 28 | m_ShowColliderAABB: 0 29 | m_ContactArrowScale: 0.2 30 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 31 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 32 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 33 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 34 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 35 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoQuadraticSmoothRel.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegCurvetoQuadraticSmoothRel : SVGPathSegCurvetoQuadratic, ISVGDrawableSeg { 4 | private float _x = 0f, _y = 0f; 5 | 6 | public float x { get { return this._x; } } 7 | 8 | public float y { get { return this._y; } } 9 | 10 | public SVGPathSegCurvetoQuadraticSmoothRel(float x, float y) : base() { 11 | this._x = x; 12 | this._y = y; 13 | } 14 | //================================================================================ 15 | public override Vector2 currentPoint { 16 | get { 17 | Vector2 _return = new Vector2(0f, 0f); 18 | SVGPathSeg _prevSeg = previousSeg; 19 | if(_prevSeg != null) { 20 | _return.x = _prevSeg.currentPoint.x + this._x; 21 | _return.y = _prevSeg.currentPoint.y + this._y; 22 | } 23 | return _return; 24 | } 25 | } 26 | 27 | public override Vector2 controlPoint1 { 28 | get { 29 | Vector2 _return = new Vector2(0f, 0f); 30 | SVGPathSeg _prevSeg = previousSeg; 31 | if(_prevSeg != null) { 32 | Vector2 t_currP = previousPoint; 33 | Vector2 t_prevCP2 = ((SVGPathSegCurvetoQuadratic)_prevSeg).controlPoint1; 34 | Vector2 t_P = t_currP - t_prevCP2; 35 | _return = t_currP + t_P; 36 | } 37 | return _return; 38 | } 39 | } 40 | 41 | public void Render(SVGGraphicsPath _graphicsPath) { 42 | _graphicsPath.AddQuadraticCurveTo(controlPoint1, currentPoint); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoQuadraticRel.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegCurvetoQuadraticRel : SVGPathSegCurvetoQuadratic, ISVGDrawableSeg { 4 | private float _x = 0f, _y = 0f, _x1 = 0f, _y1 = 0f; 5 | 6 | public float x { get { return this._x; } } 7 | 8 | public float y { get { return this._y; } } 9 | 10 | public float x1 { get { return this._x1; } } 11 | 12 | public float y1 { get { return this._y1; } } 13 | 14 | public SVGPathSegCurvetoQuadraticRel(float x1, float y1, float x, float y) : base() { 15 | this._x = x; 16 | this._y = y; 17 | this._x1 = x1; 18 | this._y1 = y1; 19 | } 20 | 21 | public override Vector2 currentPoint { 22 | get { 23 | Vector2 _return = new Vector2(0f, 0f); 24 | SVGPathSeg _prevSeg = previousSeg; 25 | if(_prevSeg != null) { 26 | _return.x = _prevSeg.currentPoint.x + this._x; 27 | _return.y = _prevSeg.currentPoint.y + this._y; 28 | } 29 | return _return; 30 | } 31 | } 32 | 33 | public override Vector2 controlPoint1 { 34 | get { 35 | Vector2 _return = new Vector2(0f, 0f); 36 | SVGPathSeg _prevSeg = previousSeg; 37 | if(_prevSeg != null) { 38 | _return.x = _prevSeg.currentPoint.x + this._x1; 39 | _return.y = _prevSeg.currentPoint.y + this._y1; 40 | } 41 | return _return; 42 | } 43 | } 44 | 45 | public void Render(SVGGraphicsPath _graphicsPath) { 46 | _graphicsPath.AddQuadraticCurveTo(controlPoint1, currentPoint); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicShapes/SVGPolylineElement.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | using UnitySVG; 4 | 5 | public class SVGPolylineElement : SVGBasicElement { 6 | private readonly List _listPoints; 7 | 8 | public List listPoints { get { return _listPoints; } } 9 | 10 | public SVGPolylineElement(Dictionary attrList, 11 | SVGTransformList inheritTransformList, 12 | SVGPaintable inheritPaintable, 13 | SVGGraphics render) : base(attrList, inheritTransformList, inheritPaintable, render) { 14 | _listPoints = ExtractPoints(attrList.GetValue("points")); 15 | } 16 | 17 | private static List ExtractPoints(string inputText) { 18 | List _return = new List(); 19 | string[] _lstStr = SVGStringExtractor.ExtractTransformValue(inputText); 20 | 21 | int len = _lstStr.Length; 22 | for(int i = 0; i < len - 1; i++) { 23 | string value1 = _lstStr[i]; 24 | string value2 = _lstStr[i + 1]; 25 | SVGLength _length1 = new SVGLength(value1); 26 | SVGLength _length2 = new SVGLength(value2); 27 | Vector2 _point = new Vector2(_length1.value, _length2.value); 28 | _return.Add(_point); 29 | i++; 30 | } 31 | return _return; 32 | } 33 | 34 | protected override void CreateGraphicsPath() { 35 | _graphicsPath = new SVGGraphicsPath(); 36 | _graphicsPath.Add(this); 37 | _graphicsPath.transformList = summaryTransformList; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicShapes/SVGPolygonElement.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | using UnitySVG; 4 | 5 | public class SVGPolygonElement : SVGBasicElement { 6 | private readonly List _listPoints; 7 | 8 | public List listPoints { get { return _listPoints; } } 9 | 10 | public SVGPolygonElement(Dictionary attrList, 11 | SVGTransformList inheritTransformList, 12 | SVGPaintable inheritPaintable, 13 | SVGGraphics render) : base(attrList, inheritTransformList, inheritPaintable, render) { 14 | _listPoints = ExtractPoints(attrList.GetValue("points")); 15 | } 16 | 17 | private static List ExtractPoints(string inputText) { 18 | List _return = new List(); 19 | string[] _lstStr = SVGStringExtractor.ExtractTransformValue(inputText); 20 | 21 | int len = _lstStr.Length; 22 | 23 | for(int i = 0; i < len - 1; i++) { 24 | string value1 = _lstStr[i]; 25 | string value2 = _lstStr[i + 1]; 26 | SVGLength _length1 = new SVGLength(value1); 27 | SVGLength _length2 = new SVGLength(value2); 28 | Vector2 _point = new Vector2(_length1.value, _length2.value); 29 | _return.Add(_point); 30 | i++; 31 | } 32 | return _return; 33 | } 34 | 35 | protected override void CreateGraphicsPath() { 36 | _graphicsPath = new SVGGraphicsPath(); 37 | 38 | _graphicsPath.Add(this); 39 | _graphicsPath.transformList = summaryTransformList; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implement.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Profiling; 3 | 4 | public class Implement { 5 | private TextAsset _SVGFile; 6 | private Texture2D _texture; 7 | private readonly SVGGraphics _graphics; 8 | private SVGDocument _svgDocument; 9 | 10 | public Implement(TextAsset svgFile, ISVGDevice device) { 11 | _SVGFile = svgFile; 12 | _graphics = new SVGGraphics(device); 13 | } 14 | 15 | private void CreateEmptySVGDocument() { 16 | _svgDocument = new SVGDocument(_SVGFile.text, _graphics); 17 | } 18 | 19 | public void StartProcess() { 20 | Profiler.BeginSample("SVG.Implement.StartProcess[CreateEmptySVGDocument]"); 21 | CreateEmptySVGDocument(); 22 | Profiler.EndSample(); 23 | Profiler.BeginSample("SVG.Implement.StartProcess[GetRootElement]"); 24 | SVGSVGElement _rootSVGElement = _svgDocument.RootElement; 25 | Profiler.EndSample(); 26 | Profiler.BeginSample("SVG.Implement.StartProcess[ClearCanvas]"); 27 | _graphics.SetColor(Color.white); 28 | Profiler.EndSample(); 29 | Profiler.BeginSample("SVG.Implement.StartProcess[RenderSVGElement]"); 30 | _rootSVGElement.Render(); 31 | Profiler.EndSample(); 32 | Profiler.BeginSample("SVG.Implement.StartProcess[RenderGraphics]"); 33 | _texture = _graphics.Render(); 34 | Profiler.EndSample(); 35 | } 36 | 37 | public void NewSVGFile(TextAsset svgFile) { 38 | _SVGFile = svgFile; 39 | } 40 | 41 | public Texture2D GetTexture() { 42 | if(_texture == null) 43 | return new Texture2D(0, 0, TextureFormat.ARGB32, false); 44 | return _texture; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Assets/Demo/Invoke.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Diagnostics; 3 | using UnityEngine; 4 | 5 | [RequireComponent(typeof(Renderer))] 6 | [DisallowMultipleComponent()] 7 | public class Invoke : MonoBehaviour { 8 | public TextAsset SVGFile = null; 9 | [Tooltip("Use a faster rendering approach that takes notably more memory.")] 10 | public bool fastRenderer = false; 11 | 12 | [Space(15)] 13 | public TextureWrapMode wrapMode = TextureWrapMode.Clamp; 14 | public FilterMode filterMode = FilterMode.Trilinear; 15 | [Range(0, 9)] 16 | public int anisoLevel = 9; 17 | 18 | private void Start() { 19 | //yield return new WaitForSeconds(0.1f); 20 | if(SVGFile != null) { 21 | Stopwatch w = new Stopwatch(); 22 | 23 | w.Reset(); 24 | w.Start(); 25 | ISVGDevice device; 26 | if(fastRenderer) 27 | device = new SVGDeviceFast(); 28 | else 29 | device = new SVGDeviceSmall(); 30 | var implement = new Implement(SVGFile, device); 31 | w.Stop(); 32 | long c = w.ElapsedMilliseconds; 33 | 34 | w.Reset(); 35 | w.Start(); 36 | implement.StartProcess(); 37 | w.Stop(); 38 | long p = w.ElapsedMilliseconds; 39 | 40 | w.Reset(); 41 | w.Start(); 42 | var myRenderer = GetComponent(); 43 | var result = implement.GetTexture(); 44 | result.wrapMode = wrapMode; 45 | result.filterMode = filterMode; 46 | result.anisoLevel = anisoLevel; 47 | myRenderer.material.mainTexture = result; 48 | w.Stop(); 49 | long r = w.ElapsedMilliseconds; 50 | UnityEngine.Debug.LogFormat("Construction: {0} ms, Processing: {1} ms, Rendering: {2} ms", c, p, r); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /UnitySVG.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": ".", 5 | "folder_exclude_patterns": [ 6 | ".git", 7 | ".paket", 8 | "obj", 9 | "packages", 10 | "Temp", 11 | "Library", 12 | "ProjectSettings" 13 | ], 14 | "file_exclude_patterns": [ 15 | ".git", 16 | "*.sublime-workspace", 17 | "*.userprefs", 18 | "*.sln", 19 | "*.pidb", 20 | "*.csproj", 21 | "*.unityproj", 22 | "*.booproj", 23 | "*.meta" 24 | ] 25 | } 26 | ], 27 | "settings": { 28 | "tab_size": 2, 29 | "translate_tabs_to_spaces": true, 30 | "trim_trailing_white_space_on_save": true, 31 | "ensure_newline_at_eof_on_save": true, 32 | "rulers": [120], 33 | 34 | "AStyleFormatter": { 35 | "autoformat_on_save": true, 36 | 37 | "options_default": { 38 | "style": "google", 39 | 40 | "indent": "spaces", 41 | "indent-spaces": 2, 42 | "lineend": "linux", 43 | "convert-tabs": true, 44 | 45 | "indent-classes": true, 46 | "indent-labels": true, 47 | "indent-namespaces": true, 48 | "indent-preproc-block": true, 49 | "indent-preproc-define": true, 50 | 51 | "align-pointer": "type", 52 | "align-reference": "type", 53 | "remove-brackets": true, 54 | "keep-one-line-blocks": true, 55 | "keep-one-line-statements": true, 56 | 57 | "min-conditional-indent": 2, 58 | "max-instatement-indent": 80, 59 | 60 | "unpad-paren": true, 61 | "unpad-method-prefix": true, 62 | "pad-oper": true, 63 | "pad-header": false 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicShapes/SVGLineElement.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | using UnitySVG; 4 | 5 | public class SVGLineElement : SVGTransformable, ISVGDrawable { 6 | private SVGLength _x1, _y1, _x2, _y2; 7 | private readonly SVGGraphics _render; 8 | private readonly SVGPaintable _paintable; 9 | 10 | public SVGLength x1 { get { return _x1; } } 11 | 12 | public SVGLength y1 { get { return _y1; } } 13 | 14 | public SVGLength x2 { get { return _x2; } } 15 | 16 | public SVGLength y2 { get { return _y2; } } 17 | 18 | public SVGLineElement(Dictionary attrList, 19 | SVGTransformList inheritTransformList, 20 | SVGPaintable inheritPaintable, 21 | SVGGraphics render) : base(inheritTransformList) { 22 | _paintable = new SVGPaintable(inheritPaintable, attrList); 23 | _render = render; 24 | _x1 = new SVGLength(attrList.GetValue("x1")); 25 | _y1 = new SVGLength(attrList.GetValue("y1")); 26 | _x2 = new SVGLength(attrList.GetValue("x2")); 27 | _y2 = new SVGLength(attrList.GetValue("y2")); 28 | } 29 | 30 | public void BeforeRender(SVGTransformList transformList) { 31 | inheritTransformList = transformList; 32 | } 33 | 34 | public void Render() { 35 | if(_paintable.strokeColor == null) 36 | return; 37 | Matrix2x3 _matrix = transformMatrix; 38 | float _width = _paintable.strokeWidth; 39 | _render.StrokeLineCap = _paintable.strokeLineCap; 40 | 41 | Vector2 p1 = _matrix.Transform(new Vector2(_x1.value, _y1.value)); 42 | Vector2 p2 = _matrix.Transform(new Vector2(_x2.value, _y2.value)); 43 | 44 | _render.Line(p1, p2, _paintable.strokeColor, _width); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/CoordinateTransformUnits/SVGTransformList.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | public class SVGTransformList { 4 | private readonly List _listTransform; 5 | 6 | public int Count { get { return _listTransform.Count; } } 7 | 8 | private Matrix2x3 _totalMatrix; 9 | 10 | public Matrix2x3 totalMatrix { 11 | get { 12 | if(_totalMatrix == null) { 13 | _totalMatrix = new Matrix2x3(); 14 | for(int i = 0; i < _listTransform.Count; ++i) 15 | _totalMatrix.Multiply(_listTransform[i].matrix); 16 | } 17 | return _totalMatrix; 18 | } 19 | } 20 | 21 | public SVGTransformList() { 22 | _listTransform = new List(); 23 | } 24 | 25 | public SVGTransformList(int capacity) { 26 | _listTransform = new List(capacity); 27 | } 28 | 29 | public SVGTransformList(string listString) { 30 | _listTransform = SVGStringExtractor.ExtractTransformList(listString); 31 | } 32 | 33 | public void Clear() { 34 | _listTransform.Clear(); 35 | _totalMatrix = null; 36 | } 37 | 38 | public void AppendItem(SVGTransform newItem) { 39 | _listTransform.Add(newItem); 40 | _totalMatrix = null; 41 | } 42 | 43 | public void AppendItems(SVGTransformList newListItem) { 44 | _listTransform.AddRange(newListItem._listTransform); 45 | _totalMatrix = null; 46 | } 47 | 48 | public SVGTransform this[int index] { 49 | get { 50 | if((index < 0) || (index >= _listTransform.Count)) 51 | throw new DOMException(DOMExceptionType.IndexSizeErr); 52 | return _listTransform[index]; 53 | } 54 | } 55 | 56 | public SVGTransform Consolidate() { 57 | return new SVGTransform(totalMatrix); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Assets/SVGFiles/lines1.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | 10 | 12 | 14 | 16 | 18 | 19 | 20 | 21 | 23 | 25 | 27 | 29 | 31 | 32 | 33 | 34 | 36 | 38 | 40 | 42 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2007-2015, Jon Frisby, and other contributors 2 | http://github.com/MrJoy/UnitySVG 3 | 4 | Copyright (C) 2006, The Savage Project and it's contributors 5 | http://savage-project.org/ 6 | 7 | Copyright (c) 2002-2003, The Sharp Vector Graphics project 8 | http://sourceforge.net/projects/svgdomcsharp 9 | 10 | All Rights Reserved. 11 | 12 | Redistribution and use in source and binary forms, with or without 13 | modification, are permitted provided that the following conditions are met: 14 | 15 | 1. Redistribution of source code must retain the above copyright notice, 16 | this list of conditions and the following disclaimer. 17 | 18 | 2. Redistribution in binary form must reproduce the above copyright 19 | notice, this list of conditions and the following disclaimer in the 20 | documentation and/or other materials provided with the distribution. 21 | 22 | 3. Neither the name The Savage Project, SavageSVG, Sharp Vector Graphics 23 | project, nor the names of any contributors may be used to endorse or 24 | promote products derived from this software without specific prior 25 | written permission. 26 | 27 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 31 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 | POSSIBILITY OF SUCH DAMAGE. 38 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/DocumentStructure/SVGGElement.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | using UnitySVG; 4 | 5 | public class SVGGElement : SVGTransformable, ISVGDrawable { 6 | private readonly List _elementList = new List(); 7 | private readonly SVGGraphics _render; 8 | private readonly SVGPaintable _paintable; 9 | 10 | public SVGGElement(SVGParser xmlImp, 11 | SVGTransformList inheritTransformList, 12 | SVGPaintable inheritPaintable, 13 | SVGGraphics render) : base(inheritTransformList) { 14 | _render = render; 15 | Dictionary attrList = xmlImp.Node.Attributes; 16 | _paintable = new SVGPaintable(inheritPaintable, attrList); 17 | currentTransformList = new SVGTransformList(attrList.GetValue("transform")); 18 | xmlImp.GetElementList(_elementList, _paintable, _render, summaryTransformList); 19 | } 20 | 21 | public void BeforeRender(SVGTransformList transformList) { 22 | inheritTransformList = transformList; 23 | for(int i = 0; i < _elementList.Count; ++i) { 24 | ISVGDrawable temp = _elementList[i]; 25 | if(temp != null) 26 | temp.BeforeRender(summaryTransformList); 27 | } 28 | } 29 | 30 | public void Render() { 31 | Color _color = Color.black; 32 | bool use_color = false; 33 | if(_paintable.IsFill() && !_paintable.IsLinearGradiantFill()) { 34 | _color = _paintable.fillColor.Value.color; 35 | use_color = true; 36 | } else if(_paintable.strokeColor != null) { 37 | _color = _paintable.strokeColor.Value.color; 38 | use_color = true; 39 | } 40 | 41 | for(int i = 0; i < _elementList.Count; i++) { 42 | ISVGDrawable temp = _elementList[i]; 43 | if(temp != null) { 44 | if(use_color) 45 | _render.SetColor(_color); 46 | temp.Render(); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Assets/SVGFiles/lineargradient1.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | Example polygon01 - star and hexagon 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 29 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Assets/SVGFiles/lineargradient1.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | Example polygon01 - star and hexagon 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 29 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Assets/SVGFiles/test2.txt: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/RenderingDevices/SVGDeviceSmall.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | // TODO: Confirm that there's actually value in this. I suspect it only appears to be smaller due to how Unity's 4 | // TODO: profiler is accounting for things. Things that may impact this: 5 | // TODO: * Whether texture is marked as readable. 6 | // TODO: * Whether rendering pipeline is GLES or Metal (not sure about analogues on the Direct3D front). 7 | // TODO: * Specifically, whether or not semantics require the GL stack to keep a local copy of the texture data in 8 | // TODO: host RAM to avoid clobbering the GPU if the GL app writes to that area again. 9 | // TODO: * Internal representation of texture (24bpp vs. 32bpp). 10 | public class SVGDeviceSmall : ISVGDevice { 11 | private Texture2D _texture; 12 | 13 | private int _width; 14 | private int _height; 15 | 16 | public int Width { get { return _width; } } 17 | 18 | public int Height { get { return _height; } } 19 | 20 | private Color _color = Color.white; 21 | 22 | public void SetDevice(int width, int height) { 23 | SetDevice(width, height, false, false); 24 | } 25 | 26 | public void SetDevice(int width, int height, bool mipmaps, bool linear) { 27 | if(_texture == null) { 28 | _texture = new Texture2D(width, height, TextureFormat.RGB24, mipmaps, linear); 29 | _texture.hideFlags = HideFlags.HideAndDontSave; 30 | _width = width; 31 | _height = height; 32 | } 33 | } 34 | 35 | public void SetPixel(int x, int y) { 36 | if((x >= 0) && (x < _width) && (y >= 0) && (y < _height)) 37 | _texture.SetPixel(_width - x, y, _color); 38 | } 39 | 40 | public Color GetPixel(int x, int y) { 41 | return _texture.GetPixel(x, y); 42 | } 43 | 44 | public void SetColor(Color color) { 45 | _color.r = color.r; 46 | _color.g = color.g; 47 | _color.b = color.b; 48 | } 49 | 50 | public Texture2D Render() { 51 | _texture.Apply(); 52 | return _texture; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoCubicSmoothRel.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegCurvetoCubicSmoothRel : SVGPathSegCurvetoCubic, ISVGDrawableSeg { 4 | private float _x = 0f, _y = 0f, _x2 = 0f, _y2 = 0f; 5 | 6 | public float x { get { return this._x; } } 7 | 8 | public float y { get { return this._y; } } 9 | 10 | public float x2 { get { return this._x2; } } 11 | 12 | public float y2 { get { return this._y2; } } 13 | 14 | public SVGPathSegCurvetoCubicSmoothRel(float x2, float y2, float x, float y) : base() { 15 | this._x = x; 16 | this._y = y; 17 | this._x2 = x2; 18 | this._y2 = y2; 19 | } 20 | 21 | public override Vector2 currentPoint { 22 | get { 23 | Vector2 _return = new Vector2(0f, 0f); 24 | SVGPathSeg _prevSeg = previousSeg; 25 | if(_prevSeg != null) { 26 | _return.x = _prevSeg.currentPoint.x + this._x; 27 | _return.y = _prevSeg.currentPoint.y + this._y; 28 | } 29 | return _return; 30 | } 31 | } 32 | 33 | public override Vector2 controlPoint1 { 34 | get { 35 | Vector2 _return = new Vector2(0f, 0f); 36 | SVGPathSeg _prevSeg = previousSeg; 37 | if(_prevSeg != null) { 38 | Vector2 t_currP = previousPoint; 39 | Vector2 t_prevCP2 = ((SVGPathSegCurvetoCubic)_prevSeg).controlPoint2; 40 | Vector2 t_P = t_currP - t_prevCP2; 41 | _return = t_currP + t_P; 42 | } 43 | return _return; 44 | } 45 | } 46 | 47 | public override Vector2 controlPoint2 { 48 | get { 49 | Vector2 _return = new Vector2(0f, 0f); 50 | SVGPathSeg _prevSeg = previousSeg; 51 | if(_prevSeg != null) { 52 | _return.x = _prevSeg.currentPoint.x + this._x2; 53 | _return.y = _prevSeg.currentPoint.y + this._y2; 54 | } 55 | return _return; 56 | } 57 | } 58 | 59 | public void Render(SVGGraphicsPath _graphicsPath) { 60 | _graphicsPath.AddCubicCurveTo(controlPoint1, controlPoint2, currentPoint); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicTypes/SVGTransformable.cs: -------------------------------------------------------------------------------- 1 | public class SVGTransformable { 2 | private SVGTransformList _inheritTransformList; 3 | private SVGTransformList _currentTransformList; 4 | private SVGTransformList _summaryTransformList; 5 | 6 | protected SVGTransformable(SVGTransformList transformList) { 7 | inheritTransformList = transformList; 8 | } 9 | 10 | protected SVGTransformList inheritTransformList { 11 | get { return _inheritTransformList; } 12 | set { 13 | _inheritTransformList = value; 14 | // TODO: Measure if (and how much) redundant work is happening by doing this here. Consider a dirty state and 15 | // TODO: final-reconciliation-before-rendering pass. 16 | UpdateSummaryTransformList(); 17 | } 18 | } 19 | 20 | protected SVGTransformList currentTransformList { 21 | get { return _currentTransformList; } 22 | set { 23 | _currentTransformList = value; 24 | UpdateSummaryTransformList(); 25 | } 26 | } 27 | 28 | protected SVGTransformList summaryTransformList { get { return _summaryTransformList; } } 29 | 30 | protected void UpdateSummaryTransformList() { 31 | int c = 0; 32 | if(_inheritTransformList != null) 33 | c += _inheritTransformList.Count; 34 | if(_currentTransformList != null) 35 | c += _currentTransformList.Count; 36 | _summaryTransformList = new SVGTransformList(c); 37 | if(_inheritTransformList != null) 38 | _summaryTransformList.AppendItems(_inheritTransformList); 39 | if(_currentTransformList != null) 40 | _summaryTransformList.AppendItems(_currentTransformList); 41 | } 42 | 43 | public float transformAngle { 44 | get { 45 | float _angle = 0.0f; 46 | for(int i = 0; i < _summaryTransformList.Count; i++) { 47 | SVGTransform _temp = _summaryTransformList[i]; 48 | if(_temp.type == SVGTransformMode.Rotate) 49 | _angle += _temp.angle; 50 | } 51 | return _angle; 52 | } 53 | } 54 | 55 | protected Matrix2x3 transformMatrix { get { return summaryTransformList.Consolidate().matrix; } } 56 | } 57 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Paths/SVGPathSegCurvetoCubicRel.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGPathSegCurvetoCubicRel : SVGPathSegCurvetoCubic, ISVGDrawableSeg { 4 | private float _x = 0f, _y = 0f, _x1 = 0f, _y1 = 0f, _x2 = 0f, _y2 = 0f; 5 | 6 | public float x { get { return this._x; } } 7 | 8 | public float y { get { return this._y; } } 9 | 10 | public float x1 { get { return this._x1; } } 11 | 12 | public float y1 { get { return this._y1; } } 13 | 14 | public float x2 { get { return this._x2; } } 15 | 16 | public float y2 { get { return this._y2; } } 17 | 18 | public SVGPathSegCurvetoCubicRel(float x1, float y1, float x2, float y2, float x, float y) : base() { 19 | this._x = x; 20 | this._y = y; 21 | this._x1 = x1; 22 | this._y1 = y1; 23 | this._x2 = x2; 24 | this._y2 = y2; 25 | } 26 | 27 | public override Vector2 currentPoint { 28 | get { 29 | Vector2 _return = new Vector2(0f, 0f); 30 | SVGPathSeg _prevSeg = previousSeg; 31 | if(_prevSeg != null) { 32 | _return.x = _prevSeg.currentPoint.x + this._x; 33 | _return.y = _prevSeg.currentPoint.y + this._y; 34 | } 35 | return _return; 36 | } 37 | } 38 | 39 | public override Vector2 controlPoint1 { 40 | get { 41 | Vector2 _return = new Vector2(0f, 0f); 42 | SVGPathSeg _prevSeg = previousSeg; 43 | if(_prevSeg != null) { 44 | _return.x = _prevSeg.currentPoint.x + this._x1; 45 | _return.y = _prevSeg.currentPoint.y + this._y1; 46 | } 47 | return _return; 48 | } 49 | } 50 | 51 | public override Vector2 controlPoint2 { 52 | get { 53 | Vector2 _return = new Vector2(0f, 0f); 54 | SVGPathSeg _prevSeg = previousSeg; 55 | if(_prevSeg != null) { 56 | _return.x = _prevSeg.currentPoint.x + this._x2; 57 | _return.y = _prevSeg.currentPoint.y + this._y2; 58 | } 59 | return _return; 60 | } 61 | } 62 | 63 | public void Render(SVGGraphicsPath _graphicsPath) { 64 | _graphicsPath.AddCubicCurveTo(controlPoint1, controlPoint2, currentPoint); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicShapes/SVGBasicElement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace UnitySVG { 7 | public abstract class SVGBasicElement : SVGTransformable, ISVGDrawable { 8 | private readonly SVGGraphics _render; 9 | private readonly SVGPaintable _paintable; 10 | 11 | protected SVGGraphicsPath _graphicsPath; 12 | 13 | protected SVGBasicElement(Dictionary attrList, 14 | SVGTransformList inheritTransformList, 15 | SVGPaintable inheritPaintable, 16 | SVGGraphics render) : base(inheritTransformList) { 17 | _render = render; 18 | _paintable = new SVGPaintable(inheritPaintable, attrList); 19 | } 20 | 21 | protected abstract void CreateGraphicsPath(); 22 | 23 | private void Draw() { 24 | if(_paintable.strokeColor == null) 25 | return; 26 | 27 | _render.DrawPath(_graphicsPath, _paintable.strokeWidth, 28 | _paintable.strokeColor); 29 | } 30 | 31 | public void BeforeRender(SVGTransformList transformList) { 32 | inheritTransformList = transformList; 33 | } 34 | 35 | public void Render() { 36 | CreateGraphicsPath(); 37 | _render.StrokeLineCap = _paintable.strokeLineCap; 38 | _render.StrokeLineJoin = _paintable.strokeLineJoin; 39 | switch(_paintable.GetPaintType()) { 40 | case SVGPaintMethod.SolidGradientFill: 41 | _render.FillPath(_paintable.fillColor.Value, _graphicsPath); 42 | Draw(); 43 | break; 44 | case SVGPaintMethod.LinearGradientFill: { 45 | SVGLinearGradientBrush _linearGradBrush = _paintable.GetLinearGradientBrush(_graphicsPath); 46 | 47 | if(_linearGradBrush != null) 48 | _render.FillPath(_linearGradBrush, _graphicsPath); 49 | Draw(); 50 | break; 51 | } 52 | case SVGPaintMethod.RadialGradientFill: { 53 | SVGRadialGradientBrush _radialGradBrush = _paintable.GetRadialGradientBrush(_graphicsPath); 54 | 55 | if(_radialGradBrush != null) 56 | _render.FillPath(_radialGradBrush, _graphicsPath); 57 | Draw(); 58 | break; 59 | } 60 | case SVGPaintMethod.PathDraw: 61 | Draw(); 62 | break; 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/GradientsNPatterns/SVGGradientElement.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnitySVG; 3 | 4 | public enum SVGSpreadMethod : ushort { 5 | Unknown = 0, 6 | Pad = 1, 7 | Reflect = 2, 8 | Repeat = 3 9 | } 10 | 11 | public enum SVGGradientUnit : ushort { 12 | UserSpaceOnUse = 0, 13 | ObjectBoundingBox = 1 14 | } 15 | 16 | public class SVGGradientElement { 17 | private readonly SVGGradientUnit _gradientUnits; 18 | private readonly SVGSpreadMethod _spreadMethod; 19 | private readonly string _id; 20 | private readonly SVGParser _xmlImp; 21 | private readonly List _stopList; 22 | protected readonly Dictionary _attrList; 23 | 24 | public SVGGradientUnit gradientUnits { get { return _gradientUnits; } } 25 | 26 | public SVGSpreadMethod spreadMethod { get { return _spreadMethod; } } 27 | 28 | public string id { get { return _id; } } 29 | 30 | public List stopList { get { return _stopList; } } 31 | 32 | protected SVGGradientElement(SVGParser xmlImp, Dictionary attrList) { 33 | _attrList = attrList; 34 | _xmlImp = xmlImp; 35 | _stopList = new List(); 36 | _id = _attrList.GetValue("id"); 37 | _gradientUnits = SVGGradientUnit.ObjectBoundingBox; 38 | if(_attrList.GetValue("gradiantUnits") == "userSpaceOnUse") 39 | _gradientUnits = SVGGradientUnit.UserSpaceOnUse; 40 | 41 | //------ 42 | // TODO: It's probably a bug that the value is not innoculated for CaSe VaRiAtIoN in GetValue, below: 43 | _spreadMethod = SVGSpreadMethod.Pad; 44 | if(_attrList.GetValue("spreadMethod") == "reflect") 45 | _spreadMethod = SVGSpreadMethod.Reflect; 46 | else if(_attrList.GetValue("spreadMethod") == "repeat") 47 | _spreadMethod = SVGSpreadMethod.Repeat; 48 | 49 | GetElementList(); 50 | } 51 | 52 | protected void GetElementList() { 53 | bool exitFlag = false; 54 | while(!exitFlag && _xmlImp.Next()) { 55 | if(_xmlImp.Node is BlockCloseNode) { 56 | exitFlag = true; 57 | continue; 58 | } 59 | if(_xmlImp.Node.Name == SVGNodeName.Stop) 60 | _stopList.Add(new SVGStopElement(_xmlImp.Node.Attributes)); 61 | } 62 | } 63 | 64 | public SVGStopElement GetStopElement(int i) { 65 | if((i >= 0) && (i < _stopList.Count)) 66 | return _stopList[i]; 67 | return null; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 9 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} 38 | m_PreloadedShaders: [] 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 40 | type: 0} 41 | m_TierSettings_Tier1: 42 | renderingPath: 1 43 | useCascadedShadowMaps: 1 44 | m_TierSettings_Tier2: 45 | renderingPath: 1 46 | useCascadedShadowMaps: 1 47 | m_TierSettings_Tier3: 48 | renderingPath: 1 49 | useCascadedShadowMaps: 1 50 | m_DefaultRenderingPath: 1 51 | m_DefaultMobileRenderingPath: 1 52 | m_TierSettings: [] 53 | m_LightmapStripping: 0 54 | m_FogStripping: 0 55 | m_LightmapKeepPlain: 1 56 | m_LightmapKeepDirCombined: 1 57 | m_LightmapKeepDirSeparate: 1 58 | m_LightmapKeepDynamicPlain: 1 59 | m_LightmapKeepDynamicDirCombined: 1 60 | m_LightmapKeepDynamicDirSeparate: 1 61 | m_FogKeepLinear: 1 62 | m_FogKeepExp: 1 63 | m_FogKeepExp2: 1 64 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/BasicType/SVGGRect.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class SVGGRect : ISVGPathSegment { 4 | public readonly float x; 5 | public readonly float y; 6 | private readonly float width; 7 | private readonly float height; 8 | private readonly float rx; 9 | private readonly float ry; 10 | 11 | public SVGGRect(float x, float y, float width, float height, float rx, float ry) { 12 | this.x = x; 13 | this.y = y; 14 | this.width = width; 15 | this.height = height; 16 | this.rx = rx; 17 | this.ry = ry; 18 | } 19 | 20 | public void ExpandBounds(SVGGraphicsPath path) { 21 | path.ExpandBounds(x, y); 22 | path.ExpandBounds(x + width, y); 23 | path.ExpandBounds(x + width, y + height); 24 | path.ExpandBounds(x, y + height); 25 | } 26 | 27 | public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw) { 28 | Vector2 p1 = new Vector2(x, y), 29 | p2 = new Vector2(x + width, y), 30 | p3 = new Vector2(x + width, y + height), 31 | p4 = new Vector2(x, y + height); 32 | 33 | if(rx == 0.0f && ry == 0.0f) { 34 | p1 = path.matrixTransform.Transform(p1); 35 | p2 = path.matrixTransform.Transform(p2); 36 | p3 = path.matrixTransform.Transform(p3); 37 | p4 = path.matrixTransform.Transform(p4); 38 | 39 | pathDraw.Rect(p1, p2, p3, p4); 40 | } else { 41 | float t_rx = (rx == 0.0f) ? ry : rx; 42 | float t_ry = (ry == 0.0f) ? rx : ry; 43 | 44 | t_rx = (t_rx > (width * 0.5f - 2f)) ? (width * 0.5f - 2f) : t_rx; 45 | t_ry = (t_ry > (height * 0.5f - 2f)) ? (height * 0.5f - 2f) : t_ry; 46 | 47 | float angle = path.transformAngle; 48 | 49 | Vector2 t_p1 = path.matrixTransform.Transform(new Vector2(p1.x + t_rx, p1.y)); 50 | Vector2 t_p2 = path.matrixTransform.Transform(new Vector2(p2.x - t_rx, p2.y)); 51 | Vector2 t_p3 = path.matrixTransform.Transform(new Vector2(p2.x, p2.y + t_ry)); 52 | Vector2 t_p4 = path.matrixTransform.Transform(new Vector2(p3.x, p3.y - t_ry)); 53 | 54 | Vector2 t_p5 = path.matrixTransform.Transform(new Vector2(p3.x - t_rx, p3.y)); 55 | Vector2 t_p6 = path.matrixTransform.Transform(new Vector2(p4.x + t_rx, p4.y)); 56 | Vector2 t_p7 = path.matrixTransform.Transform(new Vector2(p4.x, p4.y - t_ry)); 57 | Vector2 t_p8 = path.matrixTransform.Transform(new Vector2(p1.x, p1.y + t_ry)); 58 | 59 | pathDraw.RoundedRect(t_p1, t_p2, t_p3, t_p4, t_p5, t_p6, t_p7, t_p8, t_rx, t_ry, angle); 60 | } 61 | return true; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/CoordinateTransformUnits/Matrix2x3.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | // TODO: Would it be beneficial to move to Unity's Matrix classes? 4 | public class Matrix2x3 { 5 | public float a, b, c, d, e, f; 6 | 7 | public Matrix2x3() : this(1, 0, 0, 1, 0, 0) { 8 | } 9 | 10 | public Matrix2x3(Matrix2x3 m) : this(m.a, m.b, m.c, m.d, m.e, m.f) { 11 | } 12 | 13 | public Matrix2x3(float a, float b, float c, float d, float e, float f) { 14 | SetValues(a, b, c, d, e, f); 15 | } 16 | 17 | public void SetValues(float a, float b, float c, float d, float e, float f) { 18 | this.a = a; 19 | this.b = b; 20 | this.c = c; 21 | this.d = d; 22 | this.e = e; 23 | this.f = f; 24 | } 25 | 26 | public void Multiply(Matrix2x3 secondMatrix) { 27 | float sa = secondMatrix.a, sb = secondMatrix.b, sc = secondMatrix.c, sd = secondMatrix.d, se = secondMatrix.e, 28 | sf = secondMatrix.f; 29 | SetValues(a * sa + c * sb, b * sa + d * sb, 30 | a * sc + c * sd, b * sc + d * sd, 31 | a * se + c * sf + e, b * se + d * sf + f); 32 | } 33 | 34 | public Matrix2x3 Inverse() { 35 | float det = a * d - c * b; 36 | if(det == 0) 37 | throw new SVGException(SVGExceptionType.MatrixNotInvertable); 38 | SetValues(d / det, -b / det, 39 | -c / det, a / det, 40 | (c * f - e * d) / det, (e * b - a * f) / det); 41 | return this; 42 | } 43 | 44 | public Matrix2x3 Scale(float scaleFactor) { 45 | SetValues(a * scaleFactor, b * scaleFactor, 46 | c * scaleFactor, d * scaleFactor, 47 | e, f); 48 | return this; 49 | } 50 | 51 | public Matrix2x3 ScaleNonUniform(float scaleFactorX, float scaleFactorY) { 52 | SetValues(a * scaleFactorX, b * scaleFactorX, 53 | c * scaleFactorY, d * scaleFactorY, 54 | e, f); 55 | return this; 56 | } 57 | 58 | public Matrix2x3 Rotate(float angle) { 59 | float ca = Mathf.Cos(angle * Mathf.Deg2Rad); 60 | float sa = Mathf.Sin(angle * Mathf.Deg2Rad); 61 | 62 | SetValues(a * ca + c * sa, b * ca + d * sa, 63 | c * ca - a * sa, d * ca - b * sa, 64 | e, f); 65 | return this; 66 | } 67 | 68 | public Matrix2x3 Translate(float x, float y) { 69 | SetValues(a, b, c, d, a * x + c * y + e, b * x + d * y + f); 70 | return this; 71 | } 72 | 73 | public Matrix2x3 SkewX(float angle) { 74 | float ta = Mathf.Tan(angle * Mathf.Deg2Rad); 75 | SetValues(a, b, 76 | c + a * ta, d + b * ta, 77 | e, f); 78 | return this; 79 | } 80 | 81 | public Matrix2x3 SkewY(float angle) { 82 | float ta = Mathf.Tan(angle * Mathf.Deg2Rad); 83 | SetValues(a + c * ta, b + d * ta, 84 | c, d, 85 | e, f); 86 | return this; 87 | } 88 | 89 | public Vector2 Transform(Vector2 point) { 90 | return new Vector2(a * point.x + c * point.y + e, b * point.x + d * point.y + f); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /.paket/paket.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | true 6 | 7 | true 8 | $(MSBuildThisFileDirectory) 9 | $(MSBuildThisFileDirectory)..\ 10 | /Library/Frameworks/Mono.framework/Commands/mono 11 | mono 12 | 13 | 14 | 15 | $(PaketToolsPath)paket.exe 16 | $(PaketToolsPath)paket.bootstrapper.exe 17 | "$(PaketExePath)" 18 | $(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)" 19 | "$(PaketBootStrapperExePath)" $(PaketBootStrapperCommandArgs) 20 | $(MonoPath) --runtime=v4.0.30319 $(PaketBootStrapperExePath) $(PaketBootStrapperCommandArgs) 21 | 22 | $(MSBuildProjectDirectory)\paket.references 23 | $(MSBuildStartupDirectory)\paket.references 24 | $(MSBuildProjectFullPath).paket.references 25 | $(PaketCommand) restore --references-files "$(PaketReferences)" 26 | $(PaketBootStrapperCommand) 27 | 28 | RestorePackages; $(BuildDependsOn); 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/DocumentStructure/SVGSVGElement.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Globalization; 3 | using UnityEngine; 4 | using UnitySVG; 5 | 6 | public class SVGSVGElement : SVGTransformable, ISVGDrawable { 7 | private SVGLength _width, _height; 8 | private Rect _viewport; 9 | private readonly Dictionary _attrList; 10 | private readonly List _elementList = new List(); 11 | private readonly SVGGraphics _render; 12 | 13 | public SVGSVGElement(SVGParser xmlImp, 14 | SVGTransformList inheritTransformList, 15 | SVGPaintable inheritPaintable, 16 | SVGGraphics r) : base(inheritTransformList) { 17 | _render = r; 18 | _attrList = xmlImp.Node.Attributes; 19 | var paintable = new SVGPaintable(inheritPaintable, _attrList); 20 | _width = new SVGLength(_attrList.GetValue("width")); 21 | _height = new SVGLength(_attrList.GetValue("height")); 22 | 23 | SetViewBox(); 24 | 25 | ViewBoxTransform(); 26 | 27 | SVGTransform temp = new SVGTransform(_cachedViewBoxTransform); 28 | SVGTransformList t_currentTransformList = new SVGTransformList(); 29 | t_currentTransformList.AppendItem(temp); 30 | currentTransformList = t_currentTransformList; // use setter only once, since it also updates other lists 31 | 32 | xmlImp.GetElementList(_elementList, paintable, _render, summaryTransformList); 33 | } 34 | 35 | public void BeforeRender(SVGTransformList transformList) { 36 | inheritTransformList = transformList; 37 | 38 | for(int i = 0; i < _elementList.Count; ++i) { 39 | ISVGDrawable temp = _elementList[i]; 40 | if(temp != null) 41 | temp.BeforeRender(summaryTransformList); 42 | } 43 | } 44 | 45 | public void Render() { 46 | _render.Size = new Vector2(_width.value, _height.value); 47 | for(int i = 0; i < _elementList.Count; ++i) { 48 | ISVGDrawable temp = _elementList[i]; 49 | if(temp != null) 50 | temp.Render(); 51 | } 52 | } 53 | 54 | private void SetViewBox() { 55 | string attr = _attrList.GetValue("viewBox"); 56 | if(!string.IsNullOrEmpty(attr)) { 57 | string[] _temp = SVGStringExtractor.ExtractTransformValue(attr); 58 | if(_temp.Length == 4) { 59 | float x = float.Parse(_temp[0], CultureInfo.InvariantCulture); 60 | float y = float.Parse(_temp[1], CultureInfo.InvariantCulture); 61 | float w = float.Parse(_temp[2], CultureInfo.InvariantCulture); 62 | float h = float.Parse(_temp[3], CultureInfo.InvariantCulture); 63 | _viewport = new Rect(x, y, w, h); 64 | } 65 | } 66 | } 67 | 68 | private Matrix2x3 _cachedViewBoxTransform; 69 | 70 | public Matrix2x3 ViewBoxTransform() { 71 | if(_cachedViewBoxTransform == null) { 72 | Matrix2x3 matrix = new Matrix2x3(); 73 | 74 | float x = 0.0f, y = 0.0f, w, h, attrWidth = _width.value, attrHeight = _height.value; 75 | 76 | if(!string.IsNullOrEmpty(_attrList.GetValue("viewBox"))) { 77 | Rect r = _viewport; 78 | x += -r.x; 79 | y += -r.y; 80 | w = r.width; 81 | h = r.height; 82 | } else { 83 | w = attrWidth; 84 | h = attrHeight; 85 | } 86 | 87 | float x_ratio = attrWidth / w, y_ratio = attrHeight / h; 88 | 89 | matrix = matrix.ScaleNonUniform(x_ratio, y_ratio); 90 | matrix = matrix.Translate(x, y); 91 | _cachedViewBoxTransform = matrix; 92 | } 93 | return _cachedViewBoxTransform; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/BasicTypes/SVGLength.cs: -------------------------------------------------------------------------------- 1 | public enum SVGLengthType : ushort { 2 | Unknown = 0, 3 | Number = 1, 4 | Percentage = 2, 5 | EMs = 3, 6 | EXs = 4, 7 | PX = 5, 8 | CM = 6, 9 | MM = 7, 10 | IN = 8, 11 | PT = 9, 12 | PC = 10, 13 | } 14 | 15 | public struct SVGLength { 16 | private SVGLengthType _unitType; 17 | private float _valueInSpecifiedUnits, _value; 18 | 19 | public float value { get { return _value; } } 20 | 21 | public SVGLengthType unitType { get { return _unitType; } } 22 | 23 | public SVGLength(SVGLengthType unitType, float valueInSpecifiedUnits) { 24 | _unitType = unitType; 25 | _valueInSpecifiedUnits = valueInSpecifiedUnits; 26 | _value = ConvertToPX(_valueInSpecifiedUnits, _unitType); 27 | } 28 | 29 | public SVGLength(float valueInSpecifiedUnits) { 30 | _unitType = SVGLengthType.Number; 31 | _valueInSpecifiedUnits = valueInSpecifiedUnits; 32 | _value = ConvertToPX(_valueInSpecifiedUnits, _unitType); 33 | } 34 | 35 | public SVGLength(string valueText) { 36 | float t_value = 0.0f; 37 | SVGLengthType t_type = SVGLengthType.Unknown; 38 | ExtractType(valueText, ref t_value, ref t_type); 39 | _unitType = t_type; 40 | _valueInSpecifiedUnits = t_value; 41 | _value = ConvertToPX(_valueInSpecifiedUnits, _unitType); 42 | } 43 | 44 | public void NewValueSpecifiedUnits(float valueInSpecifiedUnits) { 45 | _unitType = SVGLengthType.Unknown; 46 | _valueInSpecifiedUnits = valueInSpecifiedUnits; 47 | _value = ConvertToPX(_valueInSpecifiedUnits, _unitType); 48 | } 49 | 50 | public static float GetPXLength(string valueText) { 51 | float t_value = 0.0f; 52 | SVGLengthType t_type = SVGLengthType.Unknown; 53 | ExtractType(valueText, ref t_value, ref t_type); 54 | return ConvertToPX(t_value, t_type); 55 | } 56 | 57 | private static void ExtractType(string text, ref float value, ref SVGLengthType lengthType) { 58 | if(string.IsNullOrEmpty(text)) 59 | return; 60 | text = text.Trim(); 61 | int i; 62 | for(i = 0; i < text.Length; ++i) { 63 | char c = text[i]; 64 | if((('0' <= c) && (c <= '9')) || (c == '+') || (c == '-') || (c == '.') || (c == ' ')) 65 | continue; 66 | break; 67 | } 68 | 69 | var strValue = text.Substring(0, i); 70 | if(!string.IsNullOrEmpty(strValue)) { 71 | string unit = text.Substring(i); 72 | value = float.Parse(strValue, System.Globalization.CultureInfo.InvariantCulture); 73 | switch(unit.ToUpper()) { 74 | case "EM": lengthType = SVGLengthType.EMs; break; 75 | case "EX": lengthType = SVGLengthType.EXs; break; 76 | case "PX": lengthType = SVGLengthType.PX; break; 77 | case "CM": lengthType = SVGLengthType.CM; break; 78 | case "MM": lengthType = SVGLengthType.MM; break; 79 | case "IN": lengthType = SVGLengthType.IN; break; 80 | case "PT": lengthType = SVGLengthType.PT; break; 81 | case "PC": lengthType = SVGLengthType.PC; break; 82 | case "%": lengthType = SVGLengthType.Percentage; break; 83 | default: lengthType = SVGLengthType.Unknown; break; 84 | } 85 | } 86 | } 87 | 88 | private static float ConvertToPX(float value, SVGLengthType lengthType) { 89 | // TODO: Shouldn't PX-per- be a function of the render target size? 90 | switch(lengthType) { 91 | case SVGLengthType.IN: return value * 90.0f; 92 | case SVGLengthType.CM: return value * 35.43307f; 93 | case SVGLengthType.MM: return value * 3.543307f; 94 | case SVGLengthType.PT: return value * 1.25f; 95 | case SVGLengthType.PC: return value * 15.0f; 96 | default: return value; 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/Utilities/SVGStringExtractor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public static class SVGStringExtractor { 6 | //-------------------------------------------------- 7 | //Extract for Syntax: translate(700 200)rotate(-30) 8 | private static char[] splitPipe = new char[] { ')' }; 9 | 10 | public static List ExtractTransformList(string inputText) { 11 | List _return = new List(); 12 | 13 | string[] valuesStr = inputText.Split(splitPipe, StringSplitOptions.RemoveEmptyEntries); 14 | 15 | int len = valuesStr.Length; 16 | for(int i = 0; i < len; i++) { 17 | int vt1 = valuesStr[i].IndexOf('('); 18 | string _key = valuesStr[i].Substring(0, vt1).Trim(); 19 | string _value = valuesStr[i].Substring(vt1 + 1).Trim(); 20 | _return.Add(new SVGTransform(_key, _value)); 21 | } 22 | return _return; 23 | } 24 | 25 | //-------------------------------------------------- 26 | //Extract for Syntax: 700 200 -30 27 | private static char[] splitSpaceComma = new char[] { ' ', ',', '\n', '\t', '\r' }; 28 | 29 | //public static float[] ExtractTransformValueAsPX(string inputText) 30 | //{ 31 | // string[] tmp = ExtractTransformValue(inputText); 32 | // float[] values = new float[tmp.Length]; 33 | // for (int i = 0; i < values.Length; i++) 34 | // values[i] = SVGLength.GetPXLength(tmp[i]); 35 | // return values; 36 | //} 37 | 38 | public static string[] ExtractTransformValue(string inputText) { 39 | return inputText.Split(splitSpaceComma, StringSplitOptions.RemoveEmptyEntries); 40 | } 41 | 42 | //-------------------------------------------------- 43 | //Extract for Systax : M100 100 C200 100,... 44 | //private static readonly List _break = new List(); 45 | // WARNING: This method is NOT thread-safe due to use of static _break member! 46 | /*public static void ExtractPathSegList(string inputText, ref List charList, ref List valueList) 47 | { 48 | Profiler.BeginSample("SVGStringExtractor.ExtractPathSegList()"); 49 | _break.Clear(); 50 | for (int i = 0; i < inputText.Length; ++i) 51 | if (((inputText[i] >= 'a') && (inputText[i] <= 'z')) || ((inputText[i] >= 'A') && (inputText[i] <= 'Z'))) 52 | _break.Add(i); 53 | _break.Add(inputText.Length); 54 | charList.Capacity = _break.Count - 1; 55 | valueList.Capacity = _break.Count - 1; 56 | 57 | for (int i = 0; i < _break.Count - 1; ++i) 58 | { 59 | int _breakSpot1 = _break[i]; 60 | int _breakSpot2 = _break[i + 1]; 61 | charList.Add(inputText[_breakSpot1]); 62 | valueList.Add(inputText.Substring(_breakSpot1 + 1, _breakSpot2 - _breakSpot1 - 1)); 63 | } 64 | Profiler.EndSample(); 65 | }*/ 66 | 67 | //-------------------------------------------------- 68 | //Extract for Syntax: fill: #ffffff; stroke:#000000; stroke-width:0.172 69 | private static char[] splitColonSemicolon = new char[] { ':', ';', ' ', '\n', '\t', '\r' }; 70 | 71 | public static void ExtractStyleValue(string inputText, ref Dictionary dic) { 72 | string[] valuesStr = inputText.Split(splitColonSemicolon, StringSplitOptions.RemoveEmptyEntries); 73 | 74 | int len = valuesStr.Length - 1; 75 | for(int i = 0; i < len; i += 2) 76 | dic.Add(valuesStr[i], valuesStr[i + 1]); 77 | } 78 | 79 | //-------------------------------------------------- 80 | //Extract for Syntax: url(#identifier) 81 | public static string ExtractUrl4Gradient(string inputText) { 82 | string _return = ""; 83 | 84 | inputText = inputText 85 | .Replace('\n', ' ') 86 | .Replace('\t', ' ') 87 | .Replace('\r', ' ') 88 | .Replace(" ", ""); 89 | 90 | int vt1 = inputText.IndexOf("url(#"), 91 | vt2 = inputText.IndexOf(")"); 92 | if(vt2 < 0) 93 | vt2 = inputText.Length; 94 | 95 | _return = inputText.Substring(vt1 + 5, vt2 - vt1 - 5); 96 | 97 | return _return; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UnitySVG 2 | 3 | ## Overview 4 | 5 | UnitySVG is a library for reading SVG files and producing `Texture2D` objects from them at runtime. The intent is to allow some of one's art assets to be reduced considerably in terms of the net time needed before the user can begin playing the game. 6 | 7 | In order for this to be viable, three things must be true: 8 | 9 | * The net download size of the SVG code + SVG assets (or whatever preprocessed format we want to use) + the time needed to render the SVGs and compress them must be smaller than the download time using DXT textures directly when happening at some "average-user bandwidth" (undefined here, of course). 10 | * The resultant visual quality must be acceptable for a significant set of visual styles. (Both with regard to the complexity of SVG image that can be used and the result of runtime texture compression.) 11 | * The net user experience must be positive. (Long pauses == bad, swap thrashing == bad, etc.) 12 | 13 | On unity versions 2018.1 or later try using SVG importer by unity which provides more functionality; it can be installed into unity project by going into package manager -> Vector Graphics. More details can be found [here](https://docs.unity3d.com/Packages/com.unity.vectorgraphics@2.0/manual/index.html#using-vector-graphics) 14 | 15 | ## Compatibility 16 | 17 | A *very* limited subset of SVG is supported, specifically *excluding*: 18 | 19 | * Animation 20 | * Text 21 | * Fonts 22 | * ICC color profiles 23 | * Bindings 24 | * Compound documents 25 | * CSS 26 | * foreignObjects 27 | 28 | Essentially, only things involved in rendering static images are supported, excluding features related to clarity of the XML, "reuse", or whatnot. The principle workflow I had envisioned for this centered around (semi-)auto-generated conversions from raster to vector format, so some of the more high-level features of SVG were simply not relevant. 29 | 30 | 31 | ## Performance 32 | 33 | Pretty awful right now. See [benchmarks.txt](benchmarks.txt) for specifics. 34 | 35 | I strongly suggest installing and using [SVGO](https://github.com/svg/svgo) to optimize SVG files before use. 36 | 37 | 38 | ## History 39 | 40 | The initial version of the code is a modified version of [SavageSVG](https://github.com/codebutler/savagesvg) 41 | 42 | This fork offer major improvements in memory usage (as much as 500:1 in some extreme cases), though I have yet to appreciably improve either parsing or rendering times on hardware that isn't heavily memory-bound. 43 | 44 | 45 | ## License 46 | 47 | See [LICENSE](LICENSE) for more information. 48 | 49 | 50 | ## TODO 51 | 52 | Please note that it is unlikely _I_ will have time to do much of this, these are merely the things I see as necessary to achieving the goals above. I post this with my minor improvements for the daring to dabble with, and am willing to accept pull requests. 53 | 54 | * Serious performance optimizations, and further work on memory reduction. Some operations seem disproportionately slow, such as rendering of arc segments. 55 | * See about reusing relevant Unity classes (Vector2, Rect) where appropriate. 56 | * Document which variant/version of the SVG spec we most closely match, and significant deviations from it. 57 | * Rigorous regression/compatibility/performance testing (automated, of course). See: 58 | * [http://wiki.svg.org/index.php/Main_Page](http://wiki.svg.org/index.php/Main_Page) 59 | * [http://www.linuxrising.org/svg_test/test_big.html](http://www.linuxrising.org/svg_test/test_big.html) 60 | * [http://croczilla.com/bits_and_pieces/svg/samples/](http://croczilla.com/bits_and_pieces/svg/samples/) 61 | * Refactor the document model code to be cleanly / easily usable independent of an actual XML document. 62 | * Separate XML (and attribute!) parser that uses the SVG DOM API we construct. 63 | * Some support for foreignObjects to allow blending in noise textures and whatnot. (Definitely want to use GPU compositing for this...) 64 | * Use coroutines or threads (or a combination thereof) to make the rendering process be non-blocking. 65 | 66 | More ambitious ideas include: 67 | 68 | * See about using GPU for some operations? (Compositing, etc...) 69 | * See about implementing primitives like rendering of path segments and such on the GPU? 70 | 71 | 72 | ## Developing UnitySVG 73 | 74 | ### Workstation Setup 75 | 76 | #### OS X 77 | 78 | You need Mono. The best way to ensure you get this, plus have paths set up properly is to use [HomeBrew](http://brew.sh). 79 | 80 | ```bash 81 | brew install astyle mono 82 | ``` 83 | 84 | Make sure you add this to your `.profile` (or whatever file is appropriate to your shell), and restart your terminal: 85 | 86 | ```bash 87 | export MONO_GAC_PREFIX="/usr/local" 88 | ``` 89 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/SVG/DOM/CoordinateTransformUnits/SVGTransform.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | 4 | public enum SVGTransformMode : ushort { 5 | Unknown = 0, 6 | Matrix = 1, 7 | Translate = 2, 8 | Scale = 3, 9 | Rotate = 4, 10 | SkewX = 5, 11 | SkewY = 6 12 | } 13 | 14 | public class SVGTransform { 15 | private SVGTransformMode _type; 16 | private float _angle; 17 | 18 | public Matrix2x3 matrix { get; private set; } 19 | 20 | public float angle { 21 | get { 22 | switch(_type) { 23 | case SVGTransformMode.Rotate: 24 | case SVGTransformMode.SkewX: 25 | case SVGTransformMode.SkewY: 26 | return _angle; 27 | default: 28 | return 0.0f; 29 | } 30 | } 31 | } 32 | 33 | public SVGTransformMode type { get { return _type; } } 34 | 35 | public SVGTransform() { 36 | matrix = new Matrix2x3(); 37 | _type = SVGTransformMode.Matrix; 38 | } 39 | 40 | public SVGTransform(Matrix2x3 matrix) { 41 | _type = SVGTransformMode.Matrix; 42 | this.matrix = matrix; 43 | } 44 | 45 | public SVGTransform(string strKey, string strValue) { 46 | string[] valuesStr = SVGStringExtractor.ExtractTransformValue(strValue); 47 | int len = valuesStr.Length; 48 | float[] values = new float[len]; 49 | 50 | for(int i = 0; i < len; i++) 51 | values.SetValue(float.Parse(valuesStr[i], CultureInfo.InvariantCulture), i); 52 | switch(strKey) { 53 | case "translate": 54 | switch(len) { 55 | case 1: 56 | SetTranslate(values[0], 0); 57 | break; 58 | case 2: 59 | SetTranslate(values[0], values[1]); 60 | break; 61 | default: 62 | throw new ApplicationException("Wrong number of arguments in translate transform"); 63 | } 64 | break; 65 | case "rotate": 66 | switch(len) { 67 | case 1: 68 | SetRotate(values[0]); 69 | break; 70 | case 3: 71 | SetRotate(values[0], values[1], values[2]); 72 | break; 73 | default: 74 | throw new ApplicationException("Wrong number of arguments in rotate transform"); 75 | } 76 | break; 77 | case "scale": 78 | switch(len) { 79 | case 1: 80 | SetScale(values[0], values[0]); 81 | break; 82 | case 2: 83 | SetScale(values[0], values[1]); 84 | break; 85 | default: 86 | throw new ApplicationException("Wrong number of arguments in scale transform"); 87 | } 88 | break; 89 | case "skewX": 90 | if(len != 1) 91 | throw new ApplicationException("Wrong number of arguments in skewX transform"); 92 | SetSkewX(values[0]); 93 | break; 94 | case "skewY": 95 | if(len != 1) 96 | throw new ApplicationException("Wrong number of arguments in skewY transform"); 97 | SetSkewY(values[0]); 98 | break; 99 | case "matrix": 100 | if(len != 6) 101 | throw new ApplicationException("Wrong number of arguments in matrix transform"); 102 | SetMatrix( 103 | new Matrix2x3( 104 | values[0], 105 | values[1], 106 | values[2], 107 | values[3], 108 | values[4], 109 | values[5] 110 | )); 111 | break; 112 | default: 113 | _type = SVGTransformMode.Unknown; 114 | break; 115 | } 116 | } 117 | 118 | public void SetMatrix(Matrix2x3 m) { 119 | _type = SVGTransformMode.Matrix; 120 | matrix = m; 121 | } 122 | 123 | public void SetTranslate(float tx, float ty) { 124 | _type = SVGTransformMode.Translate; 125 | matrix = new Matrix2x3().Translate(tx, ty); 126 | } 127 | 128 | public void SetScale(float sx, float sy) { 129 | _type = SVGTransformMode.Scale; 130 | matrix = new Matrix2x3().ScaleNonUniform(sx, sy); 131 | } 132 | 133 | public void SetRotate(float rotateAngle) { 134 | _type = SVGTransformMode.Rotate; 135 | _angle = rotateAngle; 136 | matrix = new Matrix2x3().Rotate(rotateAngle); 137 | } 138 | 139 | public void SetRotate(float rotateAngle, float cx, float cy) { 140 | _type = SVGTransformMode.Rotate; 141 | _angle = rotateAngle; 142 | matrix = new Matrix2x3().Translate(cx, cy).Rotate(angle).Translate(-cx, -cy); 143 | } 144 | 145 | public void SetSkewX(float skewAngle) { 146 | _type = SVGTransformMode.SkewX; 147 | _angle = skewAngle; 148 | matrix = new Matrix2x3().SkewX(angle); 149 | } 150 | 151 | public void SetSkewY(float skewAngle) { 152 | _type = SVGTransformMode.SkewY; 153 | _angle = skewAngle; 154 | matrix = new Matrix2x3().SkewY(angle); 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 3 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Fastest 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 0 15 | shadowCascades: 1 16 | shadowDistance: 30 17 | shadowNearPlaneOffset: 2 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | blendWeights: 1 21 | textureQuality: 1 22 | anisotropicTextures: 0 23 | antiAliasing: 0 24 | softParticles: 0 25 | softVegetation: 0 26 | realtimeReflectionProbes: 0 27 | billboardsFaceCameraPosition: 0 28 | vSyncCount: 0 29 | lodBias: 0.3 30 | maximumLODLevel: 0 31 | particleRaycastBudget: 4 32 | asyncUploadTimeSlice: 2 33 | asyncUploadBufferSize: 4 34 | excludedTargetPlatforms: [] 35 | - serializedVersion: 2 36 | name: Fast 37 | pixelLightCount: 0 38 | shadows: 0 39 | shadowResolution: 0 40 | shadowProjection: 0 41 | shadowCascades: 1 42 | shadowDistance: 30 43 | shadowNearPlaneOffset: 2 44 | shadowCascade2Split: 0.33333334 45 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 46 | blendWeights: 2 47 | textureQuality: 0 48 | anisotropicTextures: 0 49 | antiAliasing: 0 50 | softParticles: 0 51 | softVegetation: 0 52 | realtimeReflectionProbes: 0 53 | billboardsFaceCameraPosition: 0 54 | vSyncCount: 0 55 | lodBias: 0.4 56 | maximumLODLevel: 0 57 | particleRaycastBudget: 16 58 | asyncUploadTimeSlice: 2 59 | asyncUploadBufferSize: 4 60 | excludedTargetPlatforms: [] 61 | - serializedVersion: 2 62 | name: Simple 63 | pixelLightCount: 1 64 | shadows: 1 65 | shadowResolution: 0 66 | shadowProjection: 0 67 | shadowCascades: 1 68 | shadowDistance: 30 69 | shadowNearPlaneOffset: 2 70 | shadowCascade2Split: 0.33333334 71 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 72 | blendWeights: 2 73 | textureQuality: 0 74 | anisotropicTextures: 1 75 | antiAliasing: 0 76 | softParticles: 0 77 | softVegetation: 0 78 | realtimeReflectionProbes: 0 79 | billboardsFaceCameraPosition: 0 80 | vSyncCount: 0 81 | lodBias: 0.7 82 | maximumLODLevel: 0 83 | particleRaycastBudget: 64 84 | asyncUploadTimeSlice: 2 85 | asyncUploadBufferSize: 4 86 | excludedTargetPlatforms: [] 87 | - serializedVersion: 2 88 | name: Good 89 | pixelLightCount: 2 90 | shadows: 2 91 | shadowResolution: 1 92 | shadowProjection: 0 93 | shadowCascades: 2 94 | shadowDistance: 100 95 | shadowNearPlaneOffset: 2 96 | shadowCascade2Split: 0.33333334 97 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 98 | blendWeights: 2 99 | textureQuality: 0 100 | anisotropicTextures: 1 101 | antiAliasing: 0 102 | softParticles: 0 103 | softVegetation: 1 104 | realtimeReflectionProbes: 1 105 | billboardsFaceCameraPosition: 1 106 | vSyncCount: 0 107 | lodBias: 1 108 | maximumLODLevel: 0 109 | particleRaycastBudget: 256 110 | asyncUploadTimeSlice: 2 111 | asyncUploadBufferSize: 4 112 | excludedTargetPlatforms: [] 113 | - serializedVersion: 2 114 | name: Beautiful 115 | pixelLightCount: 3 116 | shadows: 2 117 | shadowResolution: 2 118 | shadowProjection: 0 119 | shadowCascades: 2 120 | shadowDistance: 150 121 | shadowNearPlaneOffset: 2 122 | shadowCascade2Split: 0.33333334 123 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 124 | blendWeights: 4 125 | textureQuality: 0 126 | anisotropicTextures: 2 127 | antiAliasing: 2 128 | softParticles: 1 129 | softVegetation: 1 130 | realtimeReflectionProbes: 1 131 | billboardsFaceCameraPosition: 1 132 | vSyncCount: 0 133 | lodBias: 1.5 134 | maximumLODLevel: 0 135 | particleRaycastBudget: 1024 136 | asyncUploadTimeSlice: 2 137 | asyncUploadBufferSize: 4 138 | excludedTargetPlatforms: [] 139 | - serializedVersion: 2 140 | name: Fantastic 141 | pixelLightCount: 4 142 | shadows: 2 143 | shadowResolution: 2 144 | shadowProjection: 0 145 | shadowCascades: 4 146 | shadowDistance: 300 147 | shadowNearPlaneOffset: 2 148 | shadowCascade2Split: 0.33333334 149 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 150 | blendWeights: 4 151 | textureQuality: 0 152 | anisotropicTextures: 2 153 | antiAliasing: 2 154 | softParticles: 1 155 | softVegetation: 1 156 | realtimeReflectionProbes: 1 157 | billboardsFaceCameraPosition: 1 158 | vSyncCount: 0 159 | lodBias: 2 160 | maximumLODLevel: 0 161 | particleRaycastBudget: 4096 162 | asyncUploadTimeSlice: 2 163 | asyncUploadBufferSize: 4 164 | excludedTargetPlatforms: [] 165 | m_PerPlatformDefaultQuality: 166 | Android: 2 167 | BlackBerry: 2 168 | GLES Emulation: 5 169 | PS3: 5 170 | PS4: 5 171 | PSM: 5 172 | PSP2: 5 173 | Samsung TV: 2 174 | Standalone: 5 175 | Tizen: 2 176 | WP8: 5 177 | Web: 5 178 | WebGL: 3 179 | Windows Store Apps: 5 180 | XBOX360: 5 181 | XboxOne: 5 182 | iPhone: 2 183 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/XMLParser/SVGParser.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | public enum SVGNodeName { 7 | Rect, 8 | Line, 9 | Circle, 10 | Ellipse, 11 | PolyLine, 12 | Polygon, 13 | Path, 14 | SVG, 15 | G, 16 | LinearGradient, 17 | RadialGradient, 18 | Defs, 19 | Title, 20 | Desc, 21 | Stop 22 | } 23 | 24 | public class Node { 25 | public SVGNodeName Name; 26 | public Dictionary Attributes; 27 | 28 | public Node(SVGNodeName n, Dictionary a) { 29 | Name = n; 30 | Attributes = a; 31 | } 32 | } 33 | 34 | public class InlineNode : Node { 35 | public InlineNode(SVGNodeName n, Dictionary a) : base(n, a) { 36 | } 37 | } 38 | 39 | public class BlockOpenNode : Node { 40 | public BlockOpenNode(SVGNodeName n, Dictionary a) : base(n, a) { 41 | } 42 | } 43 | 44 | public class BlockCloseNode : Node { 45 | public BlockCloseNode(SVGNodeName n, Dictionary a) : base(n, a) { 46 | } 47 | } 48 | 49 | public class SVGParser : SmallXmlParser.IContentHandler { 50 | private SmallXmlParser _parser = new SmallXmlParser(); 51 | 52 | /***********************************************************************************/ 53 | public SVGParser() { 54 | } 55 | 56 | public SVGParser(string text) { 57 | _parser.Parse(new StringReader(text), this); 58 | } 59 | 60 | /***********************************************************************************/ 61 | private List Stream = new List(); 62 | private int idx = 0; 63 | 64 | public Node Node { get { return Stream[idx]; } } 65 | 66 | public bool Next() { 67 | idx++; 68 | return !IsEOF; 69 | } 70 | 71 | public bool IsEOF { get { return idx >= Stream.Count; } } 72 | 73 | public void OnStartParsing(SmallXmlParser parser) { 74 | idx = 0; 75 | } 76 | 77 | public void OnInlineElement(string name, Dictionary attrs) { 78 | Stream.Add(new InlineNode(Lookup(name), new Dictionary(attrs))); 79 | } 80 | 81 | public void OnStartElement(string name, Dictionary attrs) { 82 | Stream.Add(new BlockOpenNode(Lookup(name), new Dictionary(attrs))); 83 | } 84 | 85 | public void OnEndElement(string name) { 86 | Stream.Add(new BlockCloseNode(Lookup(name), new Dictionary())); 87 | } 88 | 89 | public void GetElementList(List elementList, SVGPaintable paintable, 90 | SVGGraphics render, SVGTransformList summaryTransformList) { 91 | bool exitFlag = false; 92 | while(!exitFlag && Next()) { 93 | if(Node is BlockCloseNode) { 94 | exitFlag = true; 95 | continue; 96 | } 97 | 98 | switch(Node.Name) { 99 | case SVGNodeName.Rect: elementList.Add(new SVGRectElement(Node.Attributes, summaryTransformList, paintable, render)); break; 100 | case SVGNodeName.Line: elementList.Add(new SVGLineElement(Node.Attributes, summaryTransformList, paintable, render)); break; 101 | case SVGNodeName.Circle: elementList.Add(new SVGCircleElement(Node.Attributes, summaryTransformList, paintable, render)); break; 102 | case SVGNodeName.Ellipse: elementList.Add(new SVGEllipseElement(Node.Attributes, summaryTransformList, paintable, render)); break; 103 | case SVGNodeName.PolyLine: elementList.Add(new SVGPolylineElement(Node.Attributes, summaryTransformList, paintable, render)); break; 104 | case SVGNodeName.Polygon: elementList.Add(new SVGPolygonElement(Node.Attributes, summaryTransformList, paintable, render)); break; 105 | case SVGNodeName.Path: elementList.Add(new SVGPathElement(Node.Attributes, summaryTransformList, paintable, render)); break; 106 | 107 | case SVGNodeName.SVG: elementList.Add(new SVGSVGElement(this, summaryTransformList, paintable, render)); break; 108 | case SVGNodeName.G: elementList.Add(new SVGGElement(this, summaryTransformList, paintable, render)); break; 109 | 110 | case SVGNodeName.LinearGradient: paintable.AppendLinearGradient(new SVGLinearGradientElement(this, Node.Attributes)); break; 111 | case SVGNodeName.RadialGradient: paintable.AppendRadialGradient(new SVGRadialGradientElement(this, Node.Attributes)); break; 112 | 113 | case SVGNodeName.Defs: GetElementList(elementList, paintable, render, summaryTransformList); break; 114 | case SVGNodeName.Title: GetElementList(elementList, paintable, render, summaryTransformList); break; 115 | case SVGNodeName.Desc: GetElementList(elementList, paintable, render, summaryTransformList); break; 116 | } 117 | } 118 | } 119 | 120 | private static SVGNodeName Lookup(string name) { 121 | SVGNodeName retVal; 122 | // TODO: Experiment with a dictionary lookup here. 123 | switch(name) { 124 | case "rect": retVal = SVGNodeName.Rect; break; 125 | case "line": retVal = SVGNodeName.Line; break; 126 | case "circle": retVal = SVGNodeName.Circle; break; 127 | case "ellipse": retVal = SVGNodeName.Ellipse; break; 128 | case "polyline": retVal = SVGNodeName.PolyLine; break; 129 | case "polygon": retVal = SVGNodeName.Polygon; break; 130 | case "path": retVal = SVGNodeName.Path; break; 131 | case "svg": retVal = SVGNodeName.SVG; break; 132 | case "g": retVal = SVGNodeName.G; break; 133 | case "linearGradient": retVal = SVGNodeName.LinearGradient; break; 134 | case "radialGradient": retVal = SVGNodeName.RadialGradient; break; 135 | case "defs": retVal = SVGNodeName.Defs; break; 136 | case "title": retVal = SVGNodeName.Title; break; 137 | case "desc": retVal = SVGNodeName.Desc; break; 138 | case "stop": retVal = SVGNodeName.Stop; break; 139 | default: throw new System.Exception("Unknown element type '" + name + "'!"); 140 | } 141 | return retVal; 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /benchmarks.txt: -------------------------------------------------------------------------------- 1 | (These numbers gathered on a late-2009 MacBook w/ 2.26Ghz Core2 Duo, and 4GB 2 | of 1067Mhz DDR3 RAM running OSX 10.6.1, under Unity 2.6.1) 3 | 4 | 5 | Initial version as posted to the wiki: 6 | 7 | File none arc1 lineargradient1 tiger lion test1 rect1 8 | Allocation 25.4KiB 30.3MiB 16.0MiB 82.3MiB 34.2MiB 5.7MiB 34.5MiB 9 | Time1 368ms 2634ms 2683ms 7700ms 5162ms 950ms 2672ms 10 | Time2 312ms 1826ms 2076ms 7681ms 3609ms 931ms 2582ms 11 | Time3 358ms 1669ms 2778ms 9394ms 4439ms 972ms 2987ms 12 | 13 | 14 | After converting uSVGPoint to a struct: 15 | (Note that tiger.txt does virtually all of its remaining allocations in the XML 16 | parsing side of things, thus the relatively meager gains) 17 | 18 | File none arc1 lineargradient1 tiger lion test1 rect1 19 | Allocation 25.4KiB 63.7KiB 245.1KiB 20.5MiB 3.7MiB 158.1KiB 133.8KiB 20 | Time1 348ms 2007ms 2313ms 7307ms 3819ms 557ms 1595ms 21 | Time2 389ms 1412ms 2610ms 6614ms 3149ms 753ms 2064ms 22 | Time3 299ms 1380ms 1881ms 7905ms 3142ms 577ms 2077ms 23 | 24 | After XML improvements and other cleanup: 25 | (Unfortunately, a LOT of stuff got broken here. GAH!) 26 | 27 | File none arc1 lineargradient1 tiger lion test1 rect1 28 | Allocation 18.4KiB N/A N/A 8.6MiB 1.6MiB N/A 65.0KiB 29 | Time1 264ms N/A N/A 7829ms 4186ms N/A 2191ms 30 | Time2 199ms N/A N/A 6988ms 3910ms N/A 1805ms 31 | Time3 207ms N/A N/A 7134ms 3606ms N/A 2157ms 32 | 33 | 34 | After bug fixes: 35 | 36 | File none arc1 lineargradient1 tiger lion test1 rect1 37 | Allocation 18.4KiB 44.4KiB 131.0KiB 8.6MiB 1.6MiB 68.6KiB 65.1KiB 38 | Time1 200ms 1595ms 2726ms 6412ms 3569ms 667ms 1722ms 39 | Time2 272ms 3874ms 3543ms 6608ms 3610ms 606ms 1521ms 40 | Time3 198ms 3891ms 3350ms 6201ms 3365ms 615ms 1981ms 41 | 42 | 43 | After 2010-08-06 optimization pass: 44 | (Note that the code produces a DLL about 9% smaller now. Unfortunately, at 45 | least one test image -- lion -- produces incorrect results now.) 46 | 47 | File none arc1 lineargradient1 tiger lion test1 rect1 48 | Allocation 8.9KiB 18.1KiB 40.2KiB 4.4MiB 0.7MiB 19.3KiB 24.3KiB 49 | Time1 193ms 1101ms 1958ms 4560ms 3485ms 486ms 1372ms 50 | Time2 196ms 1098ms 1943ms 4565ms 3494ms 480ms 1370ms 51 | Time3 196ms 1111ms 1925ms 4572ms 3515ms 478ms 1362ms 52 | 53 | 54 | (Following numbers gathered on a mid-2012 Retina MacBook Pro w/ 2.7Ghz Core i7, 55 | and 16GB of 1600Mhz DDR3 RAM running OSX 10.8.2, under Unity 3.5.5. NFI why 56 | the massive increase in memory usage but I presume it has to do with changes to 57 | Texture2D...) 58 | 59 | 60 | Same code as above: 61 | 62 | File none arc1 lineargradient1 tiger lion test1 rect1 63 | Allocation 4.0MiB 11.9MiB 5.9MiB 11.7MiB 11.7MiB 3.9MiB 7.9MiB 64 | Time1 124ms 939ms 1587ms 4516ms 2707ms 348ms 1141ms 65 | Time2 124ms 912ms 1567ms 4441ms 2702ms 346ms 1143ms 66 | Time3 123ms 913ms 1561ms 4423ms 2696ms 347ms 1175ms 67 | 68 | 69 | After 2012-10-03 optimizations: 70 | 71 | File none arc1 lineargradient1 tiger lion test1 rect1 72 | Allocation 4.0MiB 11.9MiB 5.9MiB 11.5MiB 12.9MiB 3.9MiB 7.9MiB 73 | Time1 127ms 838ms 1330ms 4157ms 2607ms 338ms 1070ms 74 | Time2 125ms 833ms 1330ms 4174ms 2609ms 339ms 1053ms 75 | Time3 125ms 838ms 1329ms 4180ms 2594ms 337ms 1052ms 76 | 77 | 78 | After LiteStack optimizations: 79 | 80 | File none arc1 lineargradient1 tiger lion test1 rect1 81 | Allocation 4.0MiB 11.9MiB 5.9MiB 11.9MiB 12.9MiB 3.9MiB 7.9MiB 82 | Time1 126ms 610ms 1263ms 3712ms 2419ms 338ms 793ms 83 | Time2 125ms 605ms 1268ms 3706ms 2397ms 337ms 800ms 84 | Time3 123ms 611ms 1258ms 3717ms 2410ms 338ms 793ms 85 | 86 | 87 | Removing deeper instrumentations: 88 | 89 | File none arc1 lineargradient1 tiger lion test1 rect1 90 | Allocation 4.0MiB 11.9MiB 5.9MiB 11.3MiB 12.9MiB 3.9MiB 7.9MiB 91 | Time1 124ms 611ms 1217ms 3711ms 2402ms 337ms 791ms 92 | Time2 123ms 607ms 1233ms 3710ms 2397ms 335ms 791ms 93 | Time3 126ms 603ms 1225ms 3689ms 2398ms 338ms 793ms 94 | 95 | 96 | After fixing lion.svg asset (I.E. just a fix to the artwork, no change to the 97 | code): 98 | 99 | File none arc1 lineargradient1 tiger lion test1 rect1 100 | Allocation 4.0MiB 11.9MiB 5.9MiB 11.3MiB 12.9MiB 3.9MiB 7.9MiB 101 | Time1 124ms 611ms 1217ms 3711ms 2102ms 337ms 791ms 102 | Time2 123ms 607ms 1233ms 3710ms 2109ms 335ms 791ms 103 | Time3 126ms 603ms 1225ms 3689ms 2109ms 338ms 793ms 104 | 105 | After moving to our own canvas system: 106 | 107 | File none arc1 lineargradient1 tiger lion test1 rect1 108 | Allocation 8.0MiB 15.7MiB 9.7MiB 15.3MiB 9.9MiB 7.7MiB 11.7MiB 109 | Time1 86ms 590ms 1052ms 3572ms 1999ms 291ms 749ms 110 | Time2 84ms 568ms 1068ms 3557ms 2016ms 297ms 751ms 111 | Time3 85ms 565ms 1071ms 3562ms 2026ms 295ms 747ms 112 | 113 | 114 | Reverting our own canvas system, but avoiding re-allocation of textures: 115 | 116 | File none arc1 lineargradient1 tiger lion test1 rect1 117 | Allocation 4.0MiB 11.9MiB 5.9MiB 11.3MiB 5.9MiB 3.9MiB 7.9MiB 118 | Time1 122ms 612ms 1221ms 3708ms 2087ms 338ms 792ms 119 | Time2 126ms 611ms 1220ms 3701ms 2089ms 340ms 789ms 120 | Time3 124ms 610ms 1220ms 3705ms 2092ms 340ms 791ms 121 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/SVGGraphicsPath.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | using UnityEngine.Profiling; 4 | 5 | public enum SVGFillRule : ushort { 6 | NoneZero = 0, 7 | EvenOdd = 1 8 | } 9 | 10 | // TODO: Find a way to break this the hell up. 11 | 12 | // TODO: Normalize conventions away from Java-style SetX to properties. 13 | public class SVGGraphicsPath { 14 | private Vector2 beginPoint; 15 | 16 | private Vector2 boundUL, boundBR; 17 | 18 | private bool needSetFirstPoint; 19 | 20 | private Matrix2x3 _matrixTransform; 21 | 22 | private readonly List listObject = new List(); 23 | 24 | public SVGFillRule fillRule = SVGFillRule.NoneZero; 25 | 26 | public Matrix2x3 matrixTransform { 27 | get { 28 | if(_matrixTransform == null) 29 | _matrixTransform = transformList.Consolidate().matrix; 30 | return _matrixTransform; 31 | } 32 | } 33 | 34 | public float transformAngle { 35 | get { 36 | float angle = 0.0f; 37 | for(int i = 0; i < transformList.Count; ++i) { 38 | SVGTransform temp = transformList[i]; 39 | if(temp.type == SVGTransformMode.Rotate) 40 | angle += temp.angle; 41 | } 42 | return angle; 43 | } 44 | } 45 | 46 | public SVGTransformList transformList { get; set; } 47 | 48 | public SVGGraphicsPath() { 49 | beginPoint = new Vector2(0f, 0f); 50 | needSetFirstPoint = true; 51 | boundUL = new Vector2(+10000f, +10000f); 52 | boundBR = new Vector2(-10000f, -10000f); 53 | transformList = new SVGTransformList(); 54 | } 55 | 56 | public void Reset() { 57 | beginPoint = new Vector2(0f, 0f); 58 | needSetFirstPoint = true; 59 | boundUL = new Vector2(+10000f, +10000f); 60 | boundBR = new Vector2(-10000f, -10000f); 61 | fillRule = SVGFillRule.NoneZero; 62 | transformList.Clear(); 63 | listObject.Clear(); 64 | } 65 | 66 | public void ExpandBounds(float x, float y) { 67 | if(x < boundUL.x) 68 | boundUL.x = x; 69 | if(y < boundUL.y) 70 | boundUL.y = y; 71 | 72 | if(x > boundBR.x) 73 | boundBR.x = x; 74 | if(y > boundBR.y) 75 | boundBR.y = y; 76 | } 77 | 78 | private void ExpandBounds(float x, float y, float dx, float dy) { 79 | if((x - dx) < boundUL.x) 80 | boundUL.x = x - dx; 81 | if((y - dy) < boundUL.y) 82 | boundUL.y = y - dy; 83 | 84 | if((x + dx) > boundBR.x) 85 | boundBR.x = x + dx; 86 | if((y + dy) > boundBR.y) 87 | boundBR.y = y + dy; 88 | } 89 | 90 | public void ExpandBounds(Vector2 point) { 91 | ExpandBounds(point.x, point.y); 92 | } 93 | 94 | public void ExpandBounds(Vector2 point, float deltax, float deltay) { 95 | ExpandBounds(point.x, point.y, deltax, deltay); 96 | } 97 | 98 | public void ExpandBounds(List points) { 99 | int length = points.Count; 100 | for(int i = 0; i < length; i++) 101 | ExpandBounds(points[i]); 102 | } 103 | 104 | private void SetFirstPoint(Vector2 p) { 105 | if(needSetFirstPoint) { 106 | beginPoint = p; 107 | needSetFirstPoint = false; 108 | } 109 | } 110 | 111 | public void Add(SVGPolygonElement polygonElement) { 112 | SetFirstPoint(polygonElement.listPoints[0]); 113 | listObject.Add(new SVGGPolygon(polygonElement.listPoints)); 114 | } 115 | 116 | public void Add(SVGPolylineElement polylineElement) { 117 | SetFirstPoint(polylineElement.listPoints[0]); 118 | listObject.Add(new SVGGPolyLine(polylineElement.listPoints)); 119 | } 120 | 121 | public void Add(SVGRectElement rectElement) { 122 | SVGGRect rect = new SVGGRect(rectElement.x.value, rectElement.y.value, rectElement.width.value, 123 | rectElement.height.value, rectElement.rx.value, rectElement.ry.value); 124 | SetFirstPoint(new Vector2(rect.x, rect.y)); 125 | listObject.Add(rect); 126 | } 127 | 128 | public void Add(SVGCircleElement circleElement) { 129 | Vector2 p = new Vector2(circleElement.cx.value, circleElement.cy.value); 130 | SetFirstPoint(p); 131 | listObject.Add(new SVGGCircle(p, circleElement.r.value)); 132 | } 133 | 134 | public void Add(SVGEllipseElement ellipseElement) { 135 | Vector2 p = new Vector2(ellipseElement.cx.value, ellipseElement.cy.value); 136 | SetFirstPoint(p); 137 | listObject.Add(new SVGGEllipse(p, ellipseElement.rx.value, ellipseElement.ry.value, 0)); 138 | } 139 | 140 | public void AddCircleTo(Vector2 p, float r) { 141 | listObject.Add(new SVGGCircle(p, r)); 142 | } 143 | 144 | public void AddEllipseTo(Vector2 p, float r1, float r2, float angle) { 145 | listObject.Add(new SVGGEllipse(p, r1, r2, angle)); 146 | } 147 | 148 | public void AddMoveTo(Vector2 p) { 149 | SetFirstPoint(p); 150 | listObject.Add(new SVGGMoveTo(p)); 151 | } 152 | 153 | public void AddArcTo(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, Vector2 p) { 154 | SVGGArcAbs svgGArcAbs = new SVGGArcAbs(r1, r2, angle, largeArcFlag, sweepFlag, p); 155 | listObject.Add(svgGArcAbs); 156 | } 157 | 158 | public void AddCubicCurveTo(Vector2 p1, Vector2 p2, Vector2 p) { 159 | SVGGCubicAbs svgGCubicAbs = new SVGGCubicAbs(p1, p2, p); 160 | listObject.Add(svgGCubicAbs); 161 | } 162 | 163 | public void AddQuadraticCurveTo(Vector2 p1, Vector2 p) { 164 | SVGGQuadraticAbs svgGQuadraticAbs = new SVGGQuadraticAbs(p1, p); 165 | listObject.Add(svgGQuadraticAbs); 166 | } 167 | 168 | public void AddLineTo(Vector2 p) { 169 | listObject.Add(new SVGGLineTo(p)); 170 | } 171 | 172 | public Rect GetBound() { 173 | Profiler.BeginSample("SVGGraphicsPath.GetBound"); 174 | for(int i = 0; i < listObject.Count; ++i) { 175 | ISVGPathSegment seg = listObject[i]; 176 | seg.ExpandBounds(this); 177 | } 178 | 179 | Rect tmp = new Rect(boundUL.x - 1, boundUL.y - 1, boundBR.x - boundUL.x + 2, boundBR.y - boundUL.y + 2); 180 | Profiler.EndSample(); 181 | return tmp; 182 | } 183 | 184 | public void RenderPath(ISVGPathDraw pathDraw, bool isClose) { 185 | Profiler.BeginSample("SVGGraphicsPath.RenderPath"); 186 | isClose = !isClose; 187 | Profiler.BeginSample("SVGGraphicsPath.RenderPath[for...]"); 188 | for(int i = 0; i < listObject.Count; i++) { 189 | Profiler.BeginSample("SVGGraphicsPath.RenderPath[...each]"); 190 | ISVGPathSegment seg = listObject[i]; 191 | isClose = seg.Render(this, pathDraw) || isClose; 192 | Profiler.EndSample(); 193 | } 194 | Profiler.EndSample(); 195 | 196 | if(!isClose) { 197 | Profiler.BeginSample("SVGPathSegment.Render[LineTo]"); 198 | pathDraw.LineTo(matrixTransform.Transform(beginPoint)); 199 | Profiler.EndSample(); 200 | } 201 | Profiler.EndSample(); 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /Assets/UnitySVG/Implementation/RenderingEngine/SVGLinearGradientBrush.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class SVGLinearGradientBrush { 6 | private SVGLinearGradientElement _linearGradElement; 7 | private float _x1, _y1, _x2, _y2; 8 | 9 | private List _stopColorList; 10 | private List _stopOffsetList; 11 | 12 | private SVGSpreadMethod _spreadMethod; 13 | 14 | public SVGLinearGradientBrush(SVGLinearGradientElement linearGradElement) { 15 | _linearGradElement = linearGradElement; 16 | Initialize(); 17 | } 18 | 19 | public SVGLinearGradientBrush(SVGLinearGradientElement linearGradElement, SVGGraphicsPath graphicsPath) { 20 | _linearGradElement = linearGradElement; 21 | Initialize(); 22 | 23 | SetGradientVector(graphicsPath); 24 | PreLocationProcess(); 25 | } 26 | 27 | private void Initialize() { 28 | _x1 = _linearGradElement.x1.value; 29 | _y1 = _linearGradElement.y1.value; 30 | _x2 = _linearGradElement.x2.value; 31 | _y2 = _linearGradElement.y2.value; 32 | 33 | _stopColorList = new List(); 34 | _stopOffsetList = new List(); 35 | _spreadMethod = _linearGradElement.spreadMethod; 36 | 37 | GetStopList(); 38 | _vitriOffset = 0; 39 | PreColorProcess(_vitriOffset); 40 | } 41 | 42 | private void GetStopList() { 43 | List _stopList = _linearGradElement.stopList; 44 | int _length = _stopList.Count; 45 | if(_length == 0) 46 | return; 47 | 48 | _stopColorList.Add(_stopList[0].stopColor.color); 49 | _stopOffsetList.Add(0f); 50 | int i = 0; 51 | for(i = 0; i < _length; i++) { 52 | float t_offset = _stopList[i].offset; 53 | if((t_offset > _stopOffsetList[_stopOffsetList.Count - 1]) && (t_offset <= 100f)) { 54 | _stopColorList.Add(_stopList[i].stopColor.color); 55 | _stopOffsetList.Add(t_offset); 56 | } else if(t_offset == _stopOffsetList[_stopOffsetList.Count - 1]) 57 | _stopColorList[_stopOffsetList.Count - 1] = _stopList[i].stopColor.color; 58 | } 59 | 60 | if(_stopOffsetList[_stopOffsetList.Count - 1] != 100f) { 61 | _stopColorList.Add(_stopColorList[_stopOffsetList.Count - 1]); 62 | _stopOffsetList.Add(100f); 63 | } 64 | } 65 | 66 | private float _deltaR, _deltaG, _deltaB; 67 | private int _vitriOffset = 0; 68 | 69 | private void PreColorProcess(int index) { 70 | float dp = _stopOffsetList[index + 1] - _stopOffsetList[index]; 71 | 72 | _deltaR = (_stopColorList[index + 1].r - _stopColorList[index].r) / dp; 73 | _deltaG = (_stopColorList[index + 1].g - _stopColorList[index].g) / dp; 74 | _deltaB = (_stopColorList[index + 1].b - _stopColorList[index].b) / dp; 75 | } 76 | 77 | private float _a, _b, _aP, _bP, _cP; 78 | 79 | private void PreLocationProcess() { 80 | if((_x1 - _x2 == 0f) || (_y1 - _y2 == 0f)) 81 | return; 82 | float dx, dy; 83 | dx = _x2 - _x1; 84 | dy = _y2 - _y1; 85 | 86 | _a = dy / dx; 87 | _b = _y1 - _a * _x1; 88 | 89 | _aP = (dx) / (dx + _a * dy); 90 | _bP = (dy) / (dx + _a * dy); 91 | _cP = -(_b * dy) / (dx + _a * dy); 92 | } 93 | //----- 94 | private float Percent(float x, float y) { 95 | float cx, cy; 96 | if(_x1 - _x2 == 0) { 97 | cx = _x1; 98 | cy = y; 99 | } else if(_y1 - _y2 == 0) { 100 | cx = x; 101 | cy = _y1; 102 | } else { 103 | cx = _aP * x + _bP * y + _cP; 104 | cy = _a * cx + _b; 105 | } 106 | 107 | 108 | float d1 = (float)Math.Sqrt((_x1 - cx) * (_x1 - cx) + (_y1 - cy) * (_y1 - cy)); 109 | float d2 = (float)Math.Sqrt((_x2 - cx) * (_x2 - cx) + (_y2 - cy) * (_y2 - cy)); 110 | float dd = (float)Math.Sqrt((_x2 - _x1) * (_x2 - _x1) + (_y2 - _y1) * (_y2 - _y1)); 111 | //-1 trai, 0 giua, 1 phai 112 | int vt = 0; 113 | if((d1 >= dd) || (d2 >= dd)) 114 | vt = (d1 < d2) ? -1 : 1; 115 | 116 | int _reflectTimes; 117 | float _remainder; 118 | 119 | switch(_spreadMethod) { 120 | case SVGSpreadMethod.Pad: 121 | if(vt == -1) 122 | return 0f; 123 | if(vt == 1) 124 | return 100f; 125 | return (d1 / dd * 100f); 126 | case SVGSpreadMethod.Reflect: 127 | _reflectTimes = (int)(d1 / dd); 128 | _remainder = d1 - (dd * (float)_reflectTimes); 129 | int _od = (int)(_reflectTimes) % 2; 130 | 131 | return ((100f * _od) + (1 - 2 * _od) * (_remainder / dd * 100f)); 132 | case SVGSpreadMethod.Repeat: 133 | _reflectTimes = (int)(d1 / dd); 134 | _remainder = d1 - (dd * (float)_reflectTimes); 135 | return (_remainder / dd * 100f); 136 | } 137 | 138 | return 100f; 139 | } 140 | 141 | private void SetGradientVector(SVGGraphicsPath graphicsPath) { 142 | Rect bound = graphicsPath.GetBound(); 143 | if(_linearGradElement.x1.unitType == SVGLengthType.Percentage) 144 | _x1 = bound.x + (bound.width * _x1 / 100f); 145 | if(_linearGradElement.y1.unitType == SVGLengthType.Percentage) 146 | _y1 = bound.y + (bound.height * _y1 / 100f); 147 | if(_linearGradElement.x2.unitType == SVGLengthType.Percentage) 148 | _x2 = bound.x + (bound.width * _x2 / 100f); 149 | if(_linearGradElement.y2.unitType == SVGLengthType.Percentage) 150 | _y2 = bound.y + (bound.height * _y2 / 100f); 151 | 152 | if(_linearGradElement.gradientUnits == SVGGradientUnit.ObjectBoundingBox) { 153 | Vector2 _point = graphicsPath.matrixTransform.Transform(new Vector2(_x1, _y1)); 154 | _x1 = _point.x; 155 | _y1 = _point.y; 156 | 157 | _point = graphicsPath.matrixTransform.Transform(new Vector2(_x2, _y2)); 158 | _x2 = _point.x; 159 | _y2 = _point.y; 160 | } 161 | } 162 | 163 | /*private float _ox = 0; 164 | private int _dem = 0; 165 | private bool _show = false;*/ 166 | public Color GetColor(float x, float y) { 167 | Color _color = Color.black; 168 | 169 | 170 | /*if(_ox != x) { 171 | _ox = x; 172 | _dem ++ ; 173 | 174 | if(_dem < 300) { 175 | _show = true; 176 | } 177 | }*/ 178 | 179 | float _percent = Percent(x, y); 180 | 181 | /*if(_show == true) { 182 | UnityEngine.Debug.Log("x " + x + " y " + y + " percent " + _percent); 183 | }*/ 184 | 185 | if((_stopOffsetList[_vitriOffset] <= _percent) && (_percent <= _stopOffsetList[_vitriOffset + 1])) { 186 | _color.r = ((_percent - _stopOffsetList[_vitriOffset]) * _deltaR) + _stopColorList[_vitriOffset].r; 187 | _color.g = ((_percent - _stopOffsetList[_vitriOffset]) * _deltaG) + _stopColorList[_vitriOffset].g; 188 | _color.b = ((_percent - _stopOffsetList[_vitriOffset]) * _deltaB) + _stopColorList[_vitriOffset].b; 189 | 190 | } else { 191 | for(int i = 0; i < _stopOffsetList.Count - 1; i++) 192 | if((_stopOffsetList[i] <= _percent) && (_percent <= _stopOffsetList[i + 1])) { 193 | _vitriOffset = i; 194 | PreColorProcess(_vitriOffset); 195 | 196 | _color.r = ((_percent - _stopOffsetList[i]) * _deltaR) + _stopColorList[i].r; 197 | _color.g = ((_percent - _stopOffsetList[i]) * _deltaG) + _stopColorList[i].g; 198 | _color.b = ((_percent - _stopOffsetList[i]) * _deltaB) + _stopColorList[i].b; 199 | break; 200 | } 201 | } 202 | //_show = false; 203 | return _color; 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left cmd 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Window Shake X 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0 162 | sensitivity: 0.1 163 | snap: 0 164 | invert: 0 165 | type: 3 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Window Shake Y 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0 178 | sensitivity: 0.1 179 | snap: 0 180 | invert: 0 181 | type: 3 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Horizontal 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 0 193 | dead: 0.19 194 | sensitivity: 1 195 | snap: 0 196 | invert: 0 197 | type: 2 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Vertical 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 0 209 | dead: 0.19 210 | sensitivity: 1 211 | snap: 0 212 | invert: 1 213 | type: 2 214 | axis: 1 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire1 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 0 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Fire2 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 1 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Fire3 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: joystick button 2 254 | altNegativeButton: 255 | altPositiveButton: 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Jump 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: joystick button 3 270 | altNegativeButton: 271 | altPositiveButton: 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Submit 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: return 286 | altNegativeButton: 287 | altPositiveButton: joystick button 0 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | - serializedVersion: 3 297 | m_Name: Submit 298 | descriptiveName: 299 | descriptiveNegativeName: 300 | negativeButton: 301 | positiveButton: enter 302 | altNegativeButton: 303 | altPositiveButton: space 304 | gravity: 1000 305 | dead: 0.001 306 | sensitivity: 1000 307 | snap: 0 308 | invert: 0 309 | type: 0 310 | axis: 0 311 | joyNum: 0 312 | - serializedVersion: 3 313 | m_Name: Cancel 314 | descriptiveName: 315 | descriptiveNegativeName: 316 | negativeButton: 317 | positiveButton: escape 318 | altNegativeButton: 319 | altPositiveButton: joystick button 1 320 | gravity: 1000 321 | dead: 0.001 322 | sensitivity: 1000 323 | snap: 0 324 | invert: 0 325 | type: 0 326 | axis: 0 327 | joyNum: 0 328 | --------------------------------------------------------------------------------