Skip to content

Commit

Permalink
bump glgl version to include Spline3Sampler
Browse files Browse the repository at this point in the history
  • Loading branch information
soypat committed Nov 21, 2024
1 parent 804badd commit ca290d8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
38 changes: 22 additions & 16 deletions forge/textsdf/glyph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import (

"github.com/soypat/glgl/math/ms2"
"github.com/soypat/gsdf"
"github.com/soypat/gsdf/gleval"
"github.com/soypat/gsdf/gsdfaux"
)

type glyph struct {
}

func TestABC(t *testing.T) {
bz := ms2.SplineBezier()
spline := []ms2.Vec{
{0, 0},
{1, 0},
Expand All @@ -23,13 +21,21 @@ func TestABC(t *testing.T) {
var poly ms2.PolygonBuilder
circle := bld.NewCircle(0.1)
shape := bld.Translate2D(circle, spline[0].X, spline[1].Y)
sampler := ms2.Spline3Sampler{
Spline: ms2.SplineBezier(),
Tolerance: 0.01,
}

for i := 0; i < len(spline); i += 4 {
v0, v1, v2, v3 := spline[4*i], spline[4*i+1], spline[4*i+2], spline[4*i+3]

shape = bld.Union2D(shape, bld.Translate2D(circle, v1.X, v1.Y))
shape = bld.Union2D(shape, bld.Translate2D(circle, v2.X, v2.Y))
for x := float32(0.0); x < 1; x += 1. / 64 {
vx := bz.Evaluate(x, v0, v1, v2, v3)
poly.Add(vx)

sampler.SetSplinePoints(v0, v1, v2, v3)
points := sampler.SampleBisectWithExtremes(nil, 2)
for _, pt := range points {
poly.Add(pt)
}
}
v, err := poly.AppendVecs(nil)
Expand All @@ -38,13 +44,13 @@ func TestABC(t *testing.T) {
}

shape = bld.Union2D(shape, bld.NewPolygon(v))
// _ = shape
// sdfcpu, err := gleval.NewCPUSDF2(shape)
// if err != nil {
// t.Fatal(err)
// }
// err = gsdfaux.RenderPNGFile("shape.png", sdfcpu, 512, nil)
// if err != nil {
// t.Fatal(err)
// }
_ = shape
sdfcpu, err := gleval.NewCPUSDF2(shape)
if err != nil {
t.Fatal(err)
}
err = gsdfaux.RenderPNGFile("shape.png", sdfcpu, 512, nil)
if err != nil {
t.Fatal(err)
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
github.com/soypat/glgl v0.0.0-20241117161642-84ce0213c9ea
github.com/soypat/glgl v0.0.0-20241121001014-cc8498d2a83d
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ github.com/soypat/glgl v0.0.0-20241019203012-a2ad2ed164c2 h1:N/GkdilItOR9bBrGXIj
github.com/soypat/glgl v0.0.0-20241019203012-a2ad2ed164c2/go.mod h1:1LcEp6XHSMCI91WlJHzl/aW4Bp5v6yQOiYFyjrlk350=
github.com/soypat/glgl v0.0.0-20241117161642-84ce0213c9ea h1:bPlNmRe3fBJQPzqNWUN2ChFZJgGo+jk056+wpAzEX+w=
github.com/soypat/glgl v0.0.0-20241117161642-84ce0213c9ea/go.mod h1:1LcEp6XHSMCI91WlJHzl/aW4Bp5v6yQOiYFyjrlk350=
github.com/soypat/glgl v0.0.0-20241121001014-cc8498d2a83d h1:kDdWM661L/RAxg0j4gV+18hky7/3Tvbhd8O6p8CLB7w=
github.com/soypat/glgl v0.0.0-20241121001014-cc8498d2a83d/go.mod h1:1LcEp6XHSMCI91WlJHzl/aW4Bp5v6yQOiYFyjrlk350=
golang.org/x/exp v0.0.0-20221230185412-738e83a70c30 h1:m9O6OTJ627iFnN2JIWfdqlZCzneRO6EEBsHXI25P8ws=
golang.org/x/exp v0.0.0-20221230185412-738e83a70c30/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/image v0.22.0 h1:UtK5yLUzilVrkjMAZAZ34DXGpASN8i8pj8g+O+yd10g=
Expand Down

0 comments on commit ca290d8

Please sign in to comment.