Giter Club home page Giter Club logo

love-webp's Introduction

love-webp

Table of Contents

love-webp is a LÖVE library (pure Lua) to handle WebP files. It depends on LuaJIT (FFI), webp and webpdemux C shared libraries.

See examples (copy the library and launch the directory with LÖVE).

Install

See src.

ℹ️
webp and webpdemux shared libraries must be available (system path / executable directory).

API

-- load WebP image
-- data: string, Data or cdata
-- size: (optional) for cdata
-- return ImageData or nil on failure
M.loadImage(data, size)


-- load WebP frames
-- data: string, Data or cdata
-- size: (optional) for cdata
-- return (ImageData list, end_timestamp list, loops) or nil on failure
M.loadImages(data, size)

-- load WebP animation
-- The provided data must be alive/constant for the animation lifetime (internally referenced).
-- Frames are decoded/streamed from memory.
--
-- data: string, Data or cdata
-- size: (optional) for cdata
-- return Animation or nil
M.loadAnimation(data, size)

Animation

self.image -- ImageData (current frame)
self.texture -- Image (current frame)
self.time -- current animation time in seconds (for a specific loop)
self.current_frame -- frame index (0-based, for a specific loop)
self.current_loop -- loop index (0-based)
self.frames -- number of frames
self.loops -- number of loops
self.playing -- boolean
self.ended -- boolean
self.info -- WebPAnimInfo cdata

-- resume animation
-- (ended animations must be stopped before being played again)
Animation:play()

-- stop animation (reset to first frame)
Animation:stop()

-- pause animation
Animation:pause()

-- advance animation (if playing)
-- There is no seeking, all frames are decoded in order.
--
-- dt: seconds
Animation:tick(dt)

love-webp's People

Contributors

imagicthecat avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.