Permalink
Browse files

Merge branch 'master' into foreignobject-margin

  • Loading branch information...
2 parents bfe4cd6 + f7fc408 commit d85f3da9ece7b28e97712b628d998f5fda7ecc66 Tobias von Klipstein committed Oct 2, 2012
Showing with 1,320 additions and 53 deletions.
  1. +14 −4 CHANGELOG
  2. +6 −0 LICENSE
  3. +1 −1 example/library/index.html
  4. BIN example/library/movies/assets/cinematicBoomNorm.m4a
  5. BIN example/library/movies/assets/cinematicBoomNorm.ogg
  6. BIN example/library/movies/assets/ninja-sprite.jpg
  7. BIN example/library/movies/assets/piano-sprite.m4a
  8. BIN example/library/movies/assets/piano-sprite.mp3
  9. BIN example/library/movies/assets/piano-sprite.ogg
  10. BIN example/library/movies/assets/pong.mp3
  11. BIN example/library/movies/assets/pong.ogg
  12. BIN example/library/movies/assets/tick16.m4a
  13. BIN example/library/movies/assets/tick60.mp3
  14. +40 −0 example/library/movies/audio-boom.js
  15. +52 −0 example/library/movies/audio-button.js
  16. +45 −0 example/library/movies/audio-piano-sprite.js
  17. +8 −0 example/library/movies/audio-simple.js
  18. +5 −0 example/library/movies/audio-tick-16.js
  19. +6 −0 example/library/movies/audio-volume.js
  20. +1 −3 example/library/movies/filter-blur.js
  21. +13 −2 example/library/movies/movie_list.js
  22. +11 −0 example/library/movies/overlapping-paths.js
  23. +487 −0 example/library/movies/pong.js
  24. +52 −0 example/library/movies/sprite-ninja.js
  25. +1 −1 package.json
  26. +9 −3 src/asset/asset_controller.js
  27. +43 −1 src/asset/asset_handler.js
  28. +5 −6 src/asset/asset_resource.js
  29. +91 −0 src/asset/audio_handler.js
  30. +12 −9 src/asset/video_handler.js
  31. +64 −15 src/renderer/svg/svg.js
  32. +182 −0 src/runner/audio.js
  33. +3 −1 src/runner/environment.js
  34. +1 −1 src/version.js
  35. +28 −0 test/asset_audio_handler-spec.js
  36. +16 −6 test/asset_handler-spec.js
  37. +71 −0 test/audio-spec.js
  38. +51 −0 test/renderer/svg-spec.js
  39. +2 −0 test/runner.html
