A painter maps a frame to a finite set of segments.
Vectors, segments, and frames form a geometric data language. A painter maps its unit-square endpoints through the frame supplied at application time.
Guiding question
How can one painter describe the same picture inside square, skewed, or scaled frames?
Represent vectors and segments with constructor-selector interfaces
Represent a frame with an origin and two edge vectors
Map unit-square coordinates into one concrete frame
Construct a painter as a procedure from frames to segment lists
Print machine-readable SEG lines without replacing the returned value
Read the monochrome SVG as a rendering of actual Lispex output
The segment data is written in unit-square coordinates. frame-coordinate-map takes a vector whose x and y components are relative positions and combines the frame origin with scaled copies of its two edge vectors. segments->painter captures a finite segment list and returns a procedure that maps every endpoint through the frame supplied later.
The first run places one outline-and-cross painter inside a square frame. The second applies a diamond painter to a skewed frame. The painter definitions do not contain the final page coordinates. Each run prints one SEG line per mapped segment, and the app-local visualizer parses those transcript lines into a monochrome SVG. The returned (segments n) value remains a separate observation.
Picture languageRender the segments produced by the program.
Loading runtime
No valid SEG lines were produced by this run.
0 segments rendered from program output.
Expected result
The first program prints six SEG lines and returns (segments 6). The second prints four transformed SEG lines and returns (segments 4). The SVG beside the workbench is parsed from those transcript lines.
Trace focus
Follow the painter application into frame-coordinate-map, then inspect each endpoint as the frame origin plus an x-scaled first edge and a y-scaled second edge. The transcript output and returned segment count remain separate observations.
Try it yourself
Change the program and compare the result.
Add the four midpoint-to-midpoint segments that form an inner diamond inside the first painter. Predict the new segment count, then confirm that the visualizer renders the additional shape from the SEG output.
Show hint
The side midpoints are (0.5, 0.0), (1.0, 0.5), (0.5, 1.0), and (0.0, 0.5). The painter remains independent of the final frame.