draw2dgl: de-stutter types
This commit is contained in:
parent
a8154b175c
commit
c1b7f443b4
1 changed files with 13 additions and 13 deletions
|
@ -15,7 +15,7 @@ func init() {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
}
|
}
|
||||||
|
|
||||||
type GLPainter struct {
|
type Painter struct {
|
||||||
// The Porter-Duff composition operator.
|
// The Porter-Duff composition operator.
|
||||||
Op draw.Op
|
Op draw.Op
|
||||||
// The 16-bit color to paint the spans.
|
// The 16-bit color to paint the spans.
|
||||||
|
@ -28,7 +28,7 @@ type GLPainter struct {
|
||||||
const M16 uint32 = 1<<16 - 1
|
const M16 uint32 = 1<<16 - 1
|
||||||
|
|
||||||
// Paint satisfies the Painter interface by painting ss onto an image.RGBA.
|
// Paint satisfies the Painter interface by painting ss onto an image.RGBA.
|
||||||
func (p *GLPainter) Paint(ss []raster.Span, done bool) {
|
func (p *Painter) Paint(ss []raster.Span, done bool) {
|
||||||
//gl.Begin(gl.LINES)
|
//gl.Begin(gl.LINES)
|
||||||
sslen := len(ss)
|
sslen := len(ss)
|
||||||
clenrequired := sslen * 8
|
clenrequired := sslen * 8
|
||||||
|
@ -71,7 +71,7 @@ func (p *GLPainter) Paint(ss []raster.Span, done bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *GLPainter) Flush() {
|
func (p *Painter) Flush() {
|
||||||
if len(p.vertices) != 0 {
|
if len(p.vertices) != 0 {
|
||||||
gl.EnableClientState(gl.COLOR_ARRAY)
|
gl.EnableClientState(gl.COLOR_ARRAY)
|
||||||
gl.EnableClientState(gl.VERTEX_ARRAY)
|
gl.EnableClientState(gl.VERTEX_ARRAY)
|
||||||
|
@ -88,7 +88,7 @@ func (p *GLPainter) Flush() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetColor sets the color to paint the spans.
|
// SetColor sets the color to paint the spans.
|
||||||
func (p *GLPainter) SetColor(c color.Color) {
|
func (p *Painter) SetColor(c color.Color) {
|
||||||
r, g, b, a := c.RGBA()
|
r, g, b, a := c.RGBA()
|
||||||
if a == 0 {
|
if a == 0 {
|
||||||
p.cr = 0
|
p.cr = 0
|
||||||
|
@ -104,8 +104,8 @@ func (p *GLPainter) SetColor(c color.Color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRGBAPainter creates a new RGBAPainter for the given image.
|
// NewRGBAPainter creates a new RGBAPainter for the given image.
|
||||||
func NewGLPainter() *GLPainter {
|
func NewPainter() *Painter {
|
||||||
p := new(GLPainter)
|
p := new(Painter)
|
||||||
p.vertices = make([]int32, 0, 1024)
|
p.vertices = make([]int32, 0, 1024)
|
||||||
p.colors = make([]uint8, 0, 1024)
|
p.colors = make([]uint8, 0, 1024)
|
||||||
return p
|
return p
|
||||||
|
@ -113,24 +113,24 @@ func NewGLPainter() *GLPainter {
|
||||||
|
|
||||||
type GraphicContext struct {
|
type GraphicContext struct {
|
||||||
*draw2d.StackGraphicContext
|
*draw2d.StackGraphicContext
|
||||||
painter *GLPainter
|
painter *Painter
|
||||||
fillRasterizer *raster.Rasterizer
|
fillRasterizer *raster.Rasterizer
|
||||||
strokeRasterizer *raster.Rasterizer
|
strokeRasterizer *raster.Rasterizer
|
||||||
}
|
}
|
||||||
|
|
||||||
type GLVertex struct {
|
type Vertex struct {
|
||||||
x, y float64
|
x, y float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGLVertex() *GLVertex {
|
func NewVertex() *Vertex {
|
||||||
return &GLVertex{}
|
return &Vertex{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (glVertex *GLVertex) NextCommand(cmd draw2d.VertexCommand) {
|
func (*Vertex) NextCommand(cmd draw2d.VertexCommand) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (glVertex *GLVertex) Vertex(x, y float64) {
|
func (*Vertex) Vertex(x, y float64) {
|
||||||
gl.Vertex2d(x, y)
|
gl.Vertex2d(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ func (glVertex *GLVertex) Vertex(x, y float64) {
|
||||||
func NewGraphicContext(width, height int) *GraphicContext {
|
func NewGraphicContext(width, height int) *GraphicContext {
|
||||||
gc := &GraphicContext{
|
gc := &GraphicContext{
|
||||||
draw2d.NewStackGraphicContext(),
|
draw2d.NewStackGraphicContext(),
|
||||||
NewGLPainter(),
|
NewPainter(),
|
||||||
raster.NewRasterizer(width, height),
|
raster.NewRasterizer(width, height),
|
||||||
raster.NewRasterizer(width, height),
|
raster.NewRasterizer(width, height),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue