def addXIntersectionsFromLoopForTable(loop, xIntersectionsTable, width):
 for pointIndex in xrange(len(loop)):
  pointBegin = loop[pointIndex]
  pointEnd = loop[((pointIndex + 1) % len(loop))]
  if (pointBegin.imag > pointEnd.imag):
   pointOriginal = pointBegin
   pointBegin = pointEnd
   pointEnd = pointOriginal
  fillBegin = int(math.ceil((pointBegin.imag / width)))
  fillEnd = int(math.ceil((pointEnd.imag / width)))
  if (fillEnd > fillBegin):
   secondMinusFirstComplex = (pointEnd - pointBegin)
   secondMinusFirstImaginaryOverReal = (secondMinusFirstComplex.real / secondMinusFirstComplex.imag)
   beginRealMinusImaginary = (pointBegin.real - (pointBegin.imag * secondMinusFirstImaginaryOverReal))
   for fillLine in xrange(fillBegin, fillEnd):
    y = (fillLine * width)
    xIntersection = ((y * secondMinusFirstImaginaryOverReal) + beginRealMinusImaginary)
    addElementToListDictionary(xIntersection, fillLine, xIntersectionsTable)

def addXIntersectionsFromLoopForTable ( loop , xIntersectionsTable , width ) : for pointIndex in xrange ( len ( loop ) ) : pointBegin = loop [ pointIndex ] pointEnd = loop [ ( ( pointIndex + 1 ) % len ( loop ) ) ] if ( pointBegin . imag > pointEnd . imag ) : pointOriginal = pointBegin pointBegin = pointEnd pointEnd = pointOriginal fillBegin = int ( math . ceil ( ( pointBegin . imag / width ) ) ) fillEnd = int ( math . ceil ( ( pointEnd . imag / width ) ) ) if ( fillEnd > fillBegin ) : secondMinusFirstComplex = ( pointEnd - pointBegin ) secondMinusFirstImaginaryOverReal = ( secondMinusFirstComplex . real / secondMinusFirstComplex . imag ) beginRealMinusImaginary = ( pointBegin . real - ( pointBegin . imag * secondMinusFirstImaginaryOverReal ) ) for fillLine in xrange ( fillBegin , fillEnd ) : y = ( fillLine * width ) xIntersection = ( ( y * secondMinusFirstImaginaryOverReal ) + beginRealMinusImaginary ) addElementToListDictionary ( xIntersection , fillLine , xIntersectionsTable )
add the x intersections for a loop into a table .