update example

This commit is contained in:
elee 2022-03-25 14:24:52 -05:00
parent 6cce92813b
commit 0c69c2de8d
250 changed files with 18 additions and 13 deletions
common/nori
export.gonori_test.go
nori_test/palette.example
animation_0.pnganimation_1.pnganimation_10.apnganimation_10.pnganimation_100.apnganimation_100.pnganimation_101.apnganimation_101.pnganimation_102.pnganimation_103.pnganimation_104.apnganimation_104.pnganimation_105.apnganimation_105.pnganimation_106.apnganimation_106.pnganimation_107.apnganimation_107.pnganimation_108.apnganimation_108.pnganimation_109.apnganimation_109.pnganimation_11.apnganimation_11.pnganimation_110.apnganimation_110.pnganimation_111.apnganimation_111.pnganimation_112.apnganimation_112.pnganimation_113.apnganimation_113.pnganimation_114.apnganimation_114.pnganimation_115.apnganimation_115.pnganimation_116.apnganimation_116.pnganimation_117.apnganimation_117.pnganimation_118.apnganimation_118.pnganimation_119.apnganimation_119.pnganimation_12.apnganimation_12.pnganimation_120.apnganimation_120.pnganimation_121.apnganimation_121.pnganimation_122.apnganimation_122.pnganimation_123.apnganimation_123.pnganimation_124.pnganimation_125.pnganimation_126.pnganimation_127.pnganimation_128.pnganimation_129.pnganimation_13.apnganimation_13.pnganimation_130.pnganimation_131.pnganimation_132.pnganimation_133.apnganimation_133.pnganimation_134.apnganimation_134.pnganimation_135.apnganimation_135.pnganimation_136.apnganimation_136.pnganimation_137.pnganimation_138.pnganimation_139.pnganimation_14.apnganimation_14.pnganimation_140.pnganimation_15.apnganimation_15.pnganimation_157.pnganimation_158.pnganimation_159.pnganimation_16.pnganimation_160.pnganimation_161.pnganimation_162.pnganimation_163.pnganimation_166.pnganimation_17.apnganimation_17.pnganimation_18.pnganimation_19.apnganimation_19.pnganimation_2.pnganimation_20.pnganimation_21.png

View File

