update CHANGELOG with new version

This commit is contained in:
Anton Lavrenov 2019-08-31 16:40:39 -05:00
parent 5bc1bb87bb
commit e325deef1d
6 changed files with 16370 additions and 16310 deletions

View File

@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## Not released: ## Not released:
## 4.0.6 - 2019-08-31
* Fix fillPatternScale for text
## 4.0.5 - 2019-08-17 ## 4.0.5 - 2019-08-17
* Fix `dragstart` flow when `node.startDrag()` is called. * Fix `dragstart` flow when `node.startDrag()` is called.

32603
konva.js

File diff suppressed because it is too large Load Diff

4
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -664,8 +664,6 @@ export class SceneContext extends Context {
_fillPattern(shape) { _fillPattern(shape) {
var fillPatternX = shape.getFillPatternX(), var fillPatternX = shape.getFillPatternX(),
fillPatternY = shape.getFillPatternY(), fillPatternY = shape.getFillPatternY(),
fillPatternScaleX = shape.getFillPatternScaleX(),
fillPatternScaleY = shape.getFillPatternScaleY(),
fillPatternRotation = Konva.getAngle(shape.getFillPatternRotation()), fillPatternRotation = Konva.getAngle(shape.getFillPatternRotation()),
fillPatternOffsetX = shape.getFillPatternOffsetX(), fillPatternOffsetX = shape.getFillPatternOffsetX(),
fillPatternOffsetY = shape.getFillPatternOffsetY(); fillPatternOffsetY = shape.getFillPatternOffsetY();
@ -678,9 +676,6 @@ export class SceneContext extends Context {
this.rotate(fillPatternRotation); this.rotate(fillPatternRotation);
} }
if (fillPatternScaleX || fillPatternScaleY) {
this.scale(fillPatternScaleX, fillPatternScaleY);
}
if (fillPatternOffsetX || fillPatternOffsetY) { if (fillPatternOffsetX || fillPatternOffsetY) {
this.translate(-1 * fillPatternOffsetX, -1 * fillPatternOffsetY); this.translate(-1 * fillPatternOffsetX, -1 * fillPatternOffsetY);
} }

View File

@ -81,7 +81,7 @@ var linearGradient = 'linearGradient';
var radialGradient = 'radialGradient'; var radialGradient = 'radialGradient';
var dummyContext; var dummyContext;
function getDummyContext() { function getDummyContext(): CanvasRenderingContext2D {
if (dummyContext) { if (dummyContext) {
return dummyContext; return dummyContext;
} }
@ -193,7 +193,7 @@ export class Shape<Config extends ShapeConfig = ShapeConfig> extends Node<
); );
this.on( this.on(
'fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva', 'fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva',
_clearFillPatternCache _clearFillPatternCache
); );
@ -261,10 +261,20 @@ export class Shape<Config extends ShapeConfig = ShapeConfig> extends Node<
__getFillPattern() { __getFillPattern() {
if (this.fillPatternImage()) { if (this.fillPatternImage()) {
var ctx = getDummyContext(); var ctx = getDummyContext();
return ctx.createPattern( const pattern = ctx.createPattern(
this.fillPatternImage(), this.fillPatternImage(),
this.fillPatternRepeat() || 'repeat' this.fillPatternRepeat() || 'repeat'
); );
pattern.setTransform({
a: this.fillPatternScaleX(), // Horizontal scaling. A value of 1 results in no scaling.
b: 0, // Vertical skewing.
c: 0, // Horizontal skewing.
d: this.fillPatternScaleY(), // Vertical scaling. A value of 1 results in no scaling.
e: 0, // Horizontal translation (moving).
f: 0 // Vertical translation (moving).
});
// pattern.setTransform
return pattern;
} }
} }
_getLinearGradient() { _getLinearGradient() {
@ -281,7 +291,7 @@ export class Shape<Config extends ShapeConfig = ShapeConfig> extends Node<
// build color stops // build color stops
for (var n = 0; n < colorStops.length; n += 2) { for (var n = 0; n < colorStops.length; n += 2) {
grd.addColorStop(colorStops[n], colorStops[n + 1]); grd.addColorStop(colorStops[n] as number, colorStops[n + 1] as string);
} }
return grd; return grd;
} }
@ -308,7 +318,7 @@ export class Shape<Config extends ShapeConfig = ShapeConfig> extends Node<
// build color stops // build color stops
for (var n = 0; n < colorStops.length; n += 2) { for (var n = 0; n < colorStops.length; n += 2) {
grd.addColorStop(colorStops[n], colorStops[n + 1]); grd.addColorStop(colorStops[n] as number, colorStops[n + 1] as string);
} }
return grd; return grd;
} }

View File

@ -1006,4 +1006,48 @@ suite('Text', function() {
}; };
imageObj.src = 'assets/darth-vader.jpg'; imageObj.src = 'assets/darth-vader.jpg';
}); });
test('image gradient for text with scale', function(done) {
Konva.pixelRatio = 1;
var imageObj = new Image();
imageObj.onload = function() {
var stage = addStage();
var layer = new Konva.Layer();
var text = new Konva.Text({
text: 'Hello, this is some good text',
fontSize: 30,
fillPatternImage: imageObj,
fillPatternScaleX: 0.5,
fillPatternScaleY: 0.5
});
layer.add(text);
stage.add(layer);
var canvas = createCanvas();
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'green';
ctx.font = 'normal normal 30px Arial';
ctx.textBaseline = 'middle';
var grd = ctx.createPattern(imageObj, 'repeat');
grd.setTransform({
a: 0.5, // Horizontal scaling. A value of 1 results in no scaling.
b: 0, // Vertical skewing.
c: 0, // Horizontal skewing.
d: 0.5, // Vertical scaling. A value of 1 results in no scaling.
e: 0, // Horizontal translation (moving).
f: 0 // Vertical translation (moving).
});
ctx.fillStyle = grd;
ctx.fillText(text.text(), 0, 15);
compareLayerAndCanvas(layer, canvas, 200);
delete Konva.pixelRatio;
done();
};
imageObj.src = 'assets/darth-vader.jpg';
});
}); });