public override void Serialize(XmlDocument dom, XmlElement node) { base.Serialize(dom, node); node.SetAttribute("target", Target.ID); if (LayoutData != null) { node.SetAttribute("cp1_length", LayoutData.CP1.Length.ToString()); node.SetAttribute("cp1_angle", LayoutData.CP1.Angle.ToString()); node.SetAttribute("cp2_length", LayoutData.CP2.Length.ToString()); node.SetAttribute("cp2_angle", LayoutData.CP2.Angle.ToString()); } node.SetAttribute("width", LineWidth.ToString()); if (!Color.IsEmpty) { node.SetAttribute("color", ST.ToString(Color)); } node.SetAttribute("line_style", LineStyle.ToString()); node.SetAttribute("start_cap", StartCap.ToString()); node.SetAttribute("end_cap", EndCap.ToString()); node.SetAttribute("text", Text); node.SetAttribute("hyperlink", Hyperlink); if (!string.IsNullOrEmpty(Remark)) { ST.WriteTextNode(node, "remark", Remark); } }
public CapInfo(EndCap capType, Material material, Texture2D texture, float ratio1, float ratio2, float offset) { this.capType = capType; this.material = material; this.texture = texture; this.ratio1 = ratio1; this.ratio2 = ratio2; this.offset = offset; }
/// <inheritdoc/> public override void Assign(Base source) { base.Assign(source); LineObject src = source as LineObject; Diagonal = src.Diagonal; StartCap.Assign(src.StartCap); EndCap.Assign(src.EndCap); }
private static void GetEndCap(EndCap ec, out LineCap endcaps, out DashCap dashcaps) { switch (ec) { case EndCap.Flat: endcaps = LineCap.Flat; dashcaps = DashCap.Flat; break; case EndCap.Square: endcaps = LineCap.Square; dashcaps = DashCap.Flat; break; default: endcaps = LineCap.Round; dashcaps = DashCap.Round; break; } }
public CapInfo(EndCap capType, Texture texture, float ratio1, float ratio2, float offset1, float offset2, float scale1, float scale2, float[] uvHeights) { this.capType = capType; this.texture = texture; this.ratio1 = ratio1; this.ratio2 = ratio2; this.offset1 = offset1; this.offset2 = offset2; this.scale1 = scale1; this.scale2 = scale2; this.uvHeights = uvHeights; }
/// <inheritdoc/> public override void Serialize(FRWriter writer) { Border.SimpleBorder = true; base.Serialize(writer); LineObject c = writer.DiffObject as LineObject; if (Diagonal != c.Diagonal) { writer.WriteBool("Diagonal", Diagonal); } StartCap.Serialize("StartCap", writer, c.StartCap); EndCap.Serialize("EndCap", writer, c.EndCap); }
public override JObject SaveToJsonObject(StiJsonSaveMode mode) { var jObject = base.SaveToJsonObject(mode); if (Brush != null) { jObject.Add(new JProperty("Brush", SaveBrushToJsonObject(Brush, mode))); } jObject.Add(new JProperty("Thickness", Thickness)); jObject.Add(new JProperty("PenStyle", PenStyle.ToString())); jObject.Add(new JProperty("Alignment", Alignment.ToString())); jObject.Add(new JProperty("StartCap", StartCap.ToString())); jObject.Add(new JProperty("EndCap", EndCap.ToString())); return(jObject); }
private Int32 computeHashCode() { return(Alignment.GetHashCode() ^ getSingleArrayHashCode(CompoundArray) ^ MiterLimit.GetHashCode() ^ BackgroundBrush.GetHashCode() ^ DashOffset.GetHashCode() ^ getSingleArrayHashCode(DashPattern) ^ getStyleBrushesArrayHashCode(DashBrushes) ^ DashStyle.GetHashCode() ^ StartCap.GetHashCode() ^ EndCap.GetHashCode() ^ DashCap.GetHashCode() ^ LineJoin.GetHashCode() ^ Transform.GetHashCode() ^ Width.GetHashCode() ^ -18133844); }
/// <summary> /// Default constructor sets all attributes to their default value. /// Use DefaultAttributes to access an instance of this. /// </summary> private GraphicAttributes() { Color = RGB.Black; Opacity = 1.0; AntiGrain = false; Hatch = Hatch.Cross; FillStyle = FillStyle.Solid; LineWidth = 0.0; LineStyle = LineStyle.Continuous; LineStyleDashes = Painter.DefaultLineStyleDashes; EndCaps = EndCap.Flat; LineJoin = LineJoin.Bevel; Pattern = null; Transform = Transform2d.Identity; Clip = null; PatternTransform = Transform2d.Identity; FillMode = FillMode.EvenOdd; Font = null; }
public GraphicAttributes(Painter p) { Color = p.Color; Opacity = p.Opacity; AntiGrain = p.AntiGrain; Hatch = p.Hatch; FillStyle = p.FillStyle; LineWidth = p.LineWidth; LineStyle = p.LineStyle; LineStyleDashes = p.LineStyleDashes; EndCaps = p.EndCaps; LineJoin = p.LineJoin; Pattern = p.Pattern; Transform = p.Transform; Clip = p.Clip; PatternTransform = p.PatternTransform; FillMode = p.FillMode; Font = p.Font; }
//<< Fields protected override void Serialize(IDictionary <string, object> json) { //>> Serialization var stroke = Stroke.ToJson(); if (stroke.Any()) { json["stroke"] = stroke; } var hover = Hover.ToJson(); if (hover.Any()) { json["hover"] = hover; } if (StartCap.HasValue()) { json["startCap"] = StartCap; } if (EndCap.HasValue()) { json["endCap"] = EndCap; } var points = Points.ToJson(); if (points.Any()) { json["points"] = points; } //<< Serialization }
public static void SetEndCap (string name, EndCap capType, Material material, float offset, params Texture2D[] textures) { if (capDictionary == null) { capDictionary = new Dictionary<string, CapInfo>(); } if (name == null || name == "") { Debug.LogError ("VectorLine: must supply a name for SetEndCap"); return; } if (capDictionary.ContainsKey (name) && capType != EndCap.None) { Debug.LogError ("VectorLine: end cap \"" + name + "\" has already been set up"); return; } if (capType == EndCap.Both) { if (textures.Length < 2) { Debug.LogError ("VectorLine: must supply two textures when using SetEndCap with EndCap.Both"); return; } if (textures[0].width != textures[1].width || textures[0].height != textures[1].height) { Debug.LogError ("VectorLine: when using SetEndCap with EndCap.Both, both textures must have the same width and height"); return; } } if ( (capType == EndCap.Front || capType == EndCap.Back || capType == EndCap.Mirror) && textures.Length < 1) { Debug.LogError ("VectorLine: must supply a texture when using SetEndCap with EndCap.Front, EndCap.Back, or EndCap.Mirror"); return; } if (capType == EndCap.None) { if (!capDictionary.ContainsKey (name)) { return; } RemoveEndCap (name); return; } if (material == null) { Debug.LogError ("VectorLine: must supply a material when using SetEndCap with any EndCap type except EndCap.None"); return; } if (!material.HasProperty ("_MainTex")) { Debug.LogError ("VectorLine: the material supplied when using SetEndCap must contain a shader that has a \"_MainTex\" property"); return; } int width = textures[0].width; int height = textures[0].height; float ratio1 = 0.0f, ratio2 = 0.0f; Color[] cols1 = null, cols2 = null; if (capType == EndCap.Front) { cols1 = textures[0].GetPixels(); cols2 = new Color[width * height]; ratio1 = textures[0].width / (float)textures[0].height; } else if (capType == EndCap.Back) { cols1 = new Color[width * height]; cols2 = textures[0].GetPixels(); ratio2 = textures[0].width / (float)textures[0].height; } else if (capType == EndCap.Both) { cols1 = textures[0].GetPixels(); cols2 = textures[1].GetPixels(); ratio1 = textures[0].width / (float)textures[0].height; ratio2 = textures[1].width / (float)textures[1].height; } else if (capType == EndCap.Mirror) { cols1 = textures[0].GetPixels(); cols2 = new Color[width * height]; ratio1 = textures[0].width / (float)textures[0].height; ratio2 = ratio1; } var tex = new Texture2D(width, height*4, TextureFormat.ARGB32, false); tex.wrapMode = TextureWrapMode.Clamp; tex.filterMode = textures[0].filterMode; tex.SetPixels (0, 0, width, height, cols1); tex.SetPixels (0, height*3, width, height, cols2); // Add space to prevent top/bottom textures from potentially bleeding into each other when using bilinear filtering tex.SetPixels (0, height, width, height*2, new Color[width * (height*2)]); tex.Apply (false, true); var capMaterial = (Material)MonoBehaviour.Instantiate(material); capMaterial.name = material.name + " EndCap"; capMaterial.mainTexture = tex; capDictionary.Add (name, new CapInfo(capType, capMaterial, tex, ratio1, ratio2, offset)); }
public static void SetEndCap (string name, EndCap capType, Material material, params Texture2D[] textures) { SetEndCap (name, capType, material, 0.0f, textures); }
public static void SetEndCap (string name, EndCap capType) { SetEndCap (name, capType, null, 0.0f, null); }
/// <summary> /// Updates the inspector. /// </summary> public void UpdateInspector() { // Set values FrameCheckbox.Title = (SelectedStyle.FrameColor == null) ? "Custom Frame" : $"{SelectedStyle.FrameColor.Name} Frame"; FrameCheckbox.IntValue = SelectedStyle.HasFrame ? 1 : 0; ShowCurrentColor(); WidthSlider.FloatValue = SelectedStyle.Frame.StrokeWidth; WidthValue.StringValue = WidthSlider.FloatValue.ToString(); MiterSlider.FloatValue = SelectedStyle.Frame.StrokeMiter; MiterValue.StringValue = MiterSlider.FloatValue.ToString(); AntialiasCheckbox.IntValue = (SelectedStyle.Frame.IsAntialias) ? 1 : 0; JitterCheckbox.IntValue = SelectedStyle.HasFrameJitter ? 1 : 0; LengthSlider.FloatValue = SelectedStyle.FrameJitterLength; LengthValue.StringValue = LengthSlider.IntValue.ToString(); DeviationSlider.FloatValue = SelectedStyle.FrameJitterDeviation; DeviationValue.StringValue = DeviationSlider.IntValue.ToString(); ShowDashEditor(); BlurCheckbox.IntValue = (SelectedStyle.HasFrameBlur) ? 1 : 0; HorizontalBlurSlider.FloatValue = SelectedStyle.FrameBlur.HorizontalBlurAmount; HorizontalBlurSlider.Enabled = SelectedStyle.HasFrameBlur; HorizontalBlurValue.StringValue = HorizontalBlurSlider.IntValue.ToString(); VerticalBlurSlider.FloatValue = SelectedStyle.FrameBlur.VerticalBlurAmount; VerticalBlurSlider.Enabled = SelectedStyle.HasFrameBlur; VerticalBlurValue.StringValue = VerticalBlurSlider.IntValue.ToString(); ShowCurrentShadowColor(); HorizontalShadowOffsetSlider.FloatValue = SelectedStyle.FrameShadow.HorizontalOffset; HorizontalShadowOffsetValue.StringValue = HorizontalShadowOffsetSlider.IntValue.ToString(); VerticalShadowOffsetSlider.FloatValue = SelectedStyle.FrameShadow.VerticalOffset; VerticalShadowOffsetValue.StringValue = VerticalShadowOffsetSlider.IntValue.ToString(); HorizontalShadowBlurSlider.FloatValue = SelectedStyle.FrameShadow.HorizontalBlurAmount; HorizontalShadowBlurValue.StringValue = HorizontalShadowBlurSlider.IntValue.ToString(); VerticalShadowBlurSlider.FloatValue = SelectedStyle.FrameShadow.VerticalBlurAmount; VerticalShadowBlurValue.StringValue = VerticalShadowBlurSlider.IntValue.ToString(); // Populate the list of colors LinkedColorSelector.RemoveAllItems(); LinkedColorSelector.AddItem("None"); var n = 0; foreach (KimonoColor color in Portfolio.Colors) { // Add color LinkedColorSelector.AddItem(color.Name); ++n; // Currently selected color? if (SelectedStyle.FrameColor == color) { // Yes, highlight it LinkedColorSelector.SelectItem(n); } } // Populate the list of shadow colors LinkedShadowColor.RemoveAllItems(); LinkedShadowColor.AddItem("None"); n = 0; foreach (KimonoColor color in Portfolio.Colors) { // Add color LinkedShadowColor.AddItem(color.Name); ++n; // Currently selected color? if (SelectedStyle.FrameShadow.LinkedColor == color) { // Yes, highlight it LinkedShadowColor.SelectItem(n); } } // Populate the list of gradients GradientDropdown.RemoveAllItems(); GradientDropdown.AddItem("None"); n = 0; foreach (KimonoGradient gradient in Portfolio.Gradients) { // Add gradient GradientDropdown.AddItem(gradient.Name); ++n; // Currently selected gradient? if (SelectedStyle.FrameGradient == gradient) { // Yes, highlight it GradientDropdown.SelectItem(n); } } // Display blend mode switch (SelectedStyle.Frame.BlendMode) { case SKBlendMode.Clear: BlendMode.SelectItem(1); break; case SKBlendMode.Color: BlendMode.SelectItem(2); break; case SKBlendMode.ColorBurn: BlendMode.SelectItem(3); break; case SKBlendMode.ColorDodge: BlendMode.SelectItem(4); break; case SKBlendMode.Darken: BlendMode.SelectItem(5); break; case SKBlendMode.Difference: BlendMode.SelectItem(6); break; case SKBlendMode.Dst: BlendMode.SelectItem(7); break; case SKBlendMode.DstATop: BlendMode.SelectItem(8); break; case SKBlendMode.DstIn: BlendMode.SelectItem(9); break; case SKBlendMode.DstOut: BlendMode.SelectItem(10); break; case SKBlendMode.DstOver: BlendMode.SelectItem(11); break; case SKBlendMode.Exclusion: BlendMode.SelectItem(12); break; case SKBlendMode.HardLight: BlendMode.SelectItem(13); break; case SKBlendMode.Hue: BlendMode.SelectItem(14); break; case SKBlendMode.Lighten: BlendMode.SelectItem(15); break; case SKBlendMode.Luminosity: BlendMode.SelectItem(16); break; case SKBlendMode.Modulate: BlendMode.SelectItem(17); break; case SKBlendMode.Multiply: BlendMode.SelectItem(18); break; case SKBlendMode.Overlay: BlendMode.SelectItem(19); break; case SKBlendMode.Plus: BlendMode.SelectItem(20); break; case SKBlendMode.Saturation: BlendMode.SelectItem(21); break; case SKBlendMode.Screen: BlendMode.SelectItem(22); break; case SKBlendMode.SoftLight: BlendMode.SelectItem(23); break; case SKBlendMode.Src: BlendMode.SelectItem(24); break; case SKBlendMode.SrcATop: BlendMode.SelectItem(25); break; case SKBlendMode.SrcIn: BlendMode.SelectItem(26); break; case SKBlendMode.SrcOut: BlendMode.SelectItem(27); break; case SKBlendMode.SrcOver: BlendMode.SelectItem(0); break; case SKBlendMode.Xor: BlendMode.SelectItem(28); break; } // Display join type switch (SelectedStyle.Frame.StrokeJoin) { case SKStrokeJoin.Bevel: JoinType.SelectItem(0); break; case SKStrokeJoin.Miter: JoinType.SelectItem(1); break; case SKStrokeJoin.Round: JoinType.SelectItem(2); break; } // Display end cap type switch (SelectedStyle.Frame.StrokeCap) { case SKStrokeCap.Butt: EndCap.SelectItem(0); break; case SKStrokeCap.Round: EndCap.SelectItem(1); break; case SKStrokeCap.Square: EndCap.SelectItem(2); break; } // Update GUI FrameColor.Enabled = (SelectedStyle.HasFrame && SelectedStyle.FrameColor == null); OpacitySlider.Enabled = (SelectedStyle.HasFrame && SelectedStyle.FrameColor == null); OpacityValue.Enabled = (SelectedStyle.HasFrame && SelectedStyle.FrameColor == null); BlendMode.Enabled = SelectedStyle.HasFrame; WidthSlider.Enabled = SelectedStyle.HasFrame; WidthValue.Enabled = SelectedStyle.HasFrame; MiterSlider.Enabled = SelectedStyle.HasFrame; MiterValue.Enabled = SelectedStyle.HasFrame; JoinType.Enabled = SelectedStyle.HasFrame; EndCap.Enabled = SelectedStyle.HasFrame; LengthSlider.Enabled = SelectedStyle.HasFrameJitter; DeviationSlider.Enabled = SelectedStyle.HasFrameJitter; }
private bool ShouldSerializeEndCap() { return(!EndCap.Equals(new CapSettings())); }
void ReleaseDesignerOutlets() { if (ShadowCheckbox != null) { ShadowCheckbox.Dispose(); ShadowCheckbox = null; } if (ShadowColor != null) { ShadowColor.Dispose(); ShadowColor = null; } if (LinkedShadowColor != null) { LinkedShadowColor.Dispose(); LinkedShadowColor = null; } if (ShadowOpacitySlider != null) { ShadowOpacitySlider.Dispose(); ShadowOpacitySlider = null; } if (ShadowOpacityValue != null) { ShadowOpacityValue.Dispose(); ShadowOpacityValue = null; } if (HorizontalShadowOffsetSlider != null) { HorizontalShadowOffsetSlider.Dispose(); HorizontalShadowOffsetSlider = null; } if (HorizontalShadowOffsetValue != null) { HorizontalShadowOffsetValue.Dispose(); HorizontalShadowOffsetValue = null; } if (VerticalShadowOffsetSlider != null) { VerticalShadowOffsetSlider.Dispose(); VerticalShadowOffsetSlider = null; } if (VerticalShadowOffsetValue != null) { VerticalShadowOffsetValue.Dispose(); VerticalShadowOffsetValue = null; } if (HorizontalShadowBlurSlider != null) { HorizontalShadowBlurSlider.Dispose(); HorizontalShadowBlurSlider = null; } if (HorizontalShadowBlurValue != null) { HorizontalShadowBlurValue.Dispose(); HorizontalShadowBlurValue = null; } if (VerticalShadowBlurSlider != null) { VerticalShadowBlurSlider.Dispose(); VerticalShadowBlurSlider = null; } if (VerticalShadowBlurValue != null) { VerticalShadowBlurValue.Dispose(); VerticalShadowBlurValue = null; } if (AddColorButton != null) { AddColorButton.Dispose(); AddColorButton = null; } if (AntialiasCheckbox != null) { AntialiasCheckbox.Dispose(); AntialiasCheckbox = null; } if (BlendMode != null) { BlendMode.Dispose(); BlendMode = null; } if (BlurCheckbox != null) { BlurCheckbox.Dispose(); BlurCheckbox = null; } if (Dash1 != null) { Dash1.Dispose(); Dash1 = null; } if (Dash10 != null) { Dash10.Dispose(); Dash10 = null; } if (Dash11 != null) { Dash11.Dispose(); Dash11 = null; } if (Dash12 != null) { Dash12.Dispose(); Dash12 = null; } if (Dash13 != null) { Dash13.Dispose(); Dash13 = null; } if (Dash14 != null) { Dash14.Dispose(); Dash14 = null; } if (Dash15 != null) { Dash15.Dispose(); Dash15 = null; } if (Dash16 != null) { Dash16.Dispose(); Dash16 = null; } if (Dash2 != null) { Dash2.Dispose(); Dash2 = null; } if (Dash3 != null) { Dash3.Dispose(); Dash3 = null; } if (Dash4 != null) { Dash4.Dispose(); Dash4 = null; } if (Dash5 != null) { Dash5.Dispose(); Dash5 = null; } if (Dash6 != null) { Dash6.Dispose(); Dash6 = null; } if (Dash7 != null) { Dash7.Dispose(); Dash7 = null; } if (Dash8 != null) { Dash8.Dispose(); Dash8 = null; } if (Dash9 != null) { Dash9.Dispose(); Dash9 = null; } if (DashCheckbox != null) { DashCheckbox.Dispose(); DashCheckbox = null; } if (DeviationSlider != null) { DeviationSlider.Dispose(); DeviationSlider = null; } if (DeviationValue != null) { DeviationValue.Dispose(); DeviationValue = null; } if (EndCap != null) { EndCap.Dispose(); EndCap = null; } if (FrameCheckbox != null) { FrameCheckbox.Dispose(); FrameCheckbox = null; } if (FrameColor != null) { FrameColor.Dispose(); FrameColor = null; } if (GradientDropdown != null) { GradientDropdown.Dispose(); GradientDropdown = null; } if (HorizontalBlurSlider != null) { HorizontalBlurSlider.Dispose(); HorizontalBlurSlider = null; } if (HorizontalBlurValue != null) { HorizontalBlurValue.Dispose(); HorizontalBlurValue = null; } if (JitterCheckbox != null) { JitterCheckbox.Dispose(); JitterCheckbox = null; } if (JoinType != null) { JoinType.Dispose(); JoinType = null; } if (LengthSlider != null) { LengthSlider.Dispose(); LengthSlider = null; } if (LengthValue != null) { LengthValue.Dispose(); LengthValue = null; } if (LinkedColorSelector != null) { LinkedColorSelector.Dispose(); LinkedColorSelector = null; } if (MiterSlider != null) { MiterSlider.Dispose(); MiterSlider = null; } if (MiterValue != null) { MiterValue.Dispose(); MiterValue = null; } if (OpacitySlider != null) { OpacitySlider.Dispose(); OpacitySlider = null; } if (OpacityValue != null) { OpacityValue.Dispose(); OpacityValue = null; } if (VerticalBlurSlider != null) { VerticalBlurSlider.Dispose(); VerticalBlurSlider = null; } if (VerticalBlurValue != null) { VerticalBlurValue.Dispose(); VerticalBlurValue = null; } if (WidthSlider != null) { WidthSlider.Dispose(); WidthSlider = null; } if (WidthValue != null) { WidthValue.Dispose(); WidthValue = null; } }
public MetafileRecordEndCaps(EndCap cap) { this.cap = cap; }