-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to latest createjs libs, latest canvas, working on recent node version #3
Open
jedateach
wants to merge
9
commits into
CreateJS:master
Choose a base branch
from
jedateach:1.0
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
535750e
gitignore node_modules
jedateach b4fd046
Upgrade to node canvas 2
jedateach c23133f
Added examples/output to gitignore
jedateach 6e01936
Include easeljs and tweenjs v1.0.x via npm
jedateach f28451b
Switch codebase to use easel/tween v1, fix issues
jedateach df29488
Remove old createjs codebases
jedateach a0d1667
Bump examples code version
jedateach b1d6e81
Remove commented old code
jedateach 93cccc3
Updated urls in package.json to point to repo
jedateach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
.idea | ||
node_modules | ||
examples/output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
var Canvas = require('canvas'); | ||
var Image = Canvas.Image; | ||
var { Canvas, Image } = require('canvas'); | ||
var fs = require('fs'); | ||
var exec = require('child_process').exec; | ||
|
||
|
@@ -18,7 +17,7 @@ s.RUNNING_RATE = 2.5; | |
p.init = function (success) { | ||
var cmd = "find " + __dirname + "/output -name '*.mpg' -exec rm -f {} \\;"; | ||
console.log(cmd); | ||
exec(cmd); | ||
exec(cmd, execCallback); | ||
|
||
this.success = success; | ||
|
||
|
@@ -30,7 +29,7 @@ p.init = function (success) { | |
var spriteSheet = {"animations":{"run":[0, 25], "jump":[26, 63]}, "images":[this.loadImage("runningGrant.png")], "frames":{"regX":0, "height":292.5, "count":64, "regY":0, "width":165.75}}; | ||
|
||
var ss = new createjs.SpriteSheet(spriteSheet); | ||
this.grant = new createjs.BitmapAnimation(ss); | ||
this.grant = new createjs.Sprite(ss); | ||
|
||
// Set up looping | ||
ss.getAnimation("run").next = "run"; | ||
|
@@ -68,7 +67,7 @@ p.init = function (success) { | |
|
||
this.tickFunction = this.tick.bind(this); | ||
var fps = 80; | ||
createjs.Ticker.setFPS(fps); | ||
createjs.Ticker.framerate = fps; | ||
createjs.Ticker.addEventListener("tick", this.tickFunction); | ||
|
||
var seconds = 10; | ||
|
@@ -80,14 +79,19 @@ p.init = function (success) { | |
p.stopCapture = function () { | ||
createjs.Ticker.removeEventListener("tick", this.tickFunction); | ||
console.log('begin video encoding'); | ||
exec('cd ' + __dirname + '/output && ffmpeg -f image2 -i test_%d.png -sameq video.mpg', this.handleVideoEncoded.bind(this)); | ||
var cmd = 'cd ' + __dirname + '/output && ffmpeg -f image2 -i test_%d.png -qscale 0 video.mpg'; | ||
exec(cmd, this.handleVideoEncoded.bind(this)); | ||
} | ||
|
||
p.handleVideoEncoded = function () { | ||
console.log('Video Encoded'); | ||
p.handleVideoEncoded = function (err, stdout, stderr) { | ||
if (err) { | ||
execCallback(err, stdout, stderr); | ||
} else { | ||
console.log('Video Encoded'); | ||
} | ||
|
||
var cmd = "find " + __dirname + "/output -name '*.png' -exec rm -f {} \\;"; | ||
exec(cmd); | ||
exec(cmd, execCallback); | ||
this.success('video.mpg'); | ||
|
||
createjs.Ticker.halt(); | ||
|
@@ -123,3 +127,19 @@ p.tick = function () { | |
var fileName = __dirname + '/output/test_' + (this.index++) + '.png'; | ||
fs.writeFileSync(fileName, this.canvas.toBuffer(), ''); | ||
} | ||
|
||
/** | ||
* Helper for reporting back exec errors | ||
*/ | ||
function execCallback(error, stdout, stderr) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This helped reveal a problem in |
||
if (error) { | ||
console.error("exec error:" + error); | ||
return; | ||
} | ||
if (stdout) { | ||
console.log("stdout:" + stdout); | ||
} | ||
if (stderr) { | ||
console.log("stderr:" + stderr); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The canvas API changed in version 2.
Using this destructing syntax will break older versions of node. We can degrade it back to older syntax, if needed. But really a decision needs to be made on the minimum node version, and subsequently it should run on a CI test matrix that includes includes that minimum version of node.