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

Method drawCircle

recipes/Python/577674_Bitmap_Maker/recipe-577674.py:376–410  ·  view source on GitHub ↗
( self, cx, cy, r, fill=False )

Source from the content-addressed store, hash-verified

374 self._drawLines( segs )
375
376 def drawCircle( self, cx, cy, r, fill=False ):
377 x = 0
378 y = r
379 d = 1 - r
380
381 self.plotPoint(cx, cy + y)
382 self.plotPoint(cx, cy - y)
383 if fill:
384 self.drawLine(cx - y, cy, cx + y, cy)
385 else:
386 self.plotPoint(cx + y, cy)
387 self.plotPoint(cx - y, cy)
388
389 while( y > x ):
390 if ( d < 0 ):
391 d += ( 2*x + 3 )
392 else:
393 d += ( 2*(x-y) + 5 )
394 y -= 1
395 x += 1
396
397 if fill:
398 self.drawLine(cx + x - 1, cy + y, cx - x + 1, cy + y)
399 self.drawLine(cx - x + 1, cy - y, cx + x - 1, cy - y)
400 self.drawLine(cx + y - 1, cy + x, cx - y + 1, cy + x)
401 self.drawLine(cx - y + 1, cy - x, cx + y - 1, cy - x)
402 else:
403 self.plotPoint(cx + x, cy + y)
404 self.plotPoint(cx + y, cy + x)
405 self.plotPoint(cx - x, cy - y)
406 self.plotPoint(cx - y, cy - x)
407 self.plotPoint(cx + x, cy - y)
408 self.plotPoint(cx - y, cy + x)
409 self.plotPoint(cx - x, cy + y)
410 self.plotPoint(cx + y, cy - x)
411
412 def _saveBitMapNoCompression( self ):
413 line_padding = (4 - (self.wd % 4)) % 4

Callers 2

drawSines.pyFile · 0.45
recipe-580810.pyFile · 0.45

Calls 2

plotPointMethod · 0.95
drawLineMethod · 0.95

Tested by

no test coverage detected