diff --git a/src/Canvas.ts b/src/Canvas.ts index eb122941..96002cca 100644 --- a/src/Canvas.ts +++ b/src/Canvas.ts @@ -82,9 +82,32 @@ export class Canvas { getContext() { return this.context; } + /** + * get pixel ratio + * @method + * @name Konva.Canvas#getPixelRatio + * @returns {Number} pixel ratio + * @example + * var pixelRatio = layer.getCanvas.getPixelRatio(); + */ getPixelRatio() { return this.pixelRatio; } + /** + * set pixel ratio + * KonvaJS automatically handles pixel ratio adustments in order to render crisp drawings + * on all devices. Most desktops, low end tablets, and low end phones, have device pixel ratios + * of 1. Some high end tablets and phones, like iPhones and iPads have a device pixel ratio + * of 2. Some Macbook Pros, and iMacs also have a device pixel ratio of 2. Some high end Android devices have pixel + * ratios of 2 or 3. Some browsers like Firefox allow you to configure the pixel ratio of the viewport. Unless otherwise + * specificed, the pixel ratio will be defaulted to the actual device pixel ratio. You can override the device pixel + * ratio for special situations, or, if you don't want the pixel ratio to be taken into account, you can set it to 1. + * @method + * @name Konva.Canvas#setPixelRatio + * @param {Number} pixelRatio + * @example + * layer.getCanvas().setPixelRatio(3); + */ setPixelRatio(pixelRatio) { const previousRatio = this.pixelRatio; this.pixelRatio = pixelRatio; @@ -148,28 +171,6 @@ export class Canvas { } } -/** - * get/set pixel ratio. - * KonvaJS automatically handles pixel ratio adustments in order to render crisp drawings - * on all devices. Most desktops, low end tablets, and low end phones, have device pixel ratios - * of 1. Some high end tablets and phones, like iPhones and iPads have a device pixel ratio - * of 2. Some Macbook Pros, and iMacs also have a device pixel ratio of 2. Some high end Android devices have pixel - * ratios of 2 or 3. Some browsers like Firefox allow you to configure the pixel ratio of the viewport. Unless otherwise - * specificed, the pixel ratio will be defaulted to the actual device pixel ratio. You can override the device pixel - * ratio for special situations, or, if you don't want the pixel ratio to be taken into account, you can set it to 1. - * @name Konva.Canvas#pixelRatio - * @method - * @param {Number} pixelRatio - * @returns {Number} - * @example - * // get - * var pixelRatio = layer.getCanvas.pixelRatio(); - * - * // set - * layer.getCanvas().pixelRatio(3); - */ -Factory.addGetterSetter(Canvas, 'pixelRatio', undefined, getNumberValidator()); - export class SceneCanvas extends Canvas { constructor( config: ICanvasConfig = { width: 0, height: 0, willReadFrequently: false } diff --git a/src/shapes/Text.ts b/src/shapes/Text.ts index a54b1d6a..984b553d 100644 --- a/src/shapes/Text.ts +++ b/src/shapes/Text.ts @@ -640,7 +640,7 @@ export class Text extends Shape { * 1. the current line is the last line * 2. wrap is NONE * @param {Number} currentHeightPx - * @returns + * @returns {Boolean} */ _shouldHandleEllipsis(currentHeightPx: number): boolean { const fontSize = +this.fontSize(),