google / google/codeworld

Constructive geometry

Open
#28 2 comments 0 reactions 0 assignees View on GitHub
discussion
Dominant language
Haskell
Stars
1.3k
Forks
201
PR merge metrics
No merged PRs in 30d

Description

Additional operations should be added to combine shapes:

```
intersection :: [Picture] -> Picture
difference :: Picture -> Picture -> Picture
```

(Names are debatable.) `intersection` should produce a picture bounded by the intersection of the list. The second should produce a picture containing all areas of the first image that are not also in the second. Note that together with the existing `pictures`, this gives the three basic operations for constructive geometry.

The implementation is a little tricky. Combining two images in this way can be done with globalCompositeOperation (https://developer.mozilla.org/samples/canvas-tutorial/6_1_canvas_composite.html) But getting the resulting shapes to nest correctly will involve using off-screen canvases as temporaries. Since creating a new off-screen canvas is expensive, this should involve determining the minimum number of offscreen canvases needed, and reusing them between frames.

Contributor guide

Open the contributing guide

Research direction

Start by locating the existing `pictures` implementation and the canvas rendering entry point, then review how `globalCompositeOperation` and off-screen canvases can combine nested shapes. Determine the minimum reusable temporary canvases needed for `intersection` and `difference`; done means both operations produce the specified constructive-geometry regions without unnecessary per-frame canvas creation.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, javascript
Domain
computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.