Merge branch 'master' into draw-image-rotated
This commit is contained in:
commit
b13517ff6f
13
context.go
13
context.go
@ -45,6 +45,11 @@ const (
|
|||||||
AlignRight
|
AlignRight
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
defaultFillStyle = NewSolidPattern(color.White)
|
||||||
|
defaultStrokeStyle = NewSolidPattern(color.Black)
|
||||||
|
)
|
||||||
|
|
||||||
type Context struct {
|
type Context struct {
|
||||||
width int
|
width int
|
||||||
height int
|
height int
|
||||||
@ -89,6 +94,8 @@ func NewContextForRGBA(im *image.RGBA) *Context {
|
|||||||
height: im.Bounds().Size().Y,
|
height: im.Bounds().Size().Y,
|
||||||
im: im,
|
im: im,
|
||||||
color: color.Transparent,
|
color: color.Transparent,
|
||||||
|
fillPattern: defaultFillStyle,
|
||||||
|
strokePattern: defaultStrokeStyle,
|
||||||
lineWidth: 1,
|
lineWidth: 1,
|
||||||
fillRule: FillRuleWinding,
|
fillRule: FillRuleWinding,
|
||||||
fontFace: basicfont.Face7x13,
|
fontFace: basicfont.Face7x13,
|
||||||
@ -183,6 +190,10 @@ func (dc *Context) setFillAndStrokeColor(c color.Color) {
|
|||||||
|
|
||||||
// SetFillStyle sets current fill style
|
// SetFillStyle sets current fill style
|
||||||
func (dc *Context) SetFillStyle(pattern Pattern) {
|
func (dc *Context) SetFillStyle(pattern Pattern) {
|
||||||
|
// if pattern is SolidPattern, also change dc.color(for dc.Clear, dc.drawString)
|
||||||
|
if fillStyle, ok := pattern.(*solidPattern); ok {
|
||||||
|
dc.color = fillStyle.color
|
||||||
|
}
|
||||||
dc.fillPattern = pattern
|
dc.fillPattern = pattern
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +202,7 @@ func (dc *Context) SetStrokeStyle(pattern Pattern) {
|
|||||||
dc.strokePattern = pattern
|
dc.strokePattern = pattern
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetColor sets the current color.
|
// SetColor sets the current color(for both fill and stroke).
|
||||||
func (dc *Context) SetColor(c color.Color) {
|
func (dc *Context) SetColor(c color.Color) {
|
||||||
dc.setFillAndStrokeColor(c)
|
dc.setFillAndStrokeColor(c)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user