mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-04 03:45:58 -05:00
Further improve Raster documentation.
This commit is contained in:
parent
9cf912090c
commit
8391543115
2 changed files with 18 additions and 8 deletions
|
@ -213,9 +213,12 @@ var Raster = Item.extend(/** @lends Raster# */{
|
||||||
/**
|
/**
|
||||||
* The HTMLImageElement or Canvas element of the raster, if one is
|
* The HTMLImageElement or Canvas element of the raster, if one is
|
||||||
* associated.
|
* associated.
|
||||||
|
* Note that for consistency, a {@link #onLoad} event will be triggered on
|
||||||
|
* the raster even if the image has already finished loading before, or if
|
||||||
|
* we are setting the raster to a canvas.
|
||||||
*
|
*
|
||||||
* @bean
|
* @bean
|
||||||
* @type HTMLImageElement|Canvas
|
* @type HTMLImageElement|HTMLCanvasElement
|
||||||
*/
|
*/
|
||||||
getImage: function() {
|
getImage: function() {
|
||||||
return this._image;
|
return this._image;
|
||||||
|
@ -251,17 +254,22 @@ var Raster = Item.extend(/** @lends Raster# */{
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal version of {@link #setImage(image)} that does not trigger
|
||||||
|
* events. This is used by #setImage(), but also in other places where
|
||||||
|
* underlying canvases are replaced, resized, etc.
|
||||||
|
*/
|
||||||
_setImage: function(image) {
|
_setImage: function(image) {
|
||||||
if (this._canvas)
|
if (this._canvas)
|
||||||
CanvasProvider.release(this._canvas);
|
CanvasProvider.release(this._canvas);
|
||||||
// Due to similarities, we can handle both canvas and image types here.
|
// Due to similarities, we can handle both canvas and image types here.
|
||||||
if (image && image.getContext) {
|
if (image && image.getContext) {
|
||||||
// A canvas object
|
// A Canvas object
|
||||||
this._image = null;
|
this._image = null;
|
||||||
this._canvas = image;
|
this._canvas = image;
|
||||||
this._loaded = true;
|
this._loaded = true;
|
||||||
} else {
|
} else {
|
||||||
// A image object
|
// A Image object
|
||||||
this._image = image;
|
this._image = image;
|
||||||
this._canvas = null;
|
this._canvas = null;
|
||||||
this._loaded = image && image.complete;
|
this._loaded = image && image.complete;
|
||||||
|
@ -284,7 +292,7 @@ var Raster = Item.extend(/** @lends Raster# */{
|
||||||
* case `null` is returned instead.
|
* case `null` is returned instead.
|
||||||
*
|
*
|
||||||
* @bean
|
* @bean
|
||||||
* @type Canvas
|
* @type HTMLCanvasELement
|
||||||
*/
|
*/
|
||||||
getCanvas: function() {
|
getCanvas: function() {
|
||||||
if (!this._canvas) {
|
if (!this._canvas) {
|
||||||
|
@ -338,6 +346,8 @@ var Raster = Item.extend(/** @lends Raster# */{
|
||||||
* ID of a DOM element to get the image from (either a DOM Image or a
|
* ID of a DOM element to get the image from (either a DOM Image or a
|
||||||
* Canvas). Reading this property will return the url of the source image or
|
* Canvas). Reading this property will return the url of the source image or
|
||||||
* a data-url.
|
* a data-url.
|
||||||
|
* Note that for consistency, a {@link #onLoad} event will be triggered on
|
||||||
|
* the raster even if the image has already finished loading before.
|
||||||
*
|
*
|
||||||
* @bean
|
* @bean
|
||||||
* @type HTMLImageElement|HTMLCanvasElement|String
|
* @type HTMLImageElement|HTMLCanvasElement|String
|
||||||
|
@ -417,7 +427,7 @@ var Raster = Item.extend(/** @lends Raster# */{
|
||||||
* @param {Rectangle} rect the boundaries of the sub image in pixel
|
* @param {Rectangle} rect the boundaries of the sub image in pixel
|
||||||
* coordinates
|
* coordinates
|
||||||
*
|
*
|
||||||
* @return {Canvas} the sub image as a Canvas object
|
* @return {HTMLCanvasELement} the sub image as a Canvas object
|
||||||
*/
|
*/
|
||||||
getSubCanvas: function(/* rect */) {
|
getSubCanvas: function(/* rect */) {
|
||||||
var rect = Rectangle.read(arguments),
|
var rect = Rectangle.read(arguments),
|
||||||
|
@ -465,7 +475,7 @@ var Raster = Item.extend(/** @lends Raster# */{
|
||||||
/**
|
/**
|
||||||
* Draws an image on the raster.
|
* Draws an image on the raster.
|
||||||
*
|
*
|
||||||
* @param {HTMLImageELement|Canvas} image
|
* @param {HTMLImageELement|HTMLCanvasELement} image
|
||||||
* @param {Point} point the offset of the image as a point in pixel
|
* @param {Point} point the offset of the image as a point in pixel
|
||||||
* coordinates
|
* coordinates
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,8 +22,8 @@ var CanvasView = View.extend(/** @lends CanvasView# */{
|
||||||
* Creates a view object that wraps a canvas element.
|
* Creates a view object that wraps a canvas element.
|
||||||
*
|
*
|
||||||
* @name CanvasView#initialize
|
* @name CanvasView#initialize
|
||||||
* @param {HTMLCanvasElement} canvas the canvas object that this view should
|
* @param {HTMLCanvasElement} canvas the Canvas object that this view should
|
||||||
* wrap
|
* wrap
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Creates a view object that wraps a newly created canvas element.
|
* Creates a view object that wraps a newly created canvas element.
|
||||||
|
|
Loading…
Reference in a new issue