Bee Graphics Specification
Bee provides native graphic support, focusing on dynamic 2D drawing within Cartesian spaces.
Coordinate Systems
Bee supports radians (π) and decimal degree notation.
| Symbol | Degree |
|---|---|
| 0 | 0°0′0″ |
| π/4 | 45° |
| π/2 | 90° |
| π | 180° |
| 2π | 360° |
Minutes and Seconds: Bee uses Unicode symbols prime (′) for minutes and double prime (″) for seconds of arc.
new α ∈ G := 180°;
new β ∈ G := 0°0′0″;
Graphic Types
| Type | Signature | Description |
|---|---|---|
| Canvas | {o ∈ P, w,h ∈ Z, m ∈ [Layer]} | Canvas with points and shapes |
| Layer | {c ∈ B, v ∈ B, m ∈ [Shape]} | Layer with color and shape set |
| Shape | {o ∈ P, s ∈ ⌂, θ ∈ G} | Shape with origin and rotation |
| Label | {o ∈ P, t ∈ S, α, β ∈ G} | Graphic label with rotation |
Drawing Elements
Graphic elements are composite data types.
| Name | Signature | Meaning |
|---|---|---|
| CRT | {x, y ∈ Q} | Cartesian Point |
| POL | {r ∈ R, θ ∈ G} | Polar Point |
| VEC | {o, p ∈ CRT} | Vector |
| CRC | {o ∈ CRT, r ∈ R} | Circle |
| SQR | {o ∈ CRT, b ∈ R, θ ∈ G} | Square with rotation |
| PLG | {v ∈ [CRT]} | Polygon Shape |
Geometric Congruence (≡)
The operator ≡ (U+2261) is reserved for geometric congruence only — it never expresses value equality (use =) or reference identity (use is / @a = @b). (spec/13 §5.1, Decision 2.)
Two shapes are ≡-congruent when they share identical interior/exterior angles, the same number of sides, and the same shape class, regardless of relative scale or position:
-- congruence test for polygons
rule main:
expect poly_a ≡ poly_b;
return;
Affine Transformations
Shapes respond to in-place affine transforms (spec/13 §5):
- shape.rotate(θ ∈ G) — rotate around the local origin by angle θ.
- shape.translate(dx, dy ∈ Q) — shift the origin by (dx, dy).
- shape.scale(factor ∈ R) — scale the shape dimensions.
Drawing Keywords
| Keyword | Description |
|---|---|
| draw | Create a shape on a layer |
| wipe | Remove shapes from a layer |
| show | Show canvas |
| hide | Hide canvas |
Drawing API example
-- create a 800x600 drawing canvas and a foreground layer
rule main:
new main_canvas := Canvas(o: {x: 0, y: 0}, w: 800, h: 600);
new foreground := Layer(id: "fg", visible: true);
apply main_canvas.add_layer(foreground);
-- build a circle marker and render it onto the layer
new circle_marker := CRC(o: {x: 10, y: 20}, r: 5);
draw circle_marker on foreground;
-- manage visibility
hide foreground;
show foreground;
wipe foreground; -- clear the layer
return;
Diagnostic error codes
Diagnostic codes raised by the Graphics module (spec/13 §7):
| Code | Violation | Mitigation / diagnostic action |
|---|---|---|
| E1301 | InvalidAngleFormat: Malformed degree/minute/second (° ′ ″) angular syntax. | Correct the angular literal. |
| E1302 | LayerNotFound: draw on an unattached or non-existent layer. | Attach the layer to the canvas first. |
| E1303 | NegativeRadius: Circle or polar point constructed with a negative radius r. | Use a non-negative radius. |
| E1304 | PolygonVertexUnderflow: Polygon constructed with fewer than 3 vertex points. | Supply at least 3 vertices. |
| E1305 | CanvasRenderError: Target canvas hardware context unavailable. | Retry with a valid canvas context. |