You are browsing as a guest. Sign up (or log in) to start making projects!

1h 4m 58s logged

Devlog #2 - making it Pan and Zoom and Adding infinite space

I implemented infinite panning, precision scroll-wheel zooming, and smoother pen aesthetics along with Infinite Canvas

Challenges and Solutions

The problem I faced was that

It was difficult to add support for both space bar and left click(of the mouse) 
being pressed at the same time

So to solve it I introduced 3 variables self.panning = False, self.pan_start = None and self.space_pressed = False

then while checking for the key press, we check for space bar and set the variable self.space_pressed to true
and then while checking for the mouse press event we set the variable self.panning to True
And then finally in the mouse move event we actually pan in the canvas by moving the camera

self.horizontalScrollBar().setValue( self.horizontalScrollBar().value() - int(delta.x()))     
self.verticalScrollBar().setValue(self.verticalScrollBar().value() - int(delta.y()))
0
3

Comments 0

No comments yet. Be the first!