Skip to content

Confusion about imdraw documentation #216

Open

Description

@tapir
edgeDebug := imdraw.New(nil)

for !win.Closed() {
    // .....
    
    edgeDebug.Clear()
    //edgeDebug.Reset()
    edgeDebug.Color = colornames.Red
    edgeDebug.Push(points...)
    edgeDebug.Line(2)
    
    // .....

    win.Draw(edgeDebug)
}

According to documentation below

// Clear removes all drawn shapes from the IM. This does not remove Pushed points.
func (imd *IMDraw) Clear()

// Reset restores all point properties to defaults and removes all Pushed points.
//
// This does not affect matrix and color mask set by SetMatrix and SetColorMask.
func (imd *IMDraw) Reset()

Pushing new points in the main loop is no good since Clear() doesn't empty already pushed points but for some reason it works just fine. Only the recently pushed points are drawn to the screen. Am I missing something?

Also, Reset() supposedly removes all the pushed points but in this case it doesn't work. All the points pushed up until that moment is drawn to the screen. That's probably because old points were already drawn to the framebuffer and reset doesn't clear the buffer but it's really confusing.

Another nitpick would be that even If I use both there is no way to completely reset an imdraw object since it doesn't affect matrix and color mask.

So what's the best way to have a dynamically changing imdraw setup?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions