The summer holiday is getting closer. This means there is time to focus on hacking. Last year my summer project was to implement a matrix library and a number theory library.
This year I have decided to write a graphics library inspired by the approach taken by Metafont, Metapost and Tikz. The basic concept in these libraries is a path. The existing Racket library pict on the other hand is based on pictures.
Bezier curves will be used to draw the paths. Drawing a Bezier curve is straight forward; the builtin graphics library, racket/draw has support for this in the form of curve-to.
What is needed is convenient ways of specifying and manipulating paths.
The first problem will be this: Given points P0, P3, P6, ..., Pn. Draw a "pretty" curve through these points. That is, determine which Bezier curves is to be drawn between P0 and P3, between P3 and P6 etc.
John D. Hobby and Donald Knuth introduced the algorithm now known as "Hobby’s Algorithm" in Metafont to solve this problem. It is the central algorithm of the library.
The second problem is to introduce syntax for specifying paths. There is no doubt that the popularity of MetaPost in TeX circles is the concise syntax - so I’ll see how much it makes sense to steal.
The third problem is to support for specifying points based on linear equations. Luckily the grunt works is already done - the matrix library contains equation solvers.
Breaking large project into chunks help tremendously. Just witness how fast the number of completed Racket tasks went up on RosettaCode.
-
Draw a Bezier curve using racket/draw
-
Explain Hobby’s algorithm
-
Implement Hobby’s algorithm
-
Design syntax for paths
-
Implement syntax for paths
-
Document syntax for paths
-
Predefinitions for standard paths
-
Examples - inspration from the Metafontbook and Tikz
-
Linear expressions and "linear variables"
-
Syntax for linear expressions and linear variables.
-
From fonts to paths
-
Higher order path operations
-
Bounding boxes for paths
-
Intersections between curves
-
Coloration of areas
-
Bitmaps
-
Relation to picts?