Skip to content

Commit

Permalink
Updated to use new TextureRGBA
Browse files Browse the repository at this point in the history
  • Loading branch information
jphsd committed Sep 9, 2024
1 parent 56859d6 commit d5104b4
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 23 deletions.
9 changes: 4 additions & 5 deletions cmd/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ func main() {
res := image.NewRGBA(image.Rect(0, 0, width*3, height))
cf := random.MakeComponent()
// Color
img := texture.NewRGBA(width, height, cf.Color, 0, 0, 1, 1)
img := texture.NewTextureRGBA(width, height, cf.Color, 0, 0, 1, 1, false)
draw.Draw(res, image.Rect(0, 0, width, height), img, image.Point{}, draw.Src)
// Alpha
alpha := texture.NewColorGray(cf.Value)
img = texture.NewRGBA(width, height, alpha, 0, 0, 1, 1)
draw.Draw(res, image.Rect(width, 0, 2*width, height), img, image.Point{}, draw.Src)
gimg := texture.NewTextureGray16(width, height, cf.Value, 0, 0, 1, 1, false)
draw.Draw(res, image.Rect(width, 0, 2*width, height), gimg, image.Point{}, draw.Src)
// Bump Map
bm := &surface.BumpMap{surface.DefaultAmbient, nil, nil, cf.Vector}
img = texture.NewRGBA(width, height, bm, 0, 0, 1, 1)
img = texture.NewTextureRGBA(width, height, bm, 0, 0, 1, 1, false)
draw.Draw(res, image.Rect(2*width, 0, 3*width, height), img, image.Point{}, draw.Src)
gi.SaveImage(res, fmt.Sprintf("%06d", cnt))
cnt++
Expand Down
3 changes: 1 addition & 2 deletions cmd/ifs.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ func main() {
xfm3 := g2d.BoxTransform(0, 0, 600, 0, 600, 200, 200, 400, 200, 400)
for i := 1; i < 7; i++ {
src := texture.NewIFS([]float64{float64(width), float64(height)}, []*g2d.Aff3{xfm1, xfm2, xfm3}, i)
cf := texture.NewColorGray(src)
img := texture.NewRGBA(width, height, cf, 0, 0, 1, 1)
img := texture.NewTextureGray16(width, height, src, 0, 0, 1, 1, false)
gi.SaveImage(img, fmt.Sprintf("ifs-%d", i))
}
}
2 changes: 1 addition & 1 deletion cmd/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func main() {
xfm.RotateAbout(rand.Float64()*math.Pi*2, float64(width)/2, float64(height)/2)
f3 := texture.NewTransformCF(f2, xfm)

out := texture.NewRGBA(width, height, f3, 0, 0, 1, 1)
out := texture.NewTextureRGBA(width, height, f3, 0, 0, 1, 1, false)
image.SaveImage(out, "image")
texture.SaveJSON(f3, "image")
}
6 changes: 3 additions & 3 deletions cmd/kaleido.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func main() {
for true {
a := 0.0
cf := random.MakeColorField(6, 0)
img := texture.NewRGBA(width, height, cf, 0, 0, 1, 1)
img := texture.NewTextureRGBA(width, height, cf, 0, 0, 1, 1, false)
gi.SaveImage(img, fmt.Sprintf("%06d-0k", cnt))

pts := make([][]float64, *n*2)
Expand All @@ -52,7 +52,7 @@ func main() {
}
cf = texture.NewReflectCF(cf, prev, pts[0])

img = texture.NewRGBA(width, height, cf, 0, 0, 1, 1)
img = texture.NewTextureRGBA(width, height, cf, 0, 0, 1, 1, false)
gi.SaveImage(img, fmt.Sprintf("%06d-1k", cnt))

// Zoom out
Expand All @@ -61,7 +61,7 @@ func main() {
xfm.ScaleAbout(2, 2, 400, 400)
cf = texture.NewTransformCF(cf, xfm)

img = texture.NewRGBA(width, height, cf, 0, 0, 1, 1)
img = texture.NewTextureRGBA(width, height, cf, 0, 0, 1, 1, false)
gi.SaveImage(img, fmt.Sprintf("%06d-2k", cnt))

cnt++
Expand Down
3 changes: 1 addition & 2 deletions cmd/morph.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func main() {

f3 := texture.NewEdge(f2, texture.Z4Support(1, 1))

cf2 := texture.NewColorGray(f3)
fimg := texture.NewRGBA(width, height, cf2, 0, 0, 1, 1)
fimg := texture.NewTextureGray16(width, height, f3, 0, 0, 1, 1, false)
image.SaveImage(fimg, "morph")
}
4 changes: 2 additions & 2 deletions cmd/radialref.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ func main() {
for true {
a := 0.0
cf := random.MakeColorField(6, 0)
img := texture.NewRGBA(width, height, cf, 0, 0, 1, 1)
img := texture.NewTextureRGBA(width, height, cf, 0, 0, 1, 1, false)
gi.SaveImage(img, fmt.Sprintf("%06d-0rr", cnt))

for i := 0; i < *n; i++ {
cf = texture.NewReflectCF(cf, []float64{400, 400}, []float64{400 + math.Cos(a)*r, 400 + math.Sin(a)*r})
a += da
}
img = texture.NewRGBA(width, height, cf, 0, 0, 1, 1)
img = texture.NewTextureRGBA(width, height, cf, 0, 0, 1, 1, false)
gi.SaveImage(img, fmt.Sprintf("%06d-1rr", cnt))

cnt++
Expand Down
2 changes: 1 addition & 1 deletion cmd/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func main() {
for cnt < 100 {
name := fmt.Sprintf("%06d", cnt)
cf := random.MakeColorField(6, 0)
img := texture.NewRGBA(width, height, cf, 0, 0, 1, 1)
img := texture.NewTextureRGBA(width, height, cf, 0, 0, 1, 1, false)
image.SaveImage(img, name)
texture.SaveJSON(cf, name)
cnt++
Expand Down
6 changes: 3 additions & 3 deletions cmd/triang.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func main() {
cnt := 0
for true {
cf := random.MakeColorField(6, 0)
img := texture.NewRGBA(width, height, cf, 0, 0, 1, 1)
img := texture.NewTextureRGBA(width, height, cf, 0, 0, 1, 1, false)
gi.SaveImage(img, fmt.Sprintf("%06d-0t", cnt))

cf = texture.NewReflectCF(cf, []float64{400, 100}, []float64{746, 700})
Expand All @@ -30,15 +30,15 @@ func main() {
// Repeat to catch other reflections
cf = texture.NewReflectCF(cf, []float64{400, 100}, []float64{746, 700})
cf = texture.NewReflectCF(cf, []float64{746, 700}, []float64{54, 700})
img = texture.NewRGBA(width, height, cf, 0, 0, 1, 1)
img = texture.NewTextureRGBA(width, height, cf, 0, 0, 1, 1, false)
gi.SaveImage(img, fmt.Sprintf("%06d-1t", cnt))

// Zoom out
xfm := g2d.NewAff3()
xfm.ScaleAbout(2, 2, 400, 400)
cf = texture.NewTransformCF(cf, xfm)

img = texture.NewRGBA(width, height, cf, 0, 0, 1, 1)
img = texture.NewTextureRGBA(width, height, cf, 0, 0, 1, 1, false)
gi.SaveImage(img, fmt.Sprintf("%06d-zt", cnt))

cnt++
Expand Down
6 changes: 2 additions & 4 deletions cmd/warp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package main

import (
g2d "github.com/jphsd/graphics2d"
"github.com/jphsd/graphics2d/image"
"github.com/jphsd/texture"
)
Expand All @@ -13,7 +12,6 @@ func main() {
width, height := 1000, 1000

f1 := texture.NewSquares(25)
cf := texture.NewColorGray(f1)

//rwf := IdentityWF{}
//rwf := texture.NewRadialWF([]float64{500, 500}, 1, 1)
Expand All @@ -26,9 +24,9 @@ func main() {
rwf := texture.NewRadialRippleWF([]float64{500, 500}, 100, 10, 0)
//rwf := texture.NewRadialWiggleWF([]float64{500, 500}, 100, 0.1, 0)

wf := texture.NewWarpCF(cf, rwf)
wf := texture.NewWarp(f1, rwf)

img := texture.NewRGBA(width, height, wf, 0, 0, 1, 1)
img := texture.NewTextureGray16(width, height, wf, 0, 0, 1, 1, false)

image.SaveImage(img, "warp")
}
Expand Down

0 comments on commit d5104b4

Please sign in to comment.