mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
strokeScaleEnabled = false is disabled for text
This commit is contained in:
parent
4dfc65dba4
commit
d6cfd29962
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "KineticJS",
|
||||
"version": "5.1.10",
|
||||
"version": "5.2.0",
|
||||
"authors": [
|
||||
"Eric Rowell", "Anton Lavrenov"
|
||||
],
|
||||
|
12
kinetic.js
12
kinetic.js
@ -2055,7 +2055,7 @@ var Kinetic = {};
|
||||
strokeScaleEnabled = shape.getStrokeScaleEnabled();
|
||||
|
||||
if(shape.hasStroke()) {
|
||||
if (!strokeScaleEnabled) {
|
||||
if (!strokeScaleEnabled && !(shape instanceof Kinetic.Text)) {
|
||||
this.save();
|
||||
this.setTransform(1, 0, 0, 1, 0, 0);
|
||||
}
|
||||
@ -10611,6 +10611,7 @@ var Kinetic = {};
|
||||
}
|
||||
else {
|
||||
// arcTo would be nicer, but browser support is patchy (Opera)
|
||||
cornerRadius = Math.min(cornerRadius, width / 2, height / 2);
|
||||
context.moveTo(cornerRadius, 0);
|
||||
context.lineTo(width - cornerRadius, 0);
|
||||
context.arc(width - cornerRadius, cornerRadius, cornerRadius, Math.PI * 3 / 2, 0, false);
|
||||
@ -11978,8 +11979,13 @@ var Kinetic = {};
|
||||
context.setAttr('textBaseline', MIDDLE);
|
||||
context.setAttr('textAlign', LEFT);
|
||||
context.save();
|
||||
context.translate(p, 0);
|
||||
context.translate(0, p + textHeight / 2);
|
||||
if (p) {
|
||||
context.translate(p, 0);
|
||||
context.translate(0, p + textHeight / 2);
|
||||
} else {
|
||||
context.translate(0, textHeight / 2);
|
||||
}
|
||||
|
||||
|
||||
// draw text lines
|
||||
for(n = 0; n < textArrLen; n++) {
|
||||
|
6
kinetic.min.js
vendored
6
kinetic.min.js
vendored
File diff suppressed because one or more lines are too long
@ -517,7 +517,7 @@
|
||||
strokeScaleEnabled = shape.getStrokeScaleEnabled();
|
||||
|
||||
if(shape.hasStroke()) {
|
||||
if (!strokeScaleEnabled) {
|
||||
if (!strokeScaleEnabled && !(shape instanceof Kinetic.Text)) {
|
||||
this.save();
|
||||
this.setTransform(1, 0, 0, 1, 0, 0);
|
||||
}
|
||||
|
@ -104,8 +104,13 @@
|
||||
context.setAttr('textBaseline', MIDDLE);
|
||||
context.setAttr('textAlign', LEFT);
|
||||
context.save();
|
||||
context.translate(p, 0);
|
||||
context.translate(0, p + textHeight / 2);
|
||||
if (p) {
|
||||
context.translate(p, 0);
|
||||
context.translate(0, p + textHeight / 2);
|
||||
} else {
|
||||
context.translate(0, textHeight / 2);
|
||||
}
|
||||
|
||||
|
||||
// draw text lines
|
||||
for(n = 0; n < textArrLen; n++) {
|
||||
|
@ -57,7 +57,7 @@ suite('Label', function() {
|
||||
// resulting in slightly different tag dimensions
|
||||
var relaxedTrace = layer.getContext().getTrace(true);
|
||||
|
||||
assert.equal(relaxedTrace, 'clearRect();save();save();globalAlpha;shadowColor;shadowBlur;shadowOffsetX;shadowOffsetY;drawImage();restore();drawImage();restore();save();transform();font;textBaseline;textAlign;save();translate();translate();save();fillStyle;fillText();restore();translate();restore();restore();clearRect();save();save();globalAlpha;shadowColor;shadowBlur;shadowOffsetX;shadowOffsetY;drawImage();restore();drawImage();restore();save();transform();font;textBaseline;textAlign;save();translate();translate();save();fillStyle;fillText();restore();translate();restore();restore();');
|
||||
assert.equal(relaxedTrace, 'clearRect();save();save();globalAlpha;shadowColor;shadowBlur;shadowOffsetX;shadowOffsetY;drawImage();restore();drawImage();restore();save();transform();font;textBaseline;textAlign;save();translate();save();fillStyle;fillText();restore();translate();restore();restore();clearRect();save();save();globalAlpha;shadowColor;shadowBlur;shadowOffsetX;shadowOffsetY;drawImage();restore();drawImage();restore();save();transform();font;textBaseline;textAlign;save();translate();save();fillStyle;fillText();restore();translate();restore();restore();');
|
||||
|
||||
});
|
||||
|
||||
|
@ -313,5 +313,36 @@ suite('Text', function(){
|
||||
assert.equal(text.fill(), 'black');
|
||||
});
|
||||
|
||||
test('text with stoke and strokeScaleEnabled', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Kinetic.Layer();
|
||||
|
||||
var text = new Kinetic.Text({
|
||||
fontSize: 50,
|
||||
y : 50,
|
||||
x : 50,
|
||||
fill: 'black',
|
||||
text: 'text',
|
||||
stroke : 'red',
|
||||
strokeScaleEnabled: false,
|
||||
strokeWidth:2,
|
||||
scaleX : 2
|
||||
});
|
||||
layer.add(text);
|
||||
stage.add(layer);
|
||||
|
||||
var canvas = createCanvas();
|
||||
var context = canvas.getContext('2d');
|
||||
context.translate(50, 50);
|
||||
context.lineWidth = 2;
|
||||
context.font = '50px Arial';
|
||||
context.strokeStyle = 'red';
|
||||
context.scale(2, 1);
|
||||
context.textBaseline = 'middle';
|
||||
context.fillText('text', 0, 25);
|
||||
context.strokeText('text', 0, 25);
|
||||
compareLayerAndCanvas(layer, canvas);
|
||||
});
|
||||
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user