Skip to content

UXAndroidGraphics

UXAndroidGraphics is the Android realization of UXGraphics.

#use <UXKit> // or #import "UXAndroidGraphics.xc"

The operations act on the android.graphics.Canvas for the current draw, reached through JNI in libUXAndroid.c.

Incoming coordinates are bounds-relative, and the bound origin makes them absolute. Android’s Canvas grows y down, so nothing needs flipping. The same is true on cairo, Canvas2D and UIKit.

The drawing surface is not always a window:

UXDrawView.onDrawthe real thing, on screen
the offscreen Bitmap rigthe same drawing, into a buffer that can be read back

The vocabulary does not know which surface it has. Both are a Canvas, so the same code path produces the pixels in either case.

This allows visual checking on Android without a screen: draw into a Bitmap, read it back, and compare. If offscreen rendering used a different path, the checks would test something other than what ships.

Unlike the in-process vocabularies, each primitive here is a JNI call. Each call has a real cost, so the primitive set is small and coarse: fill a rectangle, fill a polygon, draw text, draw a line.

A protocol with a per-pixel or per-vertex entry point would be unusable across this boundary. Designing for the narrowest backend keeps the same protocol viable on all of them.

UXCanvasGraphics has the same constraint, with a wasm-to-JS boundary in place of native-to-Java.

strokesNatively() // true

Canvas strokes paths with joins and caps, so a path goes to it directly and not through the neutral offsetter. Arrowheads stay neutral, as on every backend.