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
00°0′0″
π/445°
π/290°
π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
drawCreate a shape on a layer
wipeRemove shapes from a layer
showShow canvas
hideHide 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):

CodeViolationMitigation / diagnostic action
E1301InvalidAngleFormat: Malformed degree/minute/second (° ′ ″) angular syntax.Correct the angular literal.
E1302LayerNotFound: draw on an unattached or non-existent layer.Attach the layer to the canvas first.
E1303NegativeRadius: Circle or polar point constructed with a negative radius r.Use a non-negative radius.
E1304PolygonVertexUnderflow: Polygon constructed with fewer than 3 vertex points.Supply at least 3 vertices.
E1305CanvasRenderError: Target canvas hardware context unavailable.Retry with a valid canvas context.