applied fill and stroke styles to all the path functions
This commit is contained in:
parent
ac8adda421
commit
4569cd00e1
2 changed files with 13 additions and 15 deletions
|
@ -407,7 +407,7 @@ func (cv *Canvas) useShader(style *drawStyle) (vertexLoc uint32) {
|
||||||
|
|
||||||
gli.UseProgram(sr.id)
|
gli.UseProgram(sr.id)
|
||||||
gli.Uniform2f(sr.canvasSize, cv.fw, cv.fh)
|
gli.Uniform2f(sr.canvasSize, cv.fw, cv.fh)
|
||||||
c := cv.state.fill.color
|
c := style.color
|
||||||
gli.Uniform4f(sr.color, c.r, c.g, c.b, c.a)
|
gli.Uniform4f(sr.color, c.r, c.g, c.b, c.a)
|
||||||
return sr.vertex
|
return sr.vertex
|
||||||
}
|
}
|
||||||
|
|
26
paths.go
26
paths.go
|
@ -228,8 +228,7 @@ func (cv *Canvas) Stroke() {
|
||||||
gli.BufferData(gl_ARRAY_BUFFER, len(tris)*4, unsafe.Pointer(&tris[0]), gl_STREAM_DRAW)
|
gli.BufferData(gl_ARRAY_BUFFER, len(tris)*4, unsafe.Pointer(&tris[0]), gl_STREAM_DRAW)
|
||||||
|
|
||||||
gli.UseProgram(sr.id)
|
gli.UseProgram(sr.id)
|
||||||
c := cv.state.stroke.color
|
gli.Uniform4f(sr.color, 0, 0, 0, 0)
|
||||||
gli.Uniform4f(sr.color, c.r, c.g, c.b, c.a)
|
|
||||||
gli.Uniform2f(sr.canvasSize, cv.fw, cv.fh)
|
gli.Uniform2f(sr.canvasSize, cv.fw, cv.fh)
|
||||||
|
|
||||||
gli.ColorMask(false, false, false, false)
|
gli.ColorMask(false, false, false, false)
|
||||||
|
@ -237,15 +236,18 @@ func (cv *Canvas) Stroke() {
|
||||||
gli.EnableVertexAttribArray(sr.vertex)
|
gli.EnableVertexAttribArray(sr.vertex)
|
||||||
gli.VertexAttribPointer(sr.vertex, 2, gl_FLOAT, false, 0, nil)
|
gli.VertexAttribPointer(sr.vertex, 2, gl_FLOAT, false, 0, nil)
|
||||||
gli.DrawArrays(gl_TRIANGLES, 6, int32(len(tris)/2-6))
|
gli.DrawArrays(gl_TRIANGLES, 6, int32(len(tris)/2-6))
|
||||||
|
gli.DisableVertexAttribArray(sr.vertex)
|
||||||
|
|
||||||
gli.ColorMask(true, true, true, true)
|
gli.ColorMask(true, true, true, true)
|
||||||
|
|
||||||
gli.StencilFunc(gl_EQUAL, 1, 0xFF)
|
gli.StencilFunc(gl_EQUAL, 1, 0xFF)
|
||||||
gli.StencilMask(0xFF)
|
gli.StencilMask(0xFF)
|
||||||
|
|
||||||
gli.DrawArrays(gl_TRIANGLE_FAN, 0, 6)
|
vertex := cv.useShader(&cv.state.stroke)
|
||||||
|
gli.EnableVertexAttribArray(vertex)
|
||||||
gli.DisableVertexAttribArray(sr.vertex)
|
gli.VertexAttribPointer(vertex, 2, gl_FLOAT, false, 0, nil)
|
||||||
|
gli.DrawArrays(gl_TRIANGLES, 0, 6)
|
||||||
|
gli.DisableVertexAttribArray(vertex)
|
||||||
|
|
||||||
gli.StencilOp(gl_KEEP, gl_KEEP, gl_KEEP)
|
gli.StencilOp(gl_KEEP, gl_KEEP, gl_KEEP)
|
||||||
gli.StencilFunc(gl_EQUAL, 0, 0xFF)
|
gli.StencilFunc(gl_EQUAL, 0, 0xFF)
|
||||||
|
@ -339,14 +341,11 @@ func (cv *Canvas) Fill() {
|
||||||
tris := triangulatePath(path, buf[:0])
|
tris := triangulatePath(path, buf[:0])
|
||||||
gli.BufferData(gl_ARRAY_BUFFER, len(tris)*4, unsafe.Pointer(&tris[0]), gl_STREAM_DRAW)
|
gli.BufferData(gl_ARRAY_BUFFER, len(tris)*4, unsafe.Pointer(&tris[0]), gl_STREAM_DRAW)
|
||||||
|
|
||||||
gli.UseProgram(sr.id)
|
vertex := cv.useShader(&cv.state.fill)
|
||||||
c := cv.state.fill.color
|
gli.EnableVertexAttribArray(vertex)
|
||||||
gli.Uniform4f(sr.color, c.r, c.g, c.b, c.a)
|
gli.VertexAttribPointer(vertex, 2, gl_FLOAT, false, 0, nil)
|
||||||
gli.Uniform2f(sr.canvasSize, cv.fw, cv.fh)
|
|
||||||
gli.EnableVertexAttribArray(sr.vertex)
|
|
||||||
gli.VertexAttribPointer(sr.vertex, 2, gl_FLOAT, false, 0, nil)
|
|
||||||
gli.DrawArrays(gl_TRIANGLES, 0, int32(len(tris)/2))
|
gli.DrawArrays(gl_TRIANGLES, 0, int32(len(tris)/2))
|
||||||
gli.DisableVertexAttribArray(sr.vertex)
|
gli.DisableVertexAttribArray(vertex)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cv *Canvas) Clip() {
|
func (cv *Canvas) Clip() {
|
||||||
|
@ -369,8 +368,7 @@ func (cv *Canvas) clip(path []pathPoint) {
|
||||||
gli.VertexAttribPointer(sr.vertex, 2, gl_FLOAT, false, 0, nil)
|
gli.VertexAttribPointer(sr.vertex, 2, gl_FLOAT, false, 0, nil)
|
||||||
|
|
||||||
gli.UseProgram(sr.id)
|
gli.UseProgram(sr.id)
|
||||||
c := cv.state.fill.color
|
gli.Uniform4f(sr.color, 1, 1, 1, 1)
|
||||||
gli.Uniform4f(sr.color, c.r, c.g, c.b, c.a)
|
|
||||||
gli.Uniform2f(sr.canvasSize, cv.fw, cv.fh)
|
gli.Uniform2f(sr.canvasSize, cv.fw, cv.fh)
|
||||||
gli.EnableVertexAttribArray(sr.vertex)
|
gli.EnableVertexAttribArray(sr.vertex)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue