/// <summary> Applies a given style to a RageSpline </summary> private void ApplyStyleToSpline(RageSvgPathElement path, RageSvgStyle style) { path.Spline.FillType = style.FillType; path.Spline.Outline.Type = style.OutlineType; path.Spline.Outline.Width = style.OutlineWidth; path.Spline.Outline.CornerType = style.CornersType; Color cFillColor1 = style.FillColor1; cFillColor1.a = style.FillColor1Alpha; if (style.FillType == Spline.FillType.Gradient) { ApplyFillGradient(path, style); } else { path.Spline.FillColor = cFillColor1; } Color cStrokeColor = style.OutlineColor1; cStrokeColor.a = style.OutlineAlpha; path.Spline.Outline.StartColor = cStrokeColor; }
/// <summary> Sets the Gradient Fill parameters of the RageSpline </summary> /// <param name="spline"> </param> private void ApplyFillGradient(RageSvgPathElement path, RageSvgStyle style) { var gradient = style.RageSvgGradient; var start = new Vector2(gradient.X1, gradient.Y1); var end = new Vector2(gradient.X2, gradient.Y2); if (DebugStyleCreation) { Debug.Log("\tGradient Start Color:" + gradient.StartColor); } path.Spline.FillGradient.StartColor = gradient.StartColor; path.Spline.FillGradient.EndColor = gradient.EndColor; path.Spline.FillGradient.StyleLocalPositioning = true; path.Spline.FillGradient.Offset = (start + end) / 2; path.Spline.FillGradient.Scale = 1 / ((end - start) / 2).magnitude; //Debug.Log("current: "+current.Spline.name+" | start-end x/y : "+ start.x +" "+ start.y+" "+end.x+" "+end.y); var gradientAngle = ColorExtension.CalcTheta(new Vector2(gradient.X1, gradient.Y1), new Vector2(gradient.X2, gradient.Y2)); if (DebugStyleCreation) { Debug.Log("\tGradient Angle: " + gradientAngle); } path.Spline.FillGradient.Angle = gradientAngle; }
/// <summary> Parses the RageStyle and applies the Vertex Density during import </summary> /// <param name="spline"> </param> private void ApplyRageStyle(RageSvgPathElement path, RageSvgStyle style) { if (style.HasOutline) { style.OutlineType = path.IsClosed ? Spline.OutlineType.Loop : Spline.OutlineType.Free; } else { style.OutlineType = Spline.OutlineType.None; } if (style.HasFill) { style.FillType = style.HasGradient ? Spline.FillType.Gradient : Spline.FillType.Solid; } else { style.FillType = Spline.FillType.None; } if (DebugStyleCreation) { Debug.Log("\tOutline: " + style.OutlineType + "; Has Outline: " + style.HasOutline); Debug.Log("\tFill: " + style.FillType + "; Has Fill: " + style.HasFill); Debug.Log(style.Debug()); } if (path.Spline == null || path.Spline.Rs == null) { return; } ApplyStyleToSpline(path, style); // Parse single point, according to: https://bugzilla.mozilla.org/show_bug.cgi?id=322976 if (path.Spline.PointsCount == 1) { CreateDotCircle(ref path, style); // Has to create a circle even without a "z" command to prevent RageSpline errors return; } ApplyVertexDensity(ref path); path.Spline.Rs.RefreshMeshInEditor(true, true, true); }
public void AddPath(RageSvgPathElement newPath) { Paths.Add(newPath); }