1. --!movie
  2.  
  3. global $
  4.  
  5. ----------------------------------------
  6. --
  7. ----------------------------------------
  8. on startMovie
  9.  
  10.     -- CONFIG
  11.     DUR = 50 -- 50 ms = 20 fps
  12.  
  13.     -- libs
  14.     $.import("console").show()
  15.  
  16.     -- create an instance of the APNG lib
  17.     apng = $.include($.PATH&"apng.ls").new()
  18.  
  19.     -- load background image from file
  20.     m = new(#bitmap)
  21.     m.importFileInto($.PATH&"input\lena.bmp")
  22.     lena = m.image
  23.     lena.setAlpha(255)
  24.     lena.useAlpha = TRUE
  25.  
  26.     -- create image of blue circle with alpha channel
  27.     circle = image(100, 100, 32)
  28.     circle.fill(circle.rect, rgb(0,0,255))
  29.     m = new(#bitmap)
  30.     m.importFileInto($.PATH&"input\circle.bmp", [#trimWhitespace: FALSE])
  31.     alpha = image(100, 100, 8, #grayscale)
  32.     alpha.copyPixels(m.image, alpha.rect, alpha.rect)
  33.     circle.setAlpha(alpha)
  34.     circle.useAlpha = TRUE
  35.  
  36.     ms = the milliseconds
  37.  
  38.     -- initialize APNG (i.e. start creation of new APNG file)
  39.     apng.init(0) -- 0 = loop forever
  40.  
  41.     -- add static background photo, immediately go to next frame (ms=0)
  42.     -- using filter "Up" reduces overall filesize from 830 to 638 Kb
  43.     apng.addFrame(lena, 0, 0, 0, 0, 0, apng.FILTER_UP)
  44.  
  45.     -- add frames in a loop
  46.     repeat with i = 0 to 103
  47.         -- add circle image with alpha channel on top of photo
  48.         apng.addFrame(circle, DUR, i*4, i*4, apng.DISPOSE_OP_PREVIOUS, apng.BLEND_OP_OVER)
  49.     end repeat
  50.  
  51.     ms = the milliseconds-ms
  52.  
  53.     -- save the APNG as file
  54.     apng.writeFile($.PATH&"animation_circle.png")
  55.  
  56.     out("Done. APNG was generated in "&ms&" milliseconds.")
  57. end
  58.  
[raw code]