Bitmap/Midpoint circle algorithm: Difference between revisions

Content added Content deleted
(→‎{{header|J}}: simplify)
m (→‎{{header|J}}: drawCircle to drawCircles)
Line 402: Line 402:
)
)


NB.*drawCircle v Draws circle (x) on image (y)
NB.*drawCircles v Draws circle(s) (x) on image (y)
NB. x is: 2-item list (y0 x0 radius) ; (color)
NB. x is: 2-item list of boxed (y0 x0 radius) ; (color)
drawCircle=: (1&{:: ;~ [: ; [: <@getBresenhamCircle"1 (0&{::))@[ setPixels ]
drawCircle=: (1&{:: ;~ [: ; [: <@getBresenhamCircle"1 (0&{::))@[ setPixels ]
</lang>
</lang>
Line 409: Line 409:
'''Example usage:'''
'''Example usage:'''
<lang j> myimg=: 0 255 0 makeRGB 25 25 NB. 25 by 25 green image
<lang j> myimg=: 0 255 0 makeRGB 25 25 NB. 25 by 25 green image
myimg=: (12 12 12 ; 255 0 0) drawCircle myimg NB. draw red circle with radius 12
myimg=: (12 12 12 ; 255 0 0) drawCircles myimg NB. draw red circle with radius 12
viewRGB ((12 12 9 ,: 12 12 6) ; 0 0 255) drawCircle myimg NB. draw two more concentric circles
viewRGB ((12 12 9 ,: 12 12 6) ; 0 0 255) drawCircles myimg NB. draw two more concentric circles
</lang>
</lang>