mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
Merge branch 'kudlajz-master'
This commit is contained in:
@@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [Not released][Not released]
|
||||
|
||||
## Added
|
||||
- `textDecoration` of `Konva.Text` now supports `line-through`
|
||||
|
||||
## [1.3.0][2017-01-10]
|
||||
|
||||
## Added
|
||||
|
28
konva.js
28
konva.js
@@ -3,7 +3,7 @@
|
||||
* Konva JavaScript Framework v1.3.0
|
||||
* http://konvajs.github.io/
|
||||
* Licensed under the MIT or GPL Version 2 licenses.
|
||||
* Date: Tue Jan 10 2017
|
||||
* Date: Tue Feb 07 2017
|
||||
*
|
||||
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
||||
* Modified work Copyright (C) 2014 - 2015 by Anton Lavrenov (Konva)
|
||||
@@ -13148,14 +13148,24 @@
|
||||
context.translate((totalWidth - width - p * 2) / 2, 0);
|
||||
}
|
||||
|
||||
if (textDecoration === 'underline') {
|
||||
if (textDecoration.indexOf('underline') !== -1) {
|
||||
context.save();
|
||||
context.beginPath();
|
||||
context.moveTo(0, Math.round(lineHeightPx / 2));
|
||||
context.lineTo(Math.round(width), Math.round(lineHeightPx / 2));
|
||||
// TODO: I have no idea what is real ratio
|
||||
// just /20 looks good enough
|
||||
context.lineWidth = fontSize / 20;
|
||||
context.lineWidth = fontSize / 15;
|
||||
context.strokeStyle = fill;
|
||||
context.stroke();
|
||||
context.restore();
|
||||
}
|
||||
if (textDecoration.indexOf('line-through') !== -1) {
|
||||
context.save();
|
||||
context.beginPath();
|
||||
context.moveTo(0, 0);
|
||||
context.lineTo(Math.round(width), 0);
|
||||
context.lineWidth = fontSize / 15;
|
||||
context.strokeStyle = fill;
|
||||
context.stroke();
|
||||
context.restore();
|
||||
@@ -13568,10 +13578,10 @@
|
||||
* text.text('Hello world!');
|
||||
*/
|
||||
|
||||
Konva.Factory.addGetterSetter(Konva.Text, 'textDecoration', null);
|
||||
Konva.Factory.addGetterSetter(Konva.Text, 'textDecoration', EMPTY_STRING);
|
||||
|
||||
/**
|
||||
* get/set text decoration of a text. Can be '' or 'underline'
|
||||
* get/set text decoration of a text. Possible values are 'underline', 'line-through' or combination of these values separated by space
|
||||
* @name textDecoration
|
||||
* @method
|
||||
* @memberof Konva.Text.prototype
|
||||
@@ -13581,8 +13591,14 @@
|
||||
* // get text decoration
|
||||
* var textDecoration = text.textDecoration();
|
||||
*
|
||||
* // center text
|
||||
* // underline text
|
||||
* text.textDecoration('underline');
|
||||
*
|
||||
* // strike text
|
||||
* text.textDecoration('line-through');
|
||||
*
|
||||
* // underline and strike text
|
||||
* text.textDecoration('underline line-through');
|
||||
*/
|
||||
|
||||
Konva.Collection.mapMethods(Konva.Text);
|
||||
|
6
konva.min.js
vendored
6
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -141,14 +141,24 @@
|
||||
context.translate((totalWidth - width - p * 2) / 2, 0);
|
||||
}
|
||||
|
||||
if (textDecoration === 'underline') {
|
||||
if (textDecoration.indexOf('underline') !== -1) {
|
||||
context.save();
|
||||
context.beginPath();
|
||||
context.moveTo(0, Math.round(lineHeightPx / 2));
|
||||
context.lineTo(Math.round(width), Math.round(lineHeightPx / 2));
|
||||
// TODO: I have no idea what is real ratio
|
||||
// just /20 looks good enough
|
||||
context.lineWidth = fontSize / 20;
|
||||
context.lineWidth = fontSize / 15;
|
||||
context.strokeStyle = fill;
|
||||
context.stroke();
|
||||
context.restore();
|
||||
}
|
||||
if (textDecoration.indexOf('line-through') !== -1) {
|
||||
context.save();
|
||||
context.beginPath();
|
||||
context.moveTo(0, 0);
|
||||
context.lineTo(Math.round(width), 0);
|
||||
context.lineWidth = fontSize / 15;
|
||||
context.strokeStyle = fill;
|
||||
context.stroke();
|
||||
context.restore();
|
||||
@@ -561,10 +571,10 @@
|
||||
* text.text('Hello world!');
|
||||
*/
|
||||
|
||||
Konva.Factory.addGetterSetter(Konva.Text, 'textDecoration', null);
|
||||
Konva.Factory.addGetterSetter(Konva.Text, 'textDecoration', EMPTY_STRING);
|
||||
|
||||
/**
|
||||
* get/set text decoration of a text. Can be '' or 'underline'
|
||||
* get/set text decoration of a text. Possible values are 'underline', 'line-through' or combination of these values separated by space
|
||||
* @name textDecoration
|
||||
* @method
|
||||
* @memberof Konva.Text.prototype
|
||||
@@ -574,8 +584,14 @@
|
||||
* // get text decoration
|
||||
* var textDecoration = text.textDecoration();
|
||||
*
|
||||
* // center text
|
||||
* // underline text
|
||||
* text.textDecoration('underline');
|
||||
*
|
||||
* // strike text
|
||||
* text.textDecoration('line-through');
|
||||
*
|
||||
* // underline and strike text
|
||||
* text.textDecoration('underline line-through');
|
||||
*/
|
||||
|
||||
Konva.Collection.mapMethods(Konva.Text);
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user