@ -38,14 +38,18 @@ func (n *Nori) ExportAnimation(num int) (*apng.APNG, error) {
for _, frame := range n.Animations[num].Frames {
planes := frame.Planes
var canvasRect image.Rectangle
for _, plane := range planes {
for i, plane := range planes {
if int(plane.BitmapId) >= len(n.Gawi.Images) {
log.Printf("could not find bitmap %d, only have %d", plane.BitmapId, len(n.Gawi.Images))
}
bitmap := n.Gawi.Images[plane.BitmapId]
pt := image.Pt(int(plane.PlaneX), int(plane.PlaneY)) // where to put the point
rc := bitmap.Img.Bounds()
canvasRect = canvasRect.Union(rc.Add(pt))
rc := bitmap.Img.Bounds().Add(pt) // translate rectangle to put in the global canvas
if i == 0 {
canvasRect = rc
} else {
canvasRect = canvasRect.Union(rc)
}
}
img := image.NewNRGBA64(canvasRect)
for _, plane := range planes {
@ -63,9 +67,8 @@ func (n *Nori) ExportAnimation(num int) (*apng.APNG, error) {
}
_ = transparent
pt := image.Pt(int(plane.PlaneX), int(plane.PlaneY)) // where to put the point
rc := bitmap.Img.Bounds().Add(pt)
src := bitmap.Img
sr := src.Bounds()
r := image.Rectangle{pt, pt.Add(sr.Size())}
switch plane.Blend {
case BlendMode_Alpha:
case BlendMode_Mul, BlendMode_Mul7:
@ -78,10 +81,11 @@ func (n *Nori) ExportAnimation(num int) (*apng.APNG, error) {
default:
return nil, fmt.Errorf("unknown blend mode: %d", plane.Blend)
}
draw.Draw(img,
r,
draw.Draw(
img,
rc,
src,
sr.Min,
src.Bounds().Min,
draw.Src,
)
}
@ -95,12 +99,14 @@ func (n *Nori) ExportAnimation(num int) (*apng.APNG, error) {
return nil, fmt.Errorf("no frames found for animation")
}
for i, realFrame := range images {
log.Info().Int("frame", num).Interface("rect", or).Interface("frame", realFrame.Bounds()).Msg("")
src := realFrame
big := image.NewNRGBA64(or)
draw.Draw(
big,
big.Rect,
realFrame,
realFrame.Bounds().Min,
src.Bounds(),
src,
src.Bounds().Min,
draw.Src,
)
fr := apng.Frame{
@ -112,6 +118,5 @@ func (n *Nori) ExportAnimation(num int) (*apng.APNG, error) {
}
a.Frames = append(a.Frames, fr)
}
log.Println(num, len(a.Frames))
return a, nil
}

View File

@ -75,7 +75,7 @@ func writeApng(nori *Nori, name string) error {
if err != nil {
return err
}
err = os.WriteFile(fmt.Sprintf("./nori_test/%s%s/animation_%d.apng", name, postfix, i), out.Bytes(), 0740)
err = os.WriteFile(fmt.Sprintf("./nori_test/%s%s/animation_%d.png", name, postfix, i), out.Bytes(), 0740)
if err != nil {
return err
}

Binary file not shown.

Before

(image error) Size: 22 KiB

Binary file not shown.

After

(image error) Size: 22 KiB

Binary file not shown.

Before

(image error) Size: 79 KiB

Binary file not shown.

After

(image error) Size: 79 KiB

Binary file not shown.

Before

(image error) Size: 79 KiB

Binary file not shown.

After

(image error) Size: 79 KiB

Binary file not shown.

Before

(image error) Size: 19 KiB

Binary file not shown.

After

(image error) Size: 19 KiB

Binary file not shown.

Before

(image error) Size: 18 KiB

Binary file not shown.

After

(image error) Size: 18 KiB

Binary file not shown.

Before

(image error) Size: 21 KiB

Binary file not shown.

After

(image error) Size: 21 KiB

Binary file not shown.

Before

(image error) Size: 24 KiB

Binary file not shown.

After

(image error) Size: 24 KiB

Binary file not shown.

Before

(image error) Size: 24 KiB

Binary file not shown.

After

(image error) Size: 24 KiB

Binary file not shown.

Before

(image error) Size: 24 KiB

Binary file not shown.

After

(image error) Size: 24 KiB

Binary file not shown.

Before

(image error) Size: 25 KiB

Binary file not shown.

After

(image error) Size: 25 KiB

Binary file not shown.

Before

(image error) Size: 21 KiB

Binary file not shown.

After

(image error) Size: 21 KiB

Binary file not shown.

Before

(image error) Size: 18 KiB

Binary file not shown.

After

(image error) Size: 18 KiB

Binary file not shown.

Before

(image error) Size: 24 KiB

Binary file not shown.

After

(image error) Size: 24 KiB

Binary file not shown.

Before

(image error) Size: 30 KiB

Binary file not shown.

After

(image error) Size: 30 KiB

Binary file not shown.

Before

(image error) Size: 30 KiB

Binary file not shown.

After

(image error) Size: 30 KiB

Binary file not shown.

Before

(image error) Size: 24 KiB

Binary file not shown.

After

(image error) Size: 24 KiB

Binary file not shown.

Before

(image error) Size: 23 KiB

Binary file not shown.

After

(image error) Size: 23 KiB

Binary file not shown.

Before

(image error) Size: 25 KiB

Binary file not shown.

After

(image error) Size: 25 KiB

Binary file not shown.

Before

(image error) Size: 30 KiB

Binary file not shown.

After

(image error) Size: 30 KiB

Binary file not shown.

Before

(image error) Size: 31 KiB

Binary file not shown.

After

(image error) Size: 31 KiB

Binary file not shown.

Before

(image error) Size: 24 KiB

Binary file not shown.

After

(image error) Size: 24 KiB

Binary file not shown.

Before

(image error) Size: 29 KiB

Binary file not shown.

After

(image error) Size: 29 KiB

Binary file not shown.

Before

(image error) Size: 31 KiB

Binary file not shown.

After

(image error) Size: 31 KiB

Binary file not shown.

Before

(image error) Size: 30 KiB

Binary file not shown.

After

(image error) Size: 30 KiB

Binary file not shown.

Before

(image error) Size: 24 KiB

Binary file not shown.

After

(image error) Size: 24 KiB

Binary file not shown.

Before

(image error) Size: 26 KiB

Binary file not shown.

After

(image error) Size: 26 KiB

Binary file not shown.

Before

(image error) Size: 23 KiB

Binary file not shown.

After

(image error) Size: 23 KiB

Binary file not shown.

Before

(image error) Size: 31 KiB

Binary file not shown.

After

(image error) Size: 31 KiB

Binary file not shown.

Before

(image error) Size: 31 KiB

Binary file not shown.

After

(image error) Size: 31 KiB

Binary file not shown.

Before

(image error) Size: 23 KiB

Binary file not shown.

After

(image error) Size: 23 KiB

Binary file not shown.

Before

(image error) Size: 22 KiB

Binary file not shown.

After

(image error) Size: 22 KiB

Binary file not shown.

Before

(image error) Size: 18 KiB

Binary file not shown.

After

(image error) Size: 18 KiB

Binary file not shown.

After

(image error) Size: 8.4 KiB

Binary file not shown.

Before

(image error) Size: 12 KiB

Binary file not shown.

After

(image error) Size: 12 KiB

Binary file not shown.

Before

(image error) Size: 12 KiB

After

(image error) Size: 12 KiB

Binary file not shown.

Before

(image error) Size: 8.4 KiB

Binary file not shown.

Before

(image error) Size: 8.4 KiB

After

(image error) Size: 8.4 KiB

Some files were not shown because too many files have changed in this diff Show More