show message while generating gif
This commit is contained in:
parent
07032da486
commit
18494bee45
3 changed files with 13 additions and 3 deletions
|
|
@ -363,7 +363,7 @@ func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, rende
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
out, err := xgif.AnimatePNGs(pngs, int(animateInterval))
|
out, err := xgif.AnimatePNGs(ms, pngs, int(animateInterval))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,13 @@ import (
|
||||||
"image/color"
|
"image/color"
|
||||||
"image/gif"
|
"image/gif"
|
||||||
"image/png"
|
"image/png"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ericpauley/go-quantize/quantize"
|
"github.com/ericpauley/go-quantize/quantize"
|
||||||
|
|
||||||
|
"oss.terrastruct.com/d2/lib/background"
|
||||||
"oss.terrastruct.com/util-go/go2"
|
"oss.terrastruct.com/util-go/go2"
|
||||||
|
"oss.terrastruct.com/util-go/xmain"
|
||||||
)
|
)
|
||||||
|
|
||||||
const INFINITE_LOOP = 0
|
const INFINITE_LOOP = 0
|
||||||
|
|
@ -26,7 +29,14 @@ const BG_INDEX uint8 = 255
|
||||||
|
|
||||||
var BG_COLOR = color.White
|
var BG_COLOR = color.White
|
||||||
|
|
||||||
func AnimatePNGs(pngs [][]byte, animIntervalMs int) ([]byte, error) {
|
func AnimatePNGs(ms *xmain.State, pngs [][]byte, animIntervalMs int) ([]byte, error) {
|
||||||
|
if ms != nil {
|
||||||
|
cancel := background.Repeat(func() {
|
||||||
|
ms.Log.Info.Printf("generating GIF...")
|
||||||
|
}, time.Second*5)
|
||||||
|
defer cancel()
|
||||||
|
}
|
||||||
|
|
||||||
var width, height int
|
var width, height int
|
||||||
pngImgs := make([]image.Image, len(pngs))
|
pngImgs := make([]image.Image, len(pngs))
|
||||||
for i, pngBytes := range pngs {
|
for i, pngBytes := range pngs {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ var test_output []byte
|
||||||
func TestPngToGif(t *testing.T) {
|
func TestPngToGif(t *testing.T) {
|
||||||
boards := [][]byte{test_input1, test_input2}
|
boards := [][]byte{test_input1, test_input2}
|
||||||
interval := 1_000
|
interval := 1_000
|
||||||
gifBytes, err := AnimatePNGs(boards, interval)
|
gifBytes, err := AnimatePNGs(nil, boards, interval)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
// use this to update the test output
|
// use this to update the test output
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue