Permalink
Browse files

moved image from experimental and made it a first-class donatello pri…

…mitive.
  • Loading branch information...
1 parent bc35b62 commit 556594388c3fa9cca8829847f003e6efe3efc327 @dnewcome committed Apr 14, 2012
Showing with 48 additions and 11 deletions.
  1. +0 −11 experimental.js
  2. +25 −0 image.js
  3. +23 −0 tests/image.html
View
11 experimental.js
@@ -147,14 +147,3 @@ Donatello.prototype.stop = function( time, attrs ) {
}
-/**
-* Draw an image to the scene using an <img> tag.
-*/
-Donatello.prototype.image = function( x, y, w, h, img, a ) {
- var el = Donatello.createElement( x, y, w, h, 'img');
- el.src = img;
- this.dom.appendChild( el );
- var don = new Donatello( el );
- don.attr( a );
- return don;
-}
View
25 image.js
@@ -0,0 +1,25 @@
+Donatello.Image = function( parent, x, y, w, h, img, a ) {
+ a = Donatello.attrDefaults( a );
+ this.properties = {
+ x: x, y: y, w: w, h: h, img: img
+ };
+ var el = Donatello.createElement( x, y, w, h, 'img' );
+ el.src = img;
+
+ this.dom = el;
+ this._parent = parent;
+
+ this.draw();
+ parent.dom.appendChild( el );
+ this.attr( a );
+}
+Donatello.Image.prototype = new Donatello( null );
+
+Donatello.Image.prototype.draw = function() {}
+
+/**
+* Draw an image to the scene using an <img> tag.
+*/
+Donatello.prototype.image = function( x, y, w, h, img, a ) {
+ return new Donatello.Image( this, x, y, w, h, img, a );
+}
View
23 tests/image.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<html>
+<head>
+ <script src="../donatello.js" type="text/javascript"></script>
+ <script src="../image.js" type="text/javascript"></script>
+ <script>
+ function main() {
+ var paper = Donatello.paper('paper-div', 20, 20, 600, 600 );
+ text = paper.image( 25, 25, 45, 45, "donatello.jpg" );
+ }
+ </script>
+ <style>
+ #paper-div {
+ border: 1px solid black
+ }
+ </style>
+
+</head>
+<body onload='main();'>
+ <div id="paper-div">
+ </div>
+</body>
+</html>

0 comments on commit 5565943

Please sign in to comment.