simplified Push/Pop
This commit is contained in:
parent
0fd2b0f764
commit
85b390fbce
29
context.go
29
context.go
@ -376,33 +376,14 @@ func (dc *Context) TransformPoint(x, y float64) (tx, ty float64) {
|
|||||||
// Stack
|
// Stack
|
||||||
|
|
||||||
func (dc *Context) Push() {
|
func (dc *Context) Push() {
|
||||||
path := make(raster.Path, len(dc.path))
|
x := *dc
|
||||||
copy(path, dc.path)
|
x.path = make(raster.Path, len(dc.path))
|
||||||
dc.stack = append(dc.stack, &Context{
|
copy(x.path, dc.path)
|
||||||
color: dc.color,
|
dc.stack = append(dc.stack, &x)
|
||||||
path: path,
|
|
||||||
start: dc.start,
|
|
||||||
lineWidth: dc.lineWidth,
|
|
||||||
lineCap: dc.lineCap,
|
|
||||||
lineJoin: dc.lineJoin,
|
|
||||||
fillRule: dc.fillRule,
|
|
||||||
fontFace: dc.fontFace,
|
|
||||||
fontHeight: dc.fontHeight,
|
|
||||||
matrix: dc.matrix,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dc *Context) Pop() {
|
func (dc *Context) Pop() {
|
||||||
s := dc.stack
|
s := dc.stack
|
||||||
x, s := s[len(s)-1], s[:len(s)-1]
|
x, s := s[len(s)-1], s[:len(s)-1]
|
||||||
dc.color = x.color
|
*dc = *x
|
||||||
dc.path = x.path
|
|
||||||
dc.start = x.start
|
|
||||||
dc.lineWidth = x.lineWidth
|
|
||||||
dc.lineCap = x.lineCap
|
|
||||||
dc.lineJoin = x.lineJoin
|
|
||||||
dc.fillRule = x.fillRule
|
|
||||||
dc.fontFace = x.fontFace
|
|
||||||
dc.fontHeight = x.fontHeight
|
|
||||||
dc.matrix = x.matrix
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user