-
Notifications
You must be signed in to change notification settings - Fork 13
/
clipping.go
52 lines (42 loc) · 903 Bytes
/
clipping.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"github.com/buchanae/ink/clip"
. "github.com/buchanae/ink/color"
. "github.com/buchanae/ink/dd"
"github.com/buchanae/ink/gfx"
"github.com/buchanae/ink/tess"
)
func Ink(doc gfx.Doc) {
rect := RectCenter(Center, XY{.5, .5})
circle := Circle{
XY: XY{.25, .35},
Radius: .25,
Segments: 50,
}
/*
gfx.Fill{
Shape: rect,
Color: Red,
}.Draw(doc)
gfx.Fill{
Shape: circle,
Color: Blue,
}.Draw(doc)
*/
//points := Union(circle.Path(), rect.Path())
//points := Intersection(circle.Path(), rect.Path())
//points := Difference(circle.Path(), rect.Path())
points := clip.Difference(rect.Path(), circle.Path())
circleped := tess.Tesselate(points)
gfx.Fill{
Shape: Triangles(circleped),
Color: Yellow,
}.Draw(doc)
//gfx.Dots{points, Black, .005}.Draw(doc)
}
func flipColor(a bool, b, c RGBA) RGBA {
if a {
return b
}
return c
}