updates.
This commit is contained in:
parent
e09aa43a1e
commit
cbc4672f1e
13 changed files with 359 additions and 303 deletions
44
style.go
44
style.go
|
|
@ -4,36 +4,70 @@ import "image/color"
|
|||
|
||||
// Style is a simple style set.
|
||||
type Style struct {
|
||||
Show bool
|
||||
StrokeColor color.RGBA
|
||||
FillColor color.RGBA
|
||||
StrokeWidth int
|
||||
StrokeWidth float64
|
||||
FontSize float64
|
||||
FontColor color.RGBA
|
||||
}
|
||||
|
||||
// IsZero returns if the object is set or not.
|
||||
func (s Style) IsZero() bool {
|
||||
return ColorIsZero(s.StrokeColor) && ColorIsZero(s.FillColor) && s.StrokeWidth == 0
|
||||
return ColorIsZero(s.StrokeColor) && ColorIsZero(s.FillColor) && s.StrokeWidth == 0 && s.FontSize == 0
|
||||
}
|
||||
|
||||
// GetStrokeColor returns the stroke color.
|
||||
func (s Style) GetStrokeColor() color.RGBA {
|
||||
func (s Style) GetStrokeColor(defaults ...color.RGBA) color.RGBA {
|
||||
if ColorIsZero(s.StrokeColor) {
|
||||
if len(defaults) > 0 {
|
||||
return defaults[0]
|
||||
}
|
||||
return DefaultLineColor
|
||||
}
|
||||
return s.StrokeColor
|
||||
}
|
||||
|
||||
// GetFillColor returns the fill color.
|
||||
func (s Style) GetFillColor() color.RGBA {
|
||||
func (s Style) GetFillColor(defaults ...color.RGBA) color.RGBA {
|
||||
if ColorIsZero(s.FillColor) {
|
||||
if len(defaults) > 0 {
|
||||
return defaults[0]
|
||||
}
|
||||
return DefaultFillColor
|
||||
}
|
||||
return s.FillColor
|
||||
}
|
||||
|
||||
// GetStrokeWidth returns the stroke width.
|
||||
func (s Style) GetStrokeWidth() int {
|
||||
func (s Style) GetStrokeWidth(defaults ...float64) float64 {
|
||||
if s.StrokeWidth == 0 {
|
||||
if len(defaults) > 0 {
|
||||
return defaults[0]
|
||||
}
|
||||
return DefaultLineWidth
|
||||
}
|
||||
return s.StrokeWidth
|
||||
}
|
||||
|
||||
// GetFontSize gets the font size.
|
||||
func (s Style) GetFontSize(defaults ...float64) float64 {
|
||||
if s.FontSize == 0 {
|
||||
if len(defaults) > 0 {
|
||||
return defaults[0]
|
||||
}
|
||||
return DefaultFontSize
|
||||
}
|
||||
return s.FontSize
|
||||
}
|
||||
|
||||
// GetFontColor gets the font size.
|
||||
func (s Style) GetFontColor(defaults ...color.RGBA) color.RGBA {
|
||||
if ColorIsZero(s.FontColor) {
|
||||
if len(defaults) > 0 {
|
||||
return defaults[0]
|
||||
}
|
||||
return DefaultTextColor
|
||||
}
|
||||
return s.FontColor
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue