mirror of
https://github.com/konvajs/konva.git
synced 2026-03-03 16:58:33 +08:00
added getter and setter methods for pixel ratio. Also added unit tests
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
|| context.mozBackingStorePixelRatio
|
||||
|| context.msBackingStorePixelRatio
|
||||
|| context.oBackingStorePixelRatio
|
||||
|| context.backingStorePixelRatio || 1,
|
||||
|| context.backingStorePixelRatio
|
||||
|| 1,
|
||||
_pixelRatio = devicePixelRatio / backingStoreRatio;
|
||||
|
||||
/**
|
||||
@@ -46,11 +47,31 @@
|
||||
this.context = this.element.getContext(contextType);
|
||||
this.setSize(width, height);
|
||||
},
|
||||
/**
|
||||
* get pixel ratio
|
||||
* @method
|
||||
* @memberof Kinetic.Canvas.prototype
|
||||
* @returns {Number} pixel ratio
|
||||
*/
|
||||
getPixelRatio: function() {
|
||||
return this.pixelRatio;
|
||||
},
|
||||
/**
|
||||
* get pixel ratio
|
||||
* @method
|
||||
* @memberof Kinetic.Canvas.prototype
|
||||
*/
|
||||
setPixelRatio: function(pixelRatio) {
|
||||
this.pixelRatio = pixelRatio;
|
||||
this.setSize(this.getWidth(), this.getHeight());
|
||||
},
|
||||
/**
|
||||
* reset canvas context transform
|
||||
* @method
|
||||
* @memberof Kinetic.Canvas.prototype
|
||||
*/
|
||||
reset: function() {
|
||||
this.getContext().setTransform(1 * _pixelRatio, 0, 0, 1 * _pixelRatio, 0, 0);
|
||||
this.getContext().setTransform(1 * this.pixelRatio, 0, 0, 1 * this.pixelRatio, 0, 0);
|
||||
},
|
||||
/**
|
||||
* get canvas element
|
||||
|
||||
Reference in New Issue
Block a user