implemented line dash offset
This commit is contained in:
parent
e887b6ad3e
commit
b73d093683
4 changed files with 34 additions and 1 deletions
|
@ -111,6 +111,7 @@ These features *should* work just like their HTML5 counterparts, but there are l
|
||||||
- miterLimit
|
- miterLimit
|
||||||
- lineDash
|
- lineDash
|
||||||
- getLineDash
|
- getLineDash
|
||||||
|
- lineDashOffset
|
||||||
- global alpha
|
- global alpha
|
||||||
- drawImage
|
- drawImage
|
||||||
- getImageData
|
- getImageData
|
||||||
|
@ -123,7 +124,6 @@ These features *should* work just like their HTML5 counterparts, but there are l
|
||||||
# Missing features
|
# Missing features
|
||||||
|
|
||||||
- globalCompositeOperation
|
- globalCompositeOperation
|
||||||
- lineDashOffset
|
|
||||||
- textBaseline
|
- textBaseline
|
||||||
- isPointInPath
|
- isPointInPath
|
||||||
- isPointInStroke
|
- isPointInStroke
|
||||||
|
|
|
@ -684,6 +684,10 @@ func (cv *Canvas) SetLineDash(dash []float64) {
|
||||||
cv.state.lineDashOffset = 0
|
cv.state.lineDashOffset = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cv *Canvas) SetLineDashOffset(offset float64) {
|
||||||
|
cv.state.lineDashOffset = offset
|
||||||
|
}
|
||||||
|
|
||||||
// GetLineDash gets the line dash style
|
// GetLineDash gets the line dash style
|
||||||
func (cv *Canvas) GetLineDash() []float64 {
|
func (cv *Canvas) GetLineDash() []float64 {
|
||||||
result := make([]float64, len(cv.state.lineDash))
|
result := make([]float64, len(cv.state.lineDash))
|
||||||
|
|
|
@ -239,6 +239,35 @@ func TestLineDash(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLineDashOffset(t *testing.T) {
|
||||||
|
run(t, func(cv *canvas.Canvas) {
|
||||||
|
cv.SetStrokeStyle("#0F0")
|
||||||
|
cv.SetLineWidth(2.5)
|
||||||
|
cv.SetLineDash([]float64{4, 6, 8})
|
||||||
|
cv.SetLineDashOffset(5)
|
||||||
|
cv.BeginPath()
|
||||||
|
cv.MoveTo(20, 20)
|
||||||
|
cv.LineTo(80, 20)
|
||||||
|
cv.LineTo(80, 80)
|
||||||
|
cv.LineTo(50, 80)
|
||||||
|
cv.LineTo(50, 50)
|
||||||
|
cv.LineTo(20, 50)
|
||||||
|
cv.ClosePath()
|
||||||
|
cv.MoveTo(30, 30)
|
||||||
|
cv.LineTo(70, 30)
|
||||||
|
cv.LineTo(70, 70)
|
||||||
|
cv.LineTo(60, 70)
|
||||||
|
cv.LineTo(60, 40)
|
||||||
|
cv.LineTo(30, 40)
|
||||||
|
cv.ClosePath()
|
||||||
|
cv.Stroke()
|
||||||
|
ld := cv.GetLineDash()
|
||||||
|
if ld[0] != 4 || ld[1] != 6 || ld[2] != 8 || ld[3] != 4 || ld[4] != 6 || ld[5] != 8 {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestCurves(t *testing.T) {
|
func TestCurves(t *testing.T) {
|
||||||
run(t, func(cv *canvas.Canvas) {
|
run(t, func(cv *canvas.Canvas) {
|
||||||
cv.SetStrokeStyle("#00F")
|
cv.SetStrokeStyle("#00F")
|
||||||
|
|
BIN
testdata/LineDashOffset.png
vendored
Executable file
BIN
testdata/LineDashOffset.png
vendored
Executable file
Binary file not shown.
After Width: | Height: | Size: 445 B |
Loading…
Reference in a new issue