Creates circle image (rasterized texture, returns handle for b2dDrawImage).
Takes radius (circle radius in pixels, positive integer), segments (smoothness quality, higher=smoother, 3-128 range), fill (1=filled circle, 0=outline only).
Returns image handle (positive integer, use with b2dDrawImage/b2dSetColor/b2dSetScale/b2dSetRotation, etc), returns 0 on failure.
2D Overlay
Parameters & Returns
Parameters
fillInt
radiusInt
segmentsInt
Returns
Int
Quick Summary
Creates circle image (rasterized texture, returns handle for b2dDrawImage).
Takes radius (circle radius in pixels, positive integer), segments (smoothness quality, higher=smoother, 3-128 range), fill (1=filled circle, 0=outline only).
Returns image handle (positive integer, use with b2dDrawImage/b2dSetColor/b2dSetScale/b2dSetRotation, etc), returns 0 on failure.
Technical Exegesis...
Creates circle image (rasterized texture, returns handle for b2dDrawImage). Takes radius (circle radius in pixels, positive integer), segments (smoothness quality, higher=smoother, 3-128 range), fill (1=filled circle, 0=outline only). Returns image handle (positive integer, use with b2dDrawImage/b2dSetColor/b2dSetScale/b2dSetRotation, etc), returns 0 on failure.
Creates circle image (rasterized texture, returns handle for b2dDrawImage). Takes radius (circle radius in pixels, positive integer), segments (smoothness quality, higher=smoother, 3-128 range), fill (1=filled circle, 0=outline only). Returns image handle (positive integer, use with b2dDrawImage/b2dSetColor/b2dSetScale/b2dSetRotation, etc), returns 0 on failure. Creates GPU texture (rasterizes circle to pixel buffer, uploads to GPU as RGBA texture), stores in g_images map (same as b2dLoadImage, image handle system), sets center handle (handleX/Y at circle center for rotation pivot).
Circle rasterization: allocates pixel buffer (size=(radius*2+2)^2, RGBA format), pixel-center sampling (samples at x+0.5, y+0.5 for antialiasing), distance calculation (dx^2 + dy^2 vs radius^2), edge detection (uses segments parameter: angle=2*PI/segments, checks against segment boundary lines), fill mode (filled=entire interior white alpha 255, outline=only edge pixels white alpha 255, transparent elsewhere).
Segments parameter: determines smoothness (higher values=smoother curves, more edge samples), valid range 3-128 (clamped automatically, <3 returns 0, >128 capped at 128), affects rasterization (calculates angle steps: angleStep=2*PI/segments, tests pixel against segment boundaries), common values (8 segments=octagon for small dots, 16=hexadecagon for medium circles, 32-64=smooth circles for UI, 128=maximum smoothness for large graphics).
Image handle usage: use with b2dDrawImage (b2dDrawImage(circle, x, y) draws at position), use with transforms (b2dSetScale/b2dSetRotation/b2dSetAlpha apply, then b2dDrawImage), use with color (b2dSetColor(r,g,b) tints circle before drawing), free when done (b2dFreeImage(circle) releases GPU texture).
Use cases: (1) UI buttons (circle=b2dCreateCircle(50,32,1): b2dSetColor(0,255,0): b2dDrawImage(circle,x,y) green button), (2) Particles (dot=b2dCreateCircle(5,8,1): draw many with b2dDrawImage at different positions), (3) Debug visualization (outline=b2dCreateCircle(radius,16,0): draw collision circles), (4) Icons (icon=b2dCreateCircle(20,24,1): scale/rotate with b2dSetScale/b2dSetRotation).
Center handle: handleX and handleY set to radius+1 (center of circle), rotation pivot at center (b2dSetRotation rotates around circle center, not top-left), position is center (x,y in b2dDrawImage positions circle center, not corner).
Performance: texture creation cost (rasterization + GPU upload, one-time ~1-10ms depending on size), reusable (create once, draw many times with b2dDrawImage, no per-frame cost), GPU memory (width*height*4 bytes, e.g. radius 50 = 104x104 = ~43KB), stored until freed (persists in g_images map until b2dFreeImage called).
Common values: radius 50 segments 32 for smooth UI circles (good balance of quality and performance), radius 5 segments 8 for small dots (low detail sufficient for tiny sprites), radius 100 segments 64 for large graphics (high quality for prominent elements), radius 20 segments 16 for medium icons (decent smoothness for HUD elements).
Validation: returns 0 if radius<=0 (invalid size), returns 0 if segments<3 (minimum polygon), clamps segments to 128 (prevents excessive detail), returns 0 if GPU allocation fails (out of VRAM or device not initialized).
Related: b2dDrawImage draws circle (positions and renders circle texture), b2dSetColor tints circle (applies color multiplier before drawing), b2dSetScale/b2dSetRotation/b2dSetAlpha transform circle (applies transforms to circle image), b2dFreeImage frees circle (releases GPU texture when done), b2dCreateRectangle creates rectangle image (similar function for rectangles).
Example
Example.bam
; Create a smooth filled green circle
circle = b2dCreateCircle(50, 32, 1)
; Draw it at screen position with color
b2dSetColor(0, 255, 0)
b2dDrawImage(circle, 400, 300)
; Can also scale and rotate
b2dSetScale(2.0, 2.0)
b2dSetRotation(45.0)
b2dDrawImage(circle, 600, 300)
; Free when done
b2dFreeImage(circle)