Giter VIP home page Giter VIP logo

jeff's Introduction

jeff

Jeff converts Flash™ SWFs into a JSON/PNG format for high performance usage in HTML/JavaScript. The extracted content could be used to integrate Flash™ Animations in your game using your favorite HTML Game Engine.

Contains a variety of options to allow you to get performance where you need it:

Optimised speed performance:

  • Asset rasterisation (faster than vectorial drawing)
  • Image Atlas creation (to enable batch sprite rendering in WebGL)
  • Extracting images with power of 2 dimensions (to enable mipmapping)

Optimised memory performance:

  • Image compression (lossy and loss-less compressions)
  • Animation Scaling (to rasterise images at the exact size needed)

Optimised ease of use:

  • Gathering several animations in a single output: Reduced number of assets to manage
  • Frame by Frame rasterisation: for easy integration in your game

Very good scalability: from both the command line as well as through the API, it can be used to do batch extraction on multiple SWFs.

Made at Wizcorp.

Install

For command line usage:

npm install jeff -g

For API usage:

npm install jeff

Usage

Command line:

jeff -s mySwf.swf

API:

var jeff = require('jeff');

// Writing extracted data in current folder
var options = {
	source: 'mySwf.swf',
	outDir: '.'
};

jeff(options);


// Returning extracted data in a callback
var options = {
	source: 'mySwf.swf',
	returnData: true
};

jeff(options, function (error, stats, extractedData) {
	// Uncovering conversion stats
	var nbFilesConverted = stats.files;
	var nbErrors         = stats.errors;

	// Fetching extracted data
	var imageNames = extractedData.imageNames;
	var image      = extractedData.images;
	var data       = extractedData.data;
});

Operation

  • Will parse the input directory to find SWF files corresponding to the given source file pattern.
  • Will sequentially parse and process the SWF files.
  • Will export JSON meta-data and images corresponding to the SWF files.

Roadmap for unsupported features

  • Texts (Static/Dynamic)
  • Buttons
  • Embedded fonts
  • Sounds
  • ActionScript

Roadmap for extract options

  • Option to extract shapes under vectorial format
  • Option to extract meta-data under keyframe based format (as opposed to per frame transformation matrix)

For contributors, see SWF File Format Specifications

jeff's People

Contributors

cainmartin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jeff's Issues

Option to extract meta-data under keyframe based format

Right now the JSON metadata file contains the transformation matrices for every frame of every symbol within a movie clip.

The idea is to convert the list of transformation matrices for every frame of a given symbol into a list of keyframes with corresponding easings. It can be done in 2 steps:

    1. Do some math to determine the position, rotation, skew and origin of a symbol from a transformation matrix.
    1. Determine easings that can be used to generated keyframes using in priority the flash easing method:
      t = t + t * ease - t * t * ease .

Fails to install using node v8.4.0 and npm 5.5.1 on mac

npm ERR! Failed at the [email protected] install script.

ivan@probook ~/P/F/FlashConvert> npm install jeff 2>&1 | grep error
../../nan/nan.h:342:68: error: too many arguments to function call, expected at most 2, have 4
../../nan/nan.h:424:3: error: redefinition of 'NanNew'
../../nan/nan.h:442:36: error: redefinition of 'NanNew'
../../nan/nan.h:454:36: error: redefinition of 'NanNew'
../../nan/nan.h:623:19: error: no type named 'ExternalAsciiStringResource' in 'v8::String'; did you mean 'ExternalStringResource'?
../../nan/nan.h:622:36: error: redefinition of 'NanNew'
../../nan/nan.h:637:27: error: redefinition of '_NanEscapeScopeHelper'
../../nan/nan.h:653:12: error: no matching function for call to '_NanEscapeScopeHelper'
../../nan/nan.h:658:12: error: no matching function for call to '_NanEscapeScopeHelper'
../../nan/nan.h:663:12: error: no matching function for call to '_NanEscapeScopeHelper'
../../nan/nan.h:668:12: error: no matching function for call to '_NanEscapeScopeHelper'
../../nan/nan.h:701:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate'
../../nan/nan.h:707:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate'
../../nan/nan.h:712:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate'
../../nan/nan.h:718:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate'
../../nan/nan.h:797:15: error: no type named 'WeakCallbackData' in namespace 'v8'
../../nan/nan.h:797:31: error: expected ')'
../../nan/nan.h:798:42: error: use of undeclared identifier 'data'
../../nan/nan.h:889:13: error: no member named 'smalloc' in namespace 'node'
fatal error: too many errors emitted, stopping now [-ferror-limit=]
13 warnings and 20 errors generated.
gyp ERR! build error

any suggestions how to workaround?

Would love to try this on some swf files.

Add Sound support

Consists in parsing sounds from the swf file and outputting them into sound files.

buffer-crc32 required as a dependency for Jeff

I had a problem using jeff initially and it reported an error about "Error: Cannot find module 'buffer-crc32'".
Looking through the code I found a require('buffer-crc32'); call in the lib/CanvasRenderer/SwfImgRenderer/PngWriter.js file. To fix this I had to go either a "npm install buffer-crc32" or "npm install -g buffer-crc32". To fix it permanently I think it would be better to add buffer-crc32 as a dependency in package.json. I have created a PR for this change

Option to extract shapes under vectorial format

Right now all the vectorial drawings (shapes) are rasterised and output under as png files. Also, the generated JSON metadata file does not contain the initial information of the shapes.

The idea is to give the user the option to choose to either rasterise the shapes or to include them in the JSON metadata file under the form of vectorial paths.

Add ActionScript Support

Consists in parsing the actionscript code present in swf objects and adding it into the generated JSON metadata file under a javascript format.

Replace node canvas

Consists in replacing node canvas (because it has quite a few issues and is slow for some oeprations) with an OpenGL renderer (vectorial rendering library).

A possible solution could be to combine a package containing WebGL bindings with Pixi.

N.B The whole rendering should be refactored to use the new rendering library.

Optimise the shape reconstruction process

The processShape method (in SwfObjectProcessor) reconstructs vectorial paths from the swf vectorial drawings. The structure that stores the vectorial drawings in SWFs is special for 2 reasons: it is compressed and it is compatible with their rendering engine (that treats edges between 2 fills of a same shape as a special case for better quality).

The processShape method can probably be optimised to parse the vectorial drawing structure of swf objects more quickly.

Hard-coded Framerate

It seems like Jeff output file's framerate is always set at 25 (hard-coded).
This value should be, ideally, the same as in the flash file settings.

Unit testing

Jeff should have a collection of swfs covering as much as possible supported features and a unit test able to compare output before/after a change to be sure we don't break anything when we change the code.

Output Format?

I used 0.4 to successfully convert my swf to json and pngs, but I dont actually see any documentation about the output json.

I'd like to contribute improvements/upgrades, but without reader I dont know if my json is valid or if I make changes that they are backwards compatible.

I'm hoping to eventually be able to use this in a toolchain that converts swf to Spine json format (http://en.esotericsoftware.com/spine-json-format).

Thanks!

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.