-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved image from experimental and made it a first-class donatello pri…
…mitive.
- Loading branch information
Dan Newcome
committed
Apr 14, 2012
1 parent
bc35b62
commit 5565943
Showing
3 changed files
with
48 additions
and
11 deletions.
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
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 |
---|---|---|
@@ -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 ); | ||
} |
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 |
---|---|---|
@@ -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> |