Wanting more general constraint/functional graphics in 2D and 3D

We have draw, pict, 2htdp/image, metapict and the ability to write svg files.
Learners who start with the Quick tutorial have to switch to image for the 2htdp tutorials.

  • Could we make it easier to use the two in combination?
  • Could we unify them into something all around better?
  • And maybe include Metapict too?
    SVG is an important 2D functional graphics system which Cairo can efficiently render
  • Could we have an SVG-oriented Racket Functional 2D graphics library?
  • Could this be unified with pict and 2htdp/image?
    We have various constraint solvers for Racket
  • Could we integrate such into our 2D and 3D graphics libraries?
1 Like

Hi Greg,

I have a small library that gives you "linear variables".
The idea was to recreate the variables used in MetaPost.
The idea is to use == to declare linear relations between variables.
A variable reference will give the value that satisfies the relations.

In the first example, the value of x1 is determined to be 6.

declare-variables.rkt>  
(let ()
  (declare x1 x2)
  (== (+ x1 1) 7)
  x1)
6

In the second example the system of equations is underdetermined,
so one only get an equation for x1.

declare-variables.rkt> 
(let ()
  (declare x1 x2)
  (== (+ x1 1) x2)
  x1)
"x1 = x2-1"

Adding a relation, we can see the results for both x1 and x2.

(let ()
  (declare x1 x2)
  (== (+ x1 1) x2)
  (== (* 2 x1) x2)
  (list x1 x2))
'(1 2)

Check the code. It contains examples.
Last time I looked at it is a couple of years ago.
If I remember correctly I was working on generalizing the equations to work on points too.
But I think I ran into some sort of problem.

Anyways, if you stick to linear relations as above, I expect it work.
At least you can experiment with drawing with constraints.

1 Like