Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Note that this uses a traditional, intuitive coordinate system where the origin is at the lower left corner where increasing x goes right, increasing y goes up, rather than that y-is-down bullshit* someone decided computers should use. (*I'm sure there was a very good reason at the time, but seriously?)
- $maxsep = 4px; // Defines the maximum separation that can be considered "near", or more accurately the variable used for that.
- pred __near_boundary_point__[null](pnt, from) := sqrt((from.x-pnt.x^2)+(from.y-pnt.y)^2) <= $maxsep; // One colon; defines that a point is considered "NEAR" to another (without modifiers, hence the "null"; if it was something else it would define a different type of nearness) if it is within 4px away, based on the standard (Pythagorean) distance formula
- pred __near_boundary_num__(num, rel) := abs(num-rel) <= $maxsep // The [null] can be implicit; it was used above for the sole purpose of clarity that alternative nearness can be used.
- baseline ::= LINE ALONG y = 0; // The baseline is at the bottom of the document
- topline ::= LINE ALONG y=16; // Letters are 16 pixels tall
- letter['LATIN CAPITAL LETTER A'] ::= // The capital "A" character; moves along
- left_ln:=(LINE FROM (start_x, start_y) NEAR baseline TO (peak_x, peak_y) NEAR topline),
- right_ln:=(LINE FROM NEAR (peak_x, peak_y) TO (NEAR start_x+12, NEAR start_y)), // The right down-sloping line ends roughly 3/4 of the height left of the left up-sloping line
- cross_ln:=LINE FROM (NEAR left_ln.x_at(cross_y1), cross_y1:=(NEAR 10px)) TO (NEAR right_ln.x_at(cross_y2), cross_y2:=(NEAR 10px)); // Here we see algebraic matching; allows a variable number to be used, then that number to be used again somewhere else.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement