davidbrit2
Licensed Computer Geek
I've been tinkering with a program that generates and solves mazes. I'm porting it to Cocoa from AWT, and I'm having some issues with the graphical aspects (no surprise.) The actual maze functions are part of a class which is a subclass of NSView. This maze class has a drawRect method which uses NSBezierPath.fillRect() to paint squares into the view. No problem there. The only trouble is that this is rather time consuming, because the maze goes through its entire array and paints all the cells during this method. But if I try to have a method completely separate from drawRect that just paints an individual cell (for animation purposes,) nothing happens on screen. I also tried using a boolean variable, fullRepaint, to change the behavior of drawRect accordingly. It seems that the entire graphics context gets wiped when drawRect is called, because when I try to make it paint an individual cell, I see ONLY that cell on screen.
All I can generate right now are before and after pictures (both of which appear correct.) I can't, however, animate the solution without being able to change the colors of cells during execution.
So here's my question: how do I paint to an NSView without doing a complete redraw via drawRect?
All I can generate right now are before and after pictures (both of which appear correct.) I can't, however, animate the solution without being able to change the colors of cells during execution.
So here's my question: how do I paint to an NSView without doing a complete redraw via drawRect?