mirror of
https://github.com/konvajs/konva.git
synced 2025-11-18 17:21:36 +08:00
updated Canvas docs
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
context.clearRect(0, 0, el.width, el.height);
|
context.clearRect(0, 0, el.width, el.height);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get element
|
* get canvas element
|
||||||
* @name getElement
|
* @name getElement
|
||||||
* @methodOf Kinetic.Canvas.prototype
|
* @methodOf Kinetic.Canvas.prototype
|
||||||
*/
|
*/
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
return this.element;
|
return this.element;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get context
|
* get canvas context
|
||||||
* @name getContext
|
* @name getContext
|
||||||
* @methodOf Kinetic.Canvas.prototype
|
* @methodOf Kinetic.Canvas.prototype
|
||||||
*/
|
*/
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
* set width
|
* set width
|
||||||
* @name setWidth
|
* @name setWidth
|
||||||
* @methodOf Kinetic.Canvas.prototype
|
* @methodOf Kinetic.Canvas.prototype
|
||||||
|
* @param {Number} width
|
||||||
*/
|
*/
|
||||||
setWidth: function(width) {
|
setWidth: function(width) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
@@ -58,6 +59,7 @@
|
|||||||
* set height
|
* set height
|
||||||
* @name setHeight
|
* @name setHeight
|
||||||
* @methodOf Kinetic.Canvas.prototype
|
* @methodOf Kinetic.Canvas.prototype
|
||||||
|
* @param {Number} height
|
||||||
*/
|
*/
|
||||||
setHeight: function(height) {
|
setHeight: function(height) {
|
||||||
this.height = height;
|
this.height = height;
|
||||||
@@ -85,13 +87,19 @@
|
|||||||
* set size
|
* set size
|
||||||
* @name setSize
|
* @name setSize
|
||||||
* @methodOf Kinetic.Canvas.prototype
|
* @methodOf Kinetic.Canvas.prototype
|
||||||
|
* @param {Number} width
|
||||||
|
* @param {Number} height
|
||||||
*/
|
*/
|
||||||
setSize: function(width, height) {
|
setSize: function(width, height) {
|
||||||
this.setWidth(width);
|
this.setWidth(width);
|
||||||
this.setHeight(height);
|
this.setHeight(height);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* toDataURL
|
* to data url
|
||||||
|
* @name toDataURL
|
||||||
|
* @methodOf Kinetic.Canvas.prototype
|
||||||
|
* @param {String} mimeType
|
||||||
|
* @param {Number} quality between 0 and 1 for jpg mime types
|
||||||
*/
|
*/
|
||||||
toDataURL: function(mimeType, quality) {
|
toDataURL: function(mimeType, quality) {
|
||||||
try {
|
try {
|
||||||
@@ -110,30 +118,30 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* fill current path
|
* fill shape path
|
||||||
* @name fill
|
* @name fill
|
||||||
* @methodOf Kinetic.Canvas.prototype
|
* @methodOf Kinetic.Canvas.prototype
|
||||||
|
* @param {Kinetic.Shape} shape
|
||||||
*/
|
*/
|
||||||
fill: function(shape) {
|
fill: function(shape) {
|
||||||
this._fill(shape);
|
this._fill(shape);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* stroke current path
|
* stroke shape path
|
||||||
* @name stroke
|
* @name stroke
|
||||||
* @methodOf Kinetic.Canvas.prototype
|
* @methodOf Kinetic.Canvas.prototype
|
||||||
|
* @param {Kinetic.Shape} shape
|
||||||
*/
|
*/
|
||||||
stroke: function(shape) {
|
stroke: function(shape) {
|
||||||
this._stroke(shape);
|
this._stroke(shape);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* fill and stroke current path. Aside from being a convenience method
|
* fill, stroke, and apply shadows
|
||||||
* which fills and strokes the current path with a single method, its main purpose is
|
|
||||||
* to ensure that the shadow object is not applied to both the fill and stroke. A shadow
|
|
||||||
* will only be applied to either the fill or stroke. Fill
|
* will only be applied to either the fill or stroke. Fill
|
||||||
* is given priority over stroke.
|
* is given priority over stroke.
|
||||||
* @name fillStroke
|
* @name fillStroke
|
||||||
* @param {CanvasContext} context
|
|
||||||
* @methodOf Kinetic.Canvas.prototype
|
* @methodOf Kinetic.Canvas.prototype
|
||||||
|
* @param {Kinetic.Shape} shape
|
||||||
*/
|
*/
|
||||||
fillStroke: function(shape) {
|
fillStroke: function(shape) {
|
||||||
this._fill(shape);
|
this._fill(shape);
|
||||||
@@ -145,14 +153,16 @@
|
|||||||
* @param {CanvasContext} context
|
* @param {CanvasContext} context
|
||||||
* @param {Function} func draw function
|
* @param {Function} func draw function
|
||||||
* @methodOf Kinetic.Canvas.prototype
|
* @methodOf Kinetic.Canvas.prototype
|
||||||
|
* @param {Kinetic.Shape} shape
|
||||||
|
* @param {Function} drawFunc
|
||||||
*/
|
*/
|
||||||
applyShadow: function(shape, func) {
|
applyShadow: function(shape, drawFunc) {
|
||||||
var context = this.context;
|
var context = this.context;
|
||||||
context.save();
|
context.save();
|
||||||
this._applyShadow(shape);
|
this._applyShadow(shape);
|
||||||
func();
|
drawFunc();
|
||||||
context.restore();
|
context.restore();
|
||||||
func();
|
drawFunc();
|
||||||
},
|
},
|
||||||
_applyLineCap: function(shape) {
|
_applyLineCap: function(shape) {
|
||||||
var lineCap = shape.getLineCap();
|
var lineCap = shape.getLineCap();
|
||||||
@@ -180,6 +190,13 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scene Canvas Renderer constructor
|
||||||
|
* @constructor
|
||||||
|
* @augments Kinetic.Canvas
|
||||||
|
* @param {Number} width
|
||||||
|
* @param {Number} height
|
||||||
|
*/
|
||||||
Kinetic.SceneCanvas = function(width, height) {
|
Kinetic.SceneCanvas = function(width, height) {
|
||||||
Kinetic.Canvas.call(this, width, height);
|
Kinetic.Canvas.call(this, width, height);
|
||||||
};
|
};
|
||||||
@@ -307,6 +324,13 @@
|
|||||||
};
|
};
|
||||||
Kinetic.Global.extend(Kinetic.SceneCanvas, Kinetic.Canvas);
|
Kinetic.Global.extend(Kinetic.SceneCanvas, Kinetic.Canvas);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hit Graph Canvas Renderer constructor
|
||||||
|
* @constructor
|
||||||
|
* @augments Kinetic.Canvas
|
||||||
|
* @param {Number} width
|
||||||
|
* @param {Number} height
|
||||||
|
*/
|
||||||
Kinetic.HitCanvas = function(width, height) {
|
Kinetic.HitCanvas = function(width, height) {
|
||||||
Kinetic.Canvas.call(this, width, height);
|
Kinetic.Canvas.call(this, width, height);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user