MCPcopy Create free account
hub / github.com/ActiveState/code / _drawLine

Method _drawLine

recipes/Python/577674_Bitmap_Maker/recipe-577674.py:261–286  ·  view source on GitHub ↗
( self, x1, y1, x2, y2 )

Source from the content-addressed store, hash-verified

259 bresLine = staticmethod( bresLine )
260
261 def _drawLine( self, x1, y1, x2, y2 ):
262 # special checks for vert and horiz lines
263 if ( x1 == x2 ):
264 if 0 <= x1 < self.wd:
265 if ( y2 < y1 ):
266 y1,y2 = y2,y1
267 cury = max( y1, 0 )
268 maxy = min( y2, self.ht-1 )
269 while cury <= maxy :
270 self.plotPoint( x1, cury )
271 cury += 1
272 return
273
274 if ( y1 == y2 ):
275 if ( 0 <= y1 < self.ht ):
276 if ( x2 < x1 ):
277 x1,x2 = x2,x1
278 curx = max( x1, 0 )
279 maxx = min( x2, self.wd-1 )
280 while curx <= maxx:
281 self.plotPoint( curx, y1 )
282 curx += 1
283 return
284
285 for pt in BitMap.bresLine(x1, y1, x2, y2):
286 self.plotPoint( pt[0], pt[1] )
287
288 def _drawLines( self, lineSegs ):
289 for x1,y1,x2,y2 in lineSegs:

Callers 2

_drawLinesMethod · 0.95
drawLineMethod · 0.95

Calls 4

plotPointMethod · 0.95
minFunction · 0.85
bresLineMethod · 0.80
maxFunction · 0.50

Tested by

no test coverage detected