Skip to content
Snippets Groups Projects

Allow solid colored glyphs have a different colored outline

Closed Sebastien Binet requested to merge zaddok:master into master
1 file
+ 21
0
Compare changes
  • Side-by-side
  • Inline
+ 21
0
@@ -55,6 +55,12 @@ type GlyphStyle struct {
// Radius specifies the size of the glyph's radius.
Radius vg.Length
// Width is set, LineColour is used to outline the glyph
    • Created by: kortschak

      How about using a LineStyle here? Comment would be:

      // LineStyle is the style of the glyph outline.
      // If LineStyle.Width is zero no outline is drawn.
    • Created by: zaddok

      Great suggestion, I would like that idea, except for the fact that LineStyle also includes a Dashes and a DashOffs field—they would be effectively unused. I'm happy to switch the patch over to use LineStyle if that is what people prefer.

      PS: Yikes, I need to fix the wording of that comment as well.

Please register or sign in to reply
Width vg.Length
// Outline glyph with this color if Width is set.
LineColor color.Color
// Shape draws the shape of the glyph.
Shape GlyphDrawer
}
@@ -106,6 +112,11 @@ func (CircleGlyph) DrawGlyph(c *Canvas, sty GlyphStyle, pt vg.Point) {
p.Arc(pt, sty.Radius, 0, 2*math.Pi)
p.Close()
c.Fill(p)
if sty.Width > 0 {
c.SetLineStyle(LineStyle{Color: sty.LineColor, Width: sty.Width})
c.Stroke(p)
}
}
// RingGlyph is a glyph that draws the outline of a circle.
@@ -156,6 +167,11 @@ func (BoxGlyph) DrawGlyph(c *Canvas, sty GlyphStyle, pt vg.Point) {
p.Line(vg.Point{X: pt.X - x, Y: pt.Y + x})
p.Close()
c.Fill(p)
if sty.Width > 0 {
c.SetLineStyle(LineStyle{Color: sty.LineColor, Width: sty.Width})
c.Stroke(p)
}
}
// TriangleGlyph is a glyph that draws the outline of a triangle.
@@ -185,6 +201,11 @@ func (PyramidGlyph) DrawGlyph(c *Canvas, sty GlyphStyle, pt vg.Point) {
p.Line(vg.Point{X: pt.X + r*cosπover6, Y: pt.Y - r*sinπover6})
p.Close()
c.Fill(p)
if sty.Width > 0 {
c.SetLineStyle(LineStyle{Color: sty.LineColor, Width: sty.Width})
c.Stroke(p)
}
}
// PlusGlyph is a glyph that draws a plus sign
Loading