Skip to content

Commit

Permalink
moved image from experimental and made it a first-class donatello pri…
Browse files Browse the repository at this point in the history
…mitive.
  • Loading branch information
Dan Newcome committed Apr 14, 2012
1 parent bc35b62 commit 5565943
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 11 deletions.
11 changes: 0 additions & 11 deletions experimental.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
25 changes: 25 additions & 0 deletions image.js
Original file line number Diff line number Diff line change
@@ -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 );
}
23 changes: 23 additions & 0 deletions tests/image.html
Original file line number Diff line number Diff line change
@@ -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.