View
@@ -1,17 +1,27 @@
-v0.3.8
+v0.3.9
-------------------
+v0.3.8 / 2012-09-28
+-------------------
+
+* Add `Audio` a new DisplayObject including new API
+* Add `drawAudio` method and according tests in renderer
+* Add `AudioHandler` a new AssetHandler for Audio resources
+
v0.3.7 / 2012-09-26
-------------------
* Fix issue where click event would be fired twice on touch devices (#60)
* Change display list implementation from mixin to composition
* Make the default textOrigin in the Text class 'top'
-* Cleanup KeyframeAnimation and remove setSubject(s) methods to bring inline with current Animation class
-* Fix internal asset messaging so that assetData (loadData) is correctly sent to the runner (AssetLoader)
+* Cleanup KeyframeAnimation and remove setSubject(s) methods
+ to bring inline with current Animation class
+* Fix internal asset messaging so that assetData (loadData) is
+ correctly sent to the runner (AssetLoader)
* Add missing `delay` option to KeyframeAnimation
-* Fix issue where TextSpan child default strokeWidth took precedence over parent (Text instance) strokeWidth
+* Fix issue where TextSpan child default strokeWidth took
+ precedence over parent (Text instance) strokeWidth
* Add the ability to execute tests via commandline: `make test-phantom`
* Allow to pass a function within `code` in `bonsai.run`
* Make `player.Renderer` configurable via `player.setup()`
View
@@ -28,3 +28,9 @@ External libraries (each with their own license):
- phantom-jasmine: Apache 2 - https://github.com/jcarver989/phantom-jasmine/issues/8
- closure: http://code.google.com/p/closure-compiler/source/browse/trunk/COPYING
- qc.js: https://github.com/darrint/qc.js/blob/master/COPYING
+
+External resources (each with their own license):
+
+ - cinematicBoomNorm(ogg/mp3/m4a): http://creativecommons.org/licenses/by/3.0/
+ http://www.freesound.org/people/HerbertBoland/sounds/33637/
+
@@ -1,7 +1,7 @@
<!doctype html>
-<meta name=viewport content=width=device-width,initial-scale=1>
<head>
<title>Bonsai Movie Library</title>
+ <meta name=viewport content=width=device-width,initial-scale=1>
<script src=../../lib/requirejs/require.js></script>
<!--<script src="http://localhost:8080/socket.io/socket.io.js"></script>-->
<script src="movies/movie_list.js"></script>
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,40 @@
+
+new Rect(145, 290, 1000, 60).fill('black').addTo(stage);
+
+var teamText = new Text('loading...').attr({
+ textFillColor: 'white',
+ scale:3,
+ x: 150,
+ y: 300
+}).addTo(stage);
+
+var movie = new Movie();
+
+var booom = new Audio([
+ { src: 'assets/cinematicBoomNorm.m4a' },
+ { src: 'assets/cinematicBoomNorm.ogg' }
+]).attr({
+ volume: 1
+}).addTo(stage).on('load', function() {
+
+ var i = 0, teaser = ['A Path', 'a red panda', 'and an Audio', 'walked into a bar'];
+
+ movie.frames({
+ 0: function() {
+ booom.play();
+ teamText.attr({
+ text: teaser[i]
+ });
+ },
+ '2s': function() {
+ if (i === teaser.length) {
+ movie.stop();
+ }
+ booom.stop();
+ i++;
+ }
+ }).addTo(stage);
+
+});
+
+
@@ -0,0 +1,52 @@
+
+var audio = new Audio([
+ { src: 'assets/cinematicBoomNorm.m4a' },
+ { src: 'assets/cinematicBoomNorm.ogg' }
+]).attr({
+ volume: 1
+}).addTo(stage);
+
+audio.prepareUserEvent(); // iOS devices
+
+new Button('Boooom!', 50, 50).on('click', function() {
+ audio.play(0);
+});
+
+
+
+
+// BUTTON IMPLEMENTATION
+function Button(text, x, y) {
+ var button = new bonsai.Group().addTo(stage).attr({x: x, y: y})
+
+ button.bg = bonsai.Path.rect(0, 0, 100, 40, 5).attr({
+ fillGradient: bonsai.gradient.radial(['#19D600', '#0F8000'], 100, 50, -20),
+ strokeColor: '#CCC',
+ strokeWidth: 0
+ }).addTo(button);
+
+ button
+ .on('mouseover', function() {
+ button.bg.animate('.2s', {
+ fillGradient: bonsai.gradient.radial(['#9CFF8F', '#0F8000'], 100, 50, -20),
+ strokeWidth: 3
+ })
+ })
+ .on('mouseout', function() {
+ button.bg.animate('.2s', {
+ fillGradient: bonsai.gradient.radial(['#19D600', '#0F8000'], 100, 50, -20),
+ strokeWidth: 0
+ })
+ });
+
+ button.text = new bonsai.Text(text).attr({
+ x: 10,
+ y: 13,
+ fontFamily: 'Arial',
+ fontSize: '20px',
+ textFillColor: 'white'
+ }).addTo(button);
+
+ return button;
+
+}
@@ -0,0 +1,45 @@
+var pianoSprite = [], changePianoSprite = 0;
+
+function aSound(atTime) {
+ // TODO: test multiple audio "confirmations" on iOS.
+ var aPianoSprite = pianoSprite[0];
+ changePianoSprite += 1;
+ new Movie().addTo(stage).frames({
+ 0: function() {
+ aPianoSprite.play(atTime);
+ },
+ '1s': function() {
+ aPianoSprite.stop();
+ this.stop();
+ stage.removeChild(this);
+ }
+ });
+}
+
+// load indicator
+var aTextField = new Text('loading...').addTo(stage);
+
+function ready() {
+ aTextField.attr({ text: 'Start typing: [1-8]', scale:0.5 }).animate('0.5s', {
+ opacity: 1, scale: 1
+ }, { easing: 'elasticOut' });
+
+ aSound(0);
+
+ stage.on('key', function(e) {
+ var atTime = +String.fromCharCode(e.keyCode);
+ if (['C', 'D', 'E', 'F', 'G', 'A', 'H', 'C2'][atTime]) {
+ aSound(atTime-1);
+ }
+ });
+}
+
+pianoSprite.push(new Audio([
+ { src: 'assets/piano-sprite.m4a' },
+ { src: 'assets/piano-sprite.mp3' },
+ { src: 'assets/piano-sprite.ogg' }
+]).attr('prepareUserEvent', true));
+pianoSprite[0].addTo(stage).on('load', function() {
+ //pianoSprite[1] = pianoSprite[0].clone().addTo(stage);
+ aTextField.animate('0.5s', { opacity:0 }, { onEnd: ready });
+});
@@ -0,0 +1,8 @@
+new Audio([
+ { src: 'assets/cinematicBoomNorm.m4a' },
+ { src: 'assets/cinematicBoomNorm.ogg' }
+]).addTo(stage).on('load', function() {
+ this.play();
+});
+
+
@@ -0,0 +1,5 @@
+var tick = new Audio('assets/tick16.m4a').addTo(stage);
+stage.on('tick', function() {
+ // soooooound!!
+ //tick.play();
+});
@@ -0,0 +1,6 @@
+var vol = 0.0;
+var tick = new Audio('assets/tick16.m4a').addTo(stage);
+stage.on('tick', function() {
+ vol += 0.01;
+ //tick.play().attr({ volume: Math.min(vol, 1) });
+});
@@ -1,13 +1,11 @@
// image
-new bonsai.Bitmap('assets/redpanda.jpg', {
- onload: function() {
+new bonsai.Bitmap('assets/redpanda.jpg', function() {
this.attr({
y: 100,
x: 100,
filters: 'blur'
});
stage.addChild(this);
- }
});
// shape
@@ -16,13 +16,22 @@ movieList = {
'animation-stars-2.js',
'animation-circles.js'
],
+ 'Audio': [
+ 'audio-simple.js',
+ 'audio-tick-16.js',
+ 'audio-volume.js',
+ 'audio-boom.js',
+ 'audio-piano-sprite.js',
+ 'audio-button.js'
+ ],
'Bitmaps and Sprites': [
'bitmap.js',
'bitmap-source.js',
'fill-image.js',
'sprite.js',
'data-url.js',
- 'bitmap-memory-check.js'
+ 'bitmap-memory-check.js',
+ 'sprite-ninja.js'
],
'Color': [
'color.js',
@@ -77,6 +86,7 @@ movieList = {
'sprite-properties.js'
],
'Games': [
+ 'pong.js',
'asteroids.js',
'breakout.js',
'pacman.js'
@@ -125,7 +135,8 @@ movieList = {
'shape-arc.js',
'shape-getPointAtLength.js',
'shape-center-of-arc.js',
- 'shape-fill-rule.js'
+ 'shape-fill-rule.js',
+ 'overlapping-paths.js'
],
'Test': [
'text.js',
@@ -0,0 +1,11 @@
+// http://jsbin.com/ociyiw/24/edit
+
+new Rect(100, 100, 100, 100).fill("yellow").attr({opacity:0.5}).addTo(stage);
+new Rect(160, 100, 100, 100).fill("green").attr({opacity:0.5}).addTo(stage);
+
+var group = new Group().addTo(stage).attr({
+ y:120,
+ opacity:0.5
+});
+new Rect(100, 100, 100, 100).fill("yellow").addTo(group);
+new Rect(160, 100, 100, 100).fill("green").addTo(group);
Oops, something went wrong.

0 comments on commit d85f3da

Please sign in to comment.