pline.py 690 B

12345678910111213141516171819202122232425
  1. '''
  2. Created on 25 nov. 2016
  3. @author: olinox
  4. '''
  5. from core import geometry
  6. from core.pencil.pbase import BasePencil
  7. class LinePencil(BasePencil):
  8. def __init__(self, *args):
  9. BasePencil.__init__(*args)
  10. def _update(self):
  11. x0, y0 = self.origin
  12. x, y = self.position
  13. result = set([])
  14. line = geometry.gline.line2d(self._grid.grid_shape, x0, y0, x, y)
  15. for x, y in line:
  16. result |= set( geometry.gzone.zone(self._grid.grid_shape, x, y, self.size) )
  17. self._added = list( result - self._selection )
  18. self._removed = list( self._selection - result )
  19. self._selection = list( result )