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

**URL:** <https://racket.discourse.group/t/wanting-more-general-constraint-functional-graphics-in-2d-and-3d/3807>\
**Category:** General\
**Created:** [June 26, 2025, 10:19pm UTC](https://racket.discourse.group/t/wanting-more-general-constraint-functional-graphics-in-2d-and-3d/3807 "2025-06-26T22:19:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greg\_Davidson](https://avatars.discourse-cdn.com/v4/letter/g/5f8ce5/32.png) [@Greg\_Davidson](https://racket.discourse.group/u/Greg_Davidson)\
**Post date:** [June 26, 2025, 10:19pm UTC](https://racket.discourse.group/t/wanting-more-general-constraint-functional-graphics-in-2d-and-3d/3807/1 "2025-06-26T22:19:34Z")

</div>

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?
  - (Thinking of X3D and Pict3D for 3D.)  
It seems that we have all of the pieces we need, but in fragments.  
Is anyone else interested in such a development path, especially  
seeking an elegant result rather than increased complexity?  
Related discourse at [Pict and Constraint Graphics? · Issue #76 · racket/pict · GitHub](https://github.com/racket/pict/issues/76)

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [June 26, 2025, 11:17pm UTC](https://racket.discourse.group/t/wanting-more-general-constraint-functional-graphics-in-2d-and-3d/3807/2 "2025-06-26T23:17:37Z")

</div>

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.

```scheme
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.

```scheme
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.

```scheme
(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.

> **[GitHub - soegaard/linear: Describe variables declaratively using linear...](https://github.com/soegaard/linear)**
>
> Describe variables declaratively using linear equations.
