diff --git a/ag_art361.go b/ag_art361.go new file mode 100644 index 0000000..34cd045 --- /dev/null +++ b/ag_art361.go @@ -0,0 +1,252 @@ +package main + +import "math" + +// Distinct bounded procedural illustrations, not reconstruction or solvers. +func agArt361(mode int, u, v, t, scale, dep, nx, ny, nz, edge, audio, beat float64, obstacle, hasDepth bool, room, colA, colB rgb) rgb { + x, y := (u-.5)*1.6*scale, (v-.5)*scale + r := math.Hypot(x, y) + a := math.Atan2(y, x) + glow := func(d, w float64) float64 { + d = math.Abs(d) + if d > w*8 { + return 0 + } + return math.Exp(-d / w) + } + line := func(ax, ay, bx, by, w float64) float64 { + if x < math.Min(ax, bx)-w*8 || x > math.Max(ax, bx)+w*8 || y < math.Min(ay, by)-w*8 || y > math.Max(ay, by)+w*8 { + return 0 + } + dx, dy := bx-ax, by-ay + f := 0. + if dx*dx+dy*dy > 1e-9 { + f = clamp01(((x-ax)*dx + (y-ay)*dy) / (dx*dx + dy*dy)) + } + return glow(math.Hypot(x-ax-dx*f, y-ay-dy*f), w) + } + pal := func(z float64) rgb { + return rgb{float32(.5 + .5*math.Cos(z)), float32(.5 + .5*math.Cos(z+2.1)), float32(.5 + .5*math.Cos(z+4.2))} + } + c := rgb{room.r * .04, room.g * .04, room.b * .04} + add := func(z float64, q rgb) { c.r += float32(z) * q.r; c.g += float32(z) * q.g; c.b += float32(z) * q.b } + gold, cyan, violet, green := rgb{1, .6, .12}, rgb{.12, .85, 1}, rgb{.65, .2, 1}, rgb{.12, .8, .28} + switch mode { + case 2: // Polygonal basalt plates, glowing broken seams. + fx, fy := frac(u*7*scale+.08*math.Sin(v*10)), frac(v*5*scale+.06*math.Cos(u*13)) + d := math.Min(math.Min(fx, 1-fx), math.Min(fy, 1-fy)) + add(.06+.06*math.Sin(u*20+v*15), colA) + add(glow(d, .025)*(.55+.3*math.Sin(t+u*8)), rgb{1, .17, .025}) + case 5: // Nacre shell with curved iridescent bands. + xx, yy := x/.48, y/.37 + rr := math.Hypot(xx, yy) + if rr < 1 { + z := math.Sqrt(1 - rr*rr) + add(.22+.55*z, pal(rr*25+t*.6+nx*3)) + add(glow(rr-.96, .012), colA) + } + case 10: // Braided marbling ribbons. + f := math.Sin(x*9+math.Sin(y*7+t*.4)*1.4) + math.Cos(y*11-t*.5) + add(.15+.65*glow(f, .2), colA) + add(glow(f-.4, .035), colB) + case 17: // Two dye vortices and spiral wisps. + for k := 0; k < 2; k++ { + z := float64(k) + dx, dy := x+.25-z*.5, y + rr, aa := math.Hypot(dx, dy), math.Atan2(dy, dx) + spir := math.Sin(aa*3 + rr*28 - t*(1-z*2)) + add(glow(spir, .14)*math.Exp(-rr*3), pal(z*2+rr*4)) + } + case 21: // Two swaying vines with explicit leaf pairs. + for k := 0; k < 2; k++ { + z := float64(k) + xx := -.4 + z*.8 + .06*math.Sin(y*7+t*.6) + add(glow(x-xx, .006), green) + j := int(math.Round((y + .4) / .12)) + for n := j - 1; n <= j+1; n++ { + if n < 0 || n > 7 { + continue + } + yy := -.4 + float64(n)*.12 + cx := -.4 + z*.8 + .06*math.Sin(yy*7+t*.6) + for _, side := range []float64{-1, 1} { + dx, dy := (x-cx-side*.045)/.055, (y-yy+.025)/.022 + if dx*dx+dy*dy < 1 { + add(.3+.4*(1-dx*dx-dy*dy), green) + } + } + } + } + case 29: // Rotating petal silhouettes falling through the mapped surface. + for k := 0; k < 14; k++ { + z := float64(k) + cx := -.7 + 1.4*frac(z*.618+t*.025) + cy := -.48 + .96*frac(z*.371+t*.07) + dx, dy := x-cx, y-cy + ang := z + t*.4 + xx, yy := (dx*math.Cos(ang)+dy*math.Sin(ang))/.045, (-dx*math.Sin(ang)+dy*math.Cos(ang))/.018 + if xx*xx+yy*yy < 1 { + add(.5+.4*(1-xx*xx-yy*yy), pal(z*.1+5.3)) + } + } + case 30: // Two meshing toothed brass wheels. + for k := 0; k < 2; k++ { + z := float64(k) + dx, dy := x+.2-z*.4, y + rr, aa := math.Hypot(dx, dy), math.Atan2(dy, dx) + ang := aa + t*(1-z*2)*.4 + z*.15 + outer := .18 + .018*math.Tanh(math.Sin(ang*16)*5) + if rr < outer && rr > .10 { + add(.45+.35*math.Cos(aa-.8), gold) + } + if rr < .16 && rr > .035 && math.Abs(math.Sin(ang*5)) < .12 { + add(.65, gold) + } + add(glow(rr-.035, .003), cyan) + } + case 39: // Three tilted rotating gyroscope ellipses. + for k := 0; k < 3; k++ { + z := float64(k) + ang := z*math.Pi/3 + t*.3 + xx, yy := x*math.Cos(ang)+y*math.Sin(ang), -x*math.Sin(ang)+y*math.Cos(ang) + rr := math.Hypot(xx, yy/(.3+.2*math.Sin(t*.3+z))) + add(glow(rr-.33, .004), pal(z*1.6)) + add(glow(r-.035, .006), gold) + } + case 40: // Warm arch and receding floor tiles, not a generated library. + if !obstacle && (!hasDepth || dep >= .34) { + add(.09+.035*math.Sin(x*6+t*.3), gold) + for k := 0; k < 7; k++ { + s := .9 - float64(k)*.1 + arch := math.Max(math.Abs(x)/(.36*s), math.Max(y/(.4*s), -y/(.3*s))) + if y < 0 { + arch = math.Hypot(x/(.36*s), y/(.3*s)) + } + add(glow(arch-1, .015), gold) + } + for k := 0; k < 7; k++ { + yy := .05 + float64(k)*.055 + .008*math.Sin(t*.4) + add(line(-.32, yy, .32, yy, .002)*.4, colB) + } + } else { + add(.25, room) + add(edge*.7, gold) + } + case 43: // Jagged crystal aperture with layered facets. + if !obstacle && (!hasDepth || dep >= .34) { + for k := 0; k < 9; k++ { + z := float64(k) + rr := .1 + z*.033 + .02*math.Cos(a*7+z*.4+t*.2) + add(glow(r-rr, .004), pal(4+z*.25)) + } + fac := math.Max(0, math.Cos(a*7+t*.2)) + add(.13+.15*fac, violet) + } else { + add(.2, room) + add(edge*.7, violet) + } + case 50: // Sand nodal plate; actual audio perturbs nodal phase. + f := math.Cos(u*math.Pi*5)*math.Cos(v*math.Pi*3) - math.Cos(u*math.Pi*3)*math.Cos(v*math.Pi*5) + f += (.025 + audio*.3 + beat*.2) * math.Sin(t*2+u*4) + add(glow(f, .08)*(1+audio*.4), gold) + add(glow(r-.4, .002), cyan) + add((audio*.08+beat*.10)*(.5+.5*math.Sin(u*11+v*9+t)), gold) + case 58: // Radial cymatic flower, amplitude comes from real audio. + add((audio*.08+beat*.10)*(.5+.5*math.Sin(a*6+t)), colA) + rad := .22 + .05*math.Sin(a*10+t*.35)*(1+audio*.8) + add(glow(r-rad, .006), colA) + for k := 0; k < 3; k++ { + z := float64(k) + add(glow(r-(.1+z*.075+.015*math.Cos(a*6-t*.4)), .003)*(1+beat*.4), pal(z+4)) + } + case 61: // Layered aurora curtains. + for k := 0; k < 5; k++ { + z := float64(k) + yy := -.2 + z*.07 + .1*math.Sin(x*6+t*.35+z*.5) + add(glow(y-yy, .02)*(.5+.5*math.Pow(.5+.5*math.Sin(x*47+t+z), 2)), pal(1+z*.3)) + } + case 63: // Authored frost fern plus a real-outline edge accent. + growth := .35 + .2*math.Sin(t*.25) + // Fold the six identical arms into one sector before drawing its branches. + aa := a - math.Round(a/(math.Pi/3))*(math.Pi/3) + x, y = r*math.Cos(aa), r*math.Sin(aa) + add(line(0, 0, growth, 0, .003), cyan) + for j := 1; j < 5; j++ { + d := float64(j) * growth / 5 + for _, side := range []float64{-1, 1} { + add(line(d, 0, d+.06*math.Cos(.8), side*.06*math.Sin(.8), .002), rgb{.7, .9, 1}) + } + } + + add(edge*(.3+.2*math.Sin(t)), cyan) + case 75: // Rectilinear neon traces and moving corner runners. + for k := 0; k < 4; k++ { + z := float64(k) + xx := -.6 + z*.35 + yy := -.3 + z*.17 + add(line(xx, -.42, xx, yy, .003), cyan) + add(line(xx, yy, .65, yy, .003), gold) + px := xx + (.65-xx)*frac(t*.2+z*.21) + add(glow(math.Hypot(x-px, y-yy), .015), rgb{1, 1, 1}) + } + add(edge*.5, cyan) + case 79: // Animated wire terrain with explicit perspective. + if y > -.15 { + zz := 1 / (y + .2) + gx := math.Abs(frac(x*zz*1.2) - .5) + gy := math.Abs(frac(zz*.23-t*.35+.15*math.Sin(x*5+dep)) - .5) + add(glow(gx, .025)+glow(gy, .025), cyan) + } + case 80: // Rose window with leaded radial petals and concentric rims. + for _, rr := range []float64{.1, .25, .39} { + add(glow(r-rr, .004), gold) + } + pet := .24 + .09*math.Cos(a*12) + add(glow(r-pet, .007), colA) + if r < .38 { + add(.15+.25*math.Pow(.5+.5*math.Sin(a*12+t*.2), 2), pal(a*2+r*8)) + } + case 85: // Staggered stained-glass rectangles with dark leading. + row := math.Floor(v * 6 * scale) + fx, fy := frac(u*7*scale+row*.5), frac(v*6*scale) + lead := math.Min(math.Min(fx, 1-fx), math.Min(fy, 1-fy)) + if lead > .04 { + z := math.Floor(u*7*scale+row*.5) + row*7 + add(.35+.25*math.Sin(t*.4+z), pal(z*.71)) + } + add(glow(lead-.045, .01)*.2, gold) + case 90: // Dark lens with bright accretion ellipse. + if r > .09 { + for k := 0; k < 5; k++ { + z := float64(k) + add(glow(r-(.16+z*.04+.018*math.Sin(a*3+t*.3+z)), .003), pal(z*.7)) + } + add(glow(math.Hypot(x, y*3)-.27, .01), gold) + } else { + c = rgb{} + } + case 97: // Two orbiting plasma stars with a connecting luminous bridge. + ang := t * .35 + cx, cy := .26*math.Cos(ang), .2*math.Sin(ang) + for _, sign := range []float64{-1, 1} { + rr := math.Hypot(x-cx*sign, y-cy*sign) + col := gold + if sign < 0 { + col = cyan + } + add(glow(rr-.04, .012)+.2*glow(rr, .08), col) + } + add(line(-cx, -cy, cx, cy, .008)*(.5+.2*math.Sin(t)), violet) + } + shade := float32(.8 + .2*math.Max(0, -nx*.4+ny*.4+nz*.7)) + if hasDepth { + shade *= float32(.9 + .2*(1-dep)) + } + c = c.scale(shade) + if mode != 90 { + c.r += float32(edge * .04) + c.g += float32(edge * .05) + c.b += float32(edge * .06) + } + return rgb{float32(clamp01(float64(c.r))), float32(clamp01(float64(c.g))), float32(clamp01(float64(c.b)))} +} diff --git a/ag_effects_100.go b/ag_effects_100.go index bf5e18b..9e6ac8f 100644 --- a/ag_effects_100.go +++ b/ag_effects_100.go @@ -196,7 +196,8 @@ func isAG100FX(id string) bool { } func init() { - for _, ef := range AG100Effects { + for _, i := range agSelection361 { + ef:=agSpec361(i) fxCatalog = append(fxCatalog, fxInfo{ id: ef.ID, name: ef.Name, @@ -307,7 +308,7 @@ func RenderAG100PixelWithCtx(rid string, u, v, t, speed, scale, inten float64, c if inten > 4.0 { inten = 4.0 } - if math.IsNaN(speed) || math.IsInf(speed, 0) || speed <= 0 { + if math.IsNaN(speed) || math.IsInf(speed, 0) || speed == 0 || (speed < 0 && !agSelected361(ef.Mode)) { speed = 1 } if math.IsNaN(scale) || math.IsInf(scale, 0) || scale <= 0 { @@ -362,7 +363,8 @@ func RenderAG100PixelWithCtx(rid string, u, v, t, speed, scale, inten float64, c beat := 1.0 + 0.45*audioLevel + 0.55*beatPulse var r, g, b float64 - switch ef.Cat { + if agSelected361(ef.Mode){c:=agArt361(ef.Mode,u,v,tt,scale,dep,nx,ny,nz,edgeGlow,audioLevel,beatPulse,inObstacle,hasDepth,roomCol,colA,colB);r,g,b=float64(c.r),float64(c.g),float64(c.b)}else{ + switch ef.Cat { case 0: // Material Alchemy freq := (4.0 + fs*1.7) * scale pat := ag100FBM(u*freq+dep*2.0, v*freq+float64(sub)*0.7+tt*0.18) @@ -542,6 +544,7 @@ func RenderAG100PixelWithCtx(rid string, u, v, t, speed, scale, inten float64, c b = float64(roomCol.b)*0.24 + spiral*float64(colB.b) + core*float64(colA.b) + edgeGlow*0.6 } + } if hasDepth { relMod := 0.82 + 0.36*(1.0-dep) r *= relMod diff --git a/ag_effects_100_test.go b/ag_effects_100_test.go index 8ae4c6c..69027f3 100644 --- a/ag_effects_100_test.go +++ b/ag_effects_100_test.go @@ -123,8 +123,8 @@ func TestAG100CatalogCategoriesAndIDs(t *testing.T) { catHit++ } } - if catHit != 100 { - t.Fatalf("expected 100 AG100 effects in fxCatalog, found %d", catHit) + if catHit != 20 { + t.Fatalf("expected 20 selectable AG100 effects in fxCatalog, all100 saved IDs retained, found %d", catHit) } } diff --git a/ag_effects_100_ui_windows.go b/ag_effects_100_ui_windows.go index b842192..5ff6c7a 100644 --- a/ag_effects_100_ui_windows.go +++ b/ag_effects_100_ui_windows.go @@ -20,9 +20,9 @@ var ag100Bar = fxStdBar{ var ag100UI = struct { mu sync.Mutex sel int - cat int // -1 = All (100), 0..9 = category index + cat int // -1 = All (20), 0..9 = category index status string -}{sel: 0, cat: -1} +}{sel: 2, cat: -1} func init() { for i, n := range pageNames { @@ -40,13 +40,7 @@ func init() { } func ag100VisibleIndices(cat int) []int { - var out []int - for i, ef := range AG100Effects { - if cat < 0 || ef.Cat == cat { - out = append(out, i) - } - } - return out + return agVisible361(cat) } func ag100RGBHex(c [3]float32) string { @@ -58,9 +52,9 @@ func ag100RGBHex(c [3]float32) string { func ag100AssignNow() Assign { ag100UI.mu.Lock() - i := clampi(ag100UI.sel, 0, len(AG100Effects)-1) + i := agChoice361(ag100UI.sel) ag100UI.mu.Unlock() - ef := AG100Effects[i] + ef := agSpec361(i) return Assign{ Type: "fx", ID: ef.ID, @@ -97,9 +91,9 @@ func (a *app) ag100Hooks() fxStdHooks { owns: isAG100FX, name: func() string { ag100UI.mu.Lock() - i := clampi(ag100UI.sel, 0, len(AG100Effects)-1) + i := agChoice361(ag100UI.sel) ag100UI.mu.Unlock() - return AG100Effects[i].Name + return agSpec361(i).Name }, step: ag100StepChoice, note: func(s string) { @@ -115,7 +109,7 @@ func (a *app) ag100Hooks() fxStdHooks { return Scene{}, false } ag100UI.mu.Lock() - i := clampi(ag100UI.sel, 0, len(AG100Effects)-1) + i := agChoice361(ag100UI.sel) ag100UI.mu.Unlock() as := ag100AssignNow() m := map[string]Assign{} @@ -124,7 +118,7 @@ func (a *app) ag100Hooks() fxStdHooks { m[sf.ID] = as } } - return Scene{Name: "AG100: " + AG100Effects[i].Name, Assign: m}, true + return Scene{Name: "Anti-Gravity: " + agSpec361(i).Name, Assign: m}, true }, } } @@ -147,12 +141,12 @@ func (a *app) ag100SyncLivePreview() { func (a *app) ag100Layout(add func(widget) int, rx, rw, y, bh, pad int) { ag100UI.mu.Lock() - sel := clampi(ag100UI.sel, 0, len(AG100Effects)-1) + sel := agChoice361(ag100UI.sel) cat := ag100UI.cat status := ag100UI.status ag100UI.mu.Unlock() - ef := AG100Effects[sel] + ef := agSpec361(sel) vis := ag100VisibleIndices(cat) posInCat := 1 for idx, v := range vis { @@ -171,7 +165,7 @@ func (a *app) ag100Layout(add func(widget) int, rx, rw, y, bh, pad int) { y += sc(h + 4) } - txt(fmt.Sprintf("Anti-Gravity Effects — Effect %d of %d (%s: %d of %d)", sel+1, len(AG100Effects), catLabel, posInCat, len(vis)), 32) + txt(fmt.Sprintf("Anti-Gravity Effects: %d of %d (%s: %d of %d)", agPosition361(sel), len(agSelection361), catLabel, posInCat, len(vis)), 32) y = a.fxStdBarLayout(add, ag100Bar, fxStdBarOpts{ Enabled: func(id int) bool { @@ -192,9 +186,9 @@ func (a *app) ag100Layout(add func(widget) int, rx, rw, y, bh, pad int) { // Category dropdown (All + 10 categories) dropItems := make([]string, 0, len(ag100CatNames)+1) - dropItems = append(dropItems, "All Categories (100 effects)") + dropItems = append(dropItems, "All Categories (20 effects)") for ci, cname := range ag100CatNames { - dropItems = append(dropItems, fmt.Sprintf("%02d. %s (10)", ci+1, cname)) + dropItems = append(dropItems, fmt.Sprintf("%02d. %s (2)", ci+1, cname)) } dropSel := cat + 1 if dropSel < 0 || dropSel >= len(dropItems) { @@ -209,10 +203,10 @@ func (a *app) ag100Layout(add func(widget) int, rx, rw, y, bh, pad int) { colW := (rw - sc(24) - sc(8)) / 2 for idx, spIdx := range vis { - sp := AG100Effects[spIdx] + sp := agSpec361(spIdx) col := idx % 2 lx := rx + sc(12) + col*(colW+sc(8)) - lbl := fmt.Sprintf("%03d. %s", spIdx+1, sp.Name) + lbl := fmt.Sprintf("%02d. %s", agPosition361(spIdx), sp.Name) if spIdx == sel { lbl = "▶ " + lbl } @@ -223,7 +217,7 @@ func (a *app) ag100Layout(add func(widget) int, rx, rw, y, bh, pad int) { } y += sc(4) - txt(fmt.Sprintf("%s [%s] — %s", ef.Name, ag100CatNames[ef.Cat], ef.Desc), 44) + txt(fmt.Sprintf("%s [%s]: %s", ef.Name, ag100CatNames[ef.Cat], ef.Desc), 76) if status != "" { txt(status, 24) } @@ -261,9 +255,10 @@ func (a *app) ag100Pick(id, k int) bool { func (a *app) ag100Command(id int) bool { if id >= idAG100CardBase && id < idAG100CardBase+len(AG100Effects) { idx := id - idAG100CardBase + if !agSelected361(idx){return false} ag100UI.mu.Lock() ag100UI.sel = idx - ag100UI.status = fmt.Sprintf("Selected %s (%d of %d)", AG100Effects[idx].Name, idx+1, len(AG100Effects)) + ag100UI.status = fmt.Sprintf("Selected %s (%d of %d)", agSpec361(idx).Name, agPosition361(idx), len(agSelection361)) ag100UI.mu.Unlock() a.ag100SyncLivePreview() return true diff --git a/ag_selection361.go b/ag_selection361.go new file mode 100644 index 0000000..734d1fe --- /dev/null +++ b/ag_selection361.go @@ -0,0 +1,43 @@ +package main + +// Keep original table positions and ID map intact for saved projects. +var agSelection361 = []int{2, 5, 10, 17, 21, 29, 30, 39, 40, 43, 50, 58, 61, 63, 75, 79, 80, 85, 90, 97} + +func agSelected361(i int) bool { + for _, n := range agSelection361 { + if n == i { + return true + } + } + return false +} +func agChoice361(i int) int { + if agSelected361(i) { + return i + } + return agSelection361[0] +} +func agPosition361(i int) int { + for p, n := range agSelection361 { + if n == i { + return p + 1 + } + } + return 1 +} +func agVisible361(cat int) []int { + out := make([]int, 0, 20) + for _, i := range agSelection361 { + if cat < 0 || AG100Effects[i].Cat == cat { + out = append(out, i) + } + } + return out +} +func agSpec361(i int) AG100EffectDef { + s := AG100Effects[agChoice361(i)] + names := map[int]string{2: "Basalt Ember Seams", 5: "Iridescent Nacre", 10: "Marbled Ribbons", 17: "Twin Dye Vortices", 21: "Swaying Leaf Vines", 29: "Drifting Petals", 30: "Brass Gear Pair", 39: "Gyroscope Rings", 40: "Warm Arch Portal", 43: "Crystal Aperture", 50: "Chladni Sand Plate", 58: "Cymatic Flower", 61: "Aurora Curtains", 63: "Frost Fern", 75: "Neon Trace Runners", 79: "Wireframe Terrain", 80: "Rose Window", 85: "Stained Glass", 90: "Accretion Lens", 97: "Binary Star Bridge"} + s.Name = names[agChoice361(i)] + s.Desc = "Animated illustration with exact output masks and optional relative-depth shading. Not measured reconstruction." + return s +} diff --git a/ag_selection361_test.go b/ag_selection361_test.go new file mode 100644 index 0000000..400cbdc --- /dev/null +++ b/ag_selection361_test.go @@ -0,0 +1,182 @@ +package main + +import ( + "bytes" + "fmt" + "image" + "image/color" + "image/png" + "math" + "os" + "path/filepath" + "testing" + "time" +) + +func Test361Selection20Archive100(t *testing.T) { + if len(AG100Effects) != 100 || len(agSelection361) != 20 { + t.Fatal("counts") + } + seen := map[int]bool{} + for cat := 0; cat < 10; cat++ { + if len(agVisible361(cat)) != 2 { + t.Fatal("category") + } + } + for _, i := range agSelection361 { + if seen[i] { + t.Fatal("duplicate") + } + seen[i] = true + } + for i, e := range AG100Effects { + if e.Mode != i || !isAG100FX(e.ID) || !fxKnown(e.ID) { + t.Fatal("saved ID lost", i, e.ID) + } + } +} +func Test361FiniteDistinctTimeAndInputs(t *testing.T) { + dir := os.Getenv("AG361_FRAMES") + if dir != "" { + os.MkdirAll(dir, 0755) + } + seen := map[string]int{} + for _, i := range agSelection361 { + e := AG100Effects[i] + var frames [][]byte + for j, tm := range []float64{0, 2, 5} { + im := image.NewRGBA(image.Rect(0, 0, 200, 125)) + for y := 0; y < 125; y++ { + for x := 0; x < 200; x++ { + c, ok := RenderAG100PixelWithCtx(e.ID, (float64(x)+.5)/200, (float64(y)+.5)/125, tm, 1, 1, 1, rgb{}, rgb{}, fxCtx{}) + if !ok || math.IsNaN(float64(c.r+c.g+c.b)) || math.IsInf(float64(c.r+c.g+c.b), 0) { + t.Fatal("finite", i) + } + im.SetRGBA(x, y, color.RGBA{uint8(c.r * 255), uint8(c.g * 255), uint8(c.b * 255), 255}) + } + } + frames = append(frames, im.Pix) + if dir != "" { + f, er := os.Create(filepath.Join(dir, fmt.Sprintf("%02d-%d.png", i, j))) + if er != nil { + t.Fatal(er) + } + png.Encode(f, im) + f.Close() + } + } + if bytes.Equal(frames[0], frames[1]) && bytes.Equal(frames[1], frames[2]) { + t.Error("static", i) + } + k := string(frames[1]) + if old, ok := seen[k]; ok { + t.Error("duplicate", old, i) + } + seen[k] = i + for _, bad := range []float64{0, -1, math.NaN()} { + c, _ := RenderAG100PixelWithCtx(e.ID, .3, .4, 2, 1, 1, bad, rgb{}, rgb{}, fxCtx{}) + if c != (rgb{}) { + t.Fatal("zero intensity", i) + } + } + a, _ := RenderAG100PixelWithCtx(e.ID, .3, .4, 2, 1, 1, 1, rgb{}, rgb{}, fxCtx{}) + b, _ := RenderAG100PixelWithCtx(e.ID, .3, .4, 2, 1, 1, 1, rgb{}, rgb{}, fxCtx{Audio: fxAudio{HasAudio: false, HasBeat: true, BeatPulse: 1, Level: 1}}) + if a != b { + t.Fatal("invented audio", i) + } + } +} + +func Test361ActualRendererAll100ExactMaskAndField(t *testing.T) { + p := roomTestProject(160, 100) + poly := [][2]float64{{.1, .1}, {.9, .1}, {.9, .9}, {.55, .9}, {.55, .6}, {.1, .6}} + p.Surfaces = []Surface{{ID: "wall", Cls: "wall", Poly: poly, Quad: polyBox(poly)}} + r := newRenderer(p, "") + defer r.closeVideoResources() + r.exportVirtual = true + dir := os.Getenv("AG361_FRAMES") + for i, e := range AG100Effects { + sc := &Scene{ID: "ag361", Assign: map[string]Assign{"wall": {Type: "fx", ID: e.ID, Inten: 1, Speed: 1, Scale: 1}}} + f := newFrame(160, 100) + r.RenderScene(sc, 2, f, 1, time.Unix(100, 0)) + lit := 0 + for y := 0; y < 100; y++ { + for x := 0; x < 160; x++ { + o := (y*160 + x) * 4 + if f.Pix[o]|f.Pix[o+1]|f.Pix[o+2] > 0 { + lit++ + if !pointInPolyXY((float64(x)+.5)/160, (float64(y)+.5)/100, poly) { + t.Fatal("outside", i, x, y) + } + } + } + } + if lit < 20 { + t.Error("blank", i) + } + if agSelected361(i) && dir != "" { + im := image.NewRGBA(image.Rect(0, 0, 160, 100)) + for y := 0; y < 100; y++ { + for x := 0; x < 160; x++ { + o := (y*160 + x) * 4 + im.SetRGBA(x, y, color.RGBA{f.Pix[o+2], f.Pix[o+1], f.Pix[o], 255}) + } + } + file, er := os.Create(filepath.Join(dir, fmt.Sprintf("mapped-%02d.png", i))) + if er != nil { + t.Fatal(er) + } + png.Encode(file, im) + file.Close() + } + } +} +func Benchmark361SelectedFields(b *testing.B) { + for _, i := range agSelection361 { + e := AG100Effects[i] + b.Run(fmt.Sprintf("mode%02d", i), func(b *testing.B) { + for n := 0; n < b.N; n++ { + prepareAG100Field(e.ID, 384, 216, float64(n)*.1, 1, 1, rgb{}, rgb{}, fxCtx{}) + } + }) + } +} + +func Test361SelectedControlAndPreparedColorParity(t *testing.T) { + for _, i := range agSelection361 { + e := AG100Effects[i] + c1, c2 := rgb{.7, .2, .1}, rgb{.2, .6, .8} + field := prepareAG100Field(e.ID, 48, 30, 2, 1, 1, c1, c2, fxCtx{}) + diffSpeed, diffScale := 0., 0. + for y := 0; y < 30; y++ { + for x := 0; x < 48; x++ { + u, v := float64(x)/47, float64(y)/29 + a, _ := RenderAG100PixelWithCtx(e.ID, u, v, 2, 1, 1, 1, c1, c2, fxCtx{}) + cached := sampleAG100Field(field, u, v, 1) + if math.Abs(float64(a.r-cached.r)) > 1.01/255 || math.Abs(float64(a.g-cached.g)) > 1.01/255 || math.Abs(float64(a.b-cached.b)) > 1.01/255 { + t.Fatal("cached color", i) + } + b, _ := RenderAG100PixelWithCtx(e.ID, u, v, 2, 2, 1, 1, c1, c2, fxCtx{}) + d, _ := RenderAG100PixelWithCtx(e.ID, u, v, 4, 1, 1, 1, c1, c2, fxCtx{}) + rev, _ := RenderAG100PixelWithCtx(e.ID, u, v, 2, -1, 1, 1, c1, c2, fxCtx{}) + neg, _ := RenderAG100PixelWithCtx(e.ID, u, v, -2, 1, 1, 1, c1, c2, fxCtx{}) + if b != d || rev != neg { + t.Fatal("speed/reverse", i) + } + half, _ := RenderAG100PixelWithCtx(e.ID, u, v, 2, 1, 1, .5, c1, c2, fxCtx{}) + if math.Abs(float64(half.r-a.r*.5))+math.Abs(float64(half.g-a.g*.5))+math.Abs(float64(half.b-a.b*.5)) > .00001 { + t.Fatal("intensity", i) + } + sc, _ := RenderAG100PixelWithCtx(e.ID, u, v, 2, 1, 1.5, 1, c1, c2, fxCtx{}) + diffSpeed += math.Abs(float64(a.r-b.r)) + math.Abs(float64(a.g-b.g)) + math.Abs(float64(a.b-b.b)) + diffScale += math.Abs(float64(a.r-sc.r)) + math.Abs(float64(a.g-sc.g)) + math.Abs(float64(a.b-sc.b)) + } + } + if diffSpeed < .01 { + t.Fatal("speed static", i) + } + if diffScale < .01 { + t.Fatal("scale does not change authored mode", i) + } + } +} diff --git a/ag_selection361_windows_test.go b/ag_selection361_windows_test.go new file mode 100644 index 0000000..8d0b8b9 --- /dev/null +++ b/ag_selection361_windows_test.go @@ -0,0 +1,35 @@ +//go:build windows + +package main + +import "testing" + +func Test361UISelectionKeepsAllSavedIDs(t *testing.T) { + ag100UI.mu.Lock() + oldSel, oldCat := ag100UI.sel, ag100UI.cat + ag100UI.cat = -1 + ag100UI.mu.Unlock() + defer func() { ag100UI.mu.Lock(); ag100UI.sel, ag100UI.cat = oldSel, oldCat; ag100UI.mu.Unlock() }() + a := &app{} + for i := 0; i < 100; i++ { + ok := a.ag100Command(idAG100CardBase + i) + if ok != agSelected361(i) { + t.Fatal("hidden card", i) + } + if ok && ag100AssignNow().ID != AG100Effects[i].ID { + t.Fatal("saved ID changed", i) + } + } + for cat := 0; cat < 10; cat++ { + ag100UI.mu.Lock() + ag100UI.cat = cat + ag100UI.sel = agVisible361(cat)[0] + ag100UI.mu.Unlock() + first := ag100UI.sel + ag100StepChoice(1) + ag100StepChoice(1) + if ag100UI.sel != first { + t.Fatal("step escaped category") + } + } +} diff --git a/common.go b/common.go index b8d71e1..59d4cf5 100644 --- a/common.go +++ b/common.go @@ -11,7 +11,7 @@ import ( "time" ) -const version = "0.98.360-experimental1" +const version = "0.98.361-experimental1" const appDisplayName = "Projection Mapper - Built by Instinct" diff --git a/effect_browser_catalog326_windows.go b/effect_browser_catalog326_windows.go index 8027378..09449a3 100644 --- a/effect_browser_catalog326_windows.go +++ b/effect_browser_catalog326_windows.go @@ -97,7 +97,7 @@ func (a *app) effectCatalog326(page int) (items []effectBrowserItem326, selected add(e.ID, e.ID, e.Name, e.Category, i, i == sel) } case ag100PageIdx: - ag100UI.mu.Lock();sel:=ag100UI.sel;ag100UI.mu.Unlock();for i,e:=range AG100Effects{add(e.ID,e.ID,e.Name,ag100CatNames[e.Cat],i,i==sel)} + ag100UI.mu.Lock();sel:=ag100UI.sel;ag100UI.mu.Unlock();for _,i:=range agSelection361{e:=agSpec361(i);add(e.ID,e.ID,e.Name,ag100CatNames[e.Cat],i,i==sel)} case botanicalPageIdx: for i,e:=range botanicalEffects{add(e.ID,e.ID,e.Name,e.Category,i,int(botanicalSel.Load())==i)} case carbonPageIdx: @@ -202,7 +202,7 @@ func (a *app) effectSelect326(page int, key string) bool { roomFXQueueUI.page = i / roomFXQueuePageSize roomFXQueueUI.mu.Unlock() case ag100PageIdx: - ag100UI.mu.Lock();ag100UI.sel=i;ag100UI.mu.Unlock() + if !agSelected361(i){return false};ag100UI.mu.Lock();ag100UI.sel=i;ag100UI.mu.Unlock() case botanicalPageIdx: botanicalSel.Store(int32(i)) case agPageIdx: diff --git a/effectmap.go b/effectmap.go index f99ddd8..f187980 100644 --- a/effectmap.go +++ b/effectmap.go @@ -101,6 +101,7 @@ func effectFor(cls, theme string) (effRow, bool) { func fxKnown(id string) bool { + if isAG100FX(id){return true} if id == "" { return false } diff --git a/library_preview_windows.go b/library_preview_windows.go index 136d49f..434085e 100644 --- a/library_preview_windows.go +++ b/library_preview_windows.go @@ -186,7 +186,7 @@ func (a *app) librarySample() (string, string, *Frame) { case carbonPageIdx: as:=carbonAssignCurrent();return effectName(as.ID),"Current outlines in photo coordinates. Not calibrated projector output.",a.libraryAssignSample(as) case ag100PageIdx: - ag100UI.mu.Lock();i:=clampi(ag100UI.sel,0,len(AG100Effects)-1);ag100UI.mu.Unlock();ef:=AG100Effects[i];return ef.Name,"Current outlines in photo coordinates. "+ef.Desc,a.libraryAssignSample(ag100AssignNow()) + ag100UI.mu.Lock();i:=agChoice361(ag100UI.sel);ag100UI.mu.Unlock();ef:=agSpec361(i);return ef.Name,"Current outlines in photo coordinates. "+ef.Desc,a.libraryAssignSample(ag100AssignNow()) case botanicalPageIdx: return botanicalSelected().Name,"Authored synthetic silhouette illustration only, not your body or a live camera frame. Actual projector output is black until fresh real segmentation is explicitly started.",botanicalIllustration() case chimeraPageIdx: