mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 15:23:44 +08:00
fix: restore inside attribute access
This commit is contained in:
parent
970035baf7
commit
0fb74259af
@ -280,7 +280,7 @@ export class Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_applyLineCap(shape: Shape) {
|
_applyLineCap(shape: Shape) {
|
||||||
const lineCap = shape.lineCap();
|
const lineCap = shape.attrs.lineCap;
|
||||||
if (lineCap) {
|
if (lineCap) {
|
||||||
this.setAttr('lineCap', lineCap);
|
this.setAttr('lineCap', lineCap);
|
||||||
}
|
}
|
||||||
@ -292,7 +292,7 @@ export class Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_applyLineJoin(shape: Shape) {
|
_applyLineJoin(shape: Shape) {
|
||||||
const lineJoin = shape.lineJoin();
|
const lineJoin = shape.attrs.lineJoin;
|
||||||
if (lineJoin) {
|
if (lineJoin) {
|
||||||
this.setAttr('lineJoin', lineJoin);
|
this.setAttr('lineJoin', lineJoin);
|
||||||
}
|
}
|
||||||
@ -794,9 +794,9 @@ export class SceneContext extends Context {
|
|||||||
shape._fillFunc(this);
|
shape._fillFunc(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_fill(shape: Shape) {
|
_fill(shape) {
|
||||||
const hasColor = shape.fill(),
|
const hasColor = shape.fill(),
|
||||||
fillPriority = shape.fillPriority();
|
fillPriority = shape.getFillPriority();
|
||||||
|
|
||||||
// priority fills
|
// priority fills
|
||||||
if (hasColor && fillPriority === 'color') {
|
if (hasColor && fillPriority === 'color') {
|
||||||
@ -804,19 +804,19 @@ export class SceneContext extends Context {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasPattern = shape.fillPatternImage();
|
const hasPattern = shape.getFillPatternImage();
|
||||||
if (hasPattern && fillPriority === 'pattern') {
|
if (hasPattern && fillPriority === 'pattern') {
|
||||||
this._fillPattern(shape);
|
this._fillPattern(shape);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasLinearGradient = shape.fillLinearGradientColorStops();
|
const hasLinearGradient = shape.getFillLinearGradientColorStops();
|
||||||
if (hasLinearGradient && fillPriority === 'linear-gradient') {
|
if (hasLinearGradient && fillPriority === 'linear-gradient') {
|
||||||
this._fillLinearGradient(shape);
|
this._fillLinearGradient(shape);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasRadialGradient = shape.fillRadialGradientColorStops();
|
const hasRadialGradient = shape.getFillRadialGradientColorStops();
|
||||||
if (hasRadialGradient && fillPriority === 'radial-gradient') {
|
if (hasRadialGradient && fillPriority === 'radial-gradient') {
|
||||||
this._fillRadialGradient(shape);
|
this._fillRadialGradient(shape);
|
||||||
return;
|
return;
|
||||||
@ -833,10 +833,10 @@ export class SceneContext extends Context {
|
|||||||
this._fillRadialGradient(shape);
|
this._fillRadialGradient(shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_strokeLinearGradient(shape: Shape) {
|
_strokeLinearGradient(shape) {
|
||||||
const start = shape.strokeLinearGradientStartPoint(),
|
const start = shape.getStrokeLinearGradientStartPoint(),
|
||||||
end = shape.strokeLinearGradientEndPoint(),
|
end = shape.getStrokeLinearGradientEndPoint(),
|
||||||
colorStops = shape.strokeLinearGradientColorStops(),
|
colorStops = shape.getStrokeLinearGradientColorStops(),
|
||||||
grd = this.createLinearGradient(start.x, start.y, end.x, end.y);
|
grd = this.createLinearGradient(start.x, start.y, end.x, end.y);
|
||||||
|
|
||||||
if (colorStops) {
|
if (colorStops) {
|
||||||
@ -847,16 +847,15 @@ export class SceneContext extends Context {
|
|||||||
this.setAttr('strokeStyle', grd);
|
this.setAttr('strokeStyle', grd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_stroke(shape: Shape) {
|
_stroke(shape) {
|
||||||
var dash = shape.dash(),
|
var dash = shape.dash(),
|
||||||
// ignore strokeScaleEnabled for Text
|
// ignore strokeScaleEnabled for Text
|
||||||
strokeScaleEnabled = shape.strokeScaleEnabled();
|
strokeScaleEnabled = shape.getStrokeScaleEnabled();
|
||||||
|
|
||||||
if (shape.hasStroke()) {
|
if (shape.hasStroke()) {
|
||||||
if (!strokeScaleEnabled) {
|
if (!strokeScaleEnabled) {
|
||||||
this.save();
|
this.save();
|
||||||
var pixelRatio = this.getCanvas().getPixelRatio();
|
var pixelRatio = this.getCanvas().getPixelRatio();
|
||||||
console.log(pixelRatio);
|
|
||||||
this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
|
this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -868,11 +867,11 @@ export class SceneContext extends Context {
|
|||||||
|
|
||||||
this.setAttr('lineWidth', shape.strokeWidth());
|
this.setAttr('lineWidth', shape.strokeWidth());
|
||||||
|
|
||||||
if (!shape.shadowForStrokeEnabled()) {
|
if (!shape.getShadowForStrokeEnabled()) {
|
||||||
this.setAttr('shadowColor', 'rgba(0,0,0,0)');
|
this.setAttr('shadowColor', 'rgba(0,0,0,0)');
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasLinearGradient = shape.strokeLinearGradientColorStops();
|
var hasLinearGradient = shape.getStrokeLinearGradientColorStops();
|
||||||
if (hasLinearGradient) {
|
if (hasLinearGradient) {
|
||||||
this._strokeLinearGradient(shape);
|
this._strokeLinearGradient(shape);
|
||||||
} else {
|
} else {
|
||||||
@ -886,10 +885,10 @@ export class SceneContext extends Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_applyShadow(shape: Shape) {
|
_applyShadow(shape) {
|
||||||
var color = shape.getShadowRGBA() ?? 'black',
|
var color = shape.getShadowRGBA() ?? 'black',
|
||||||
blur = shape.shadowBlur() ?? 5,
|
blur = shape.getShadowBlur() ?? 5,
|
||||||
offset = shape.shadowOffset() ?? {
|
offset = shape.getShadowOffset() ?? {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
},
|
},
|
||||||
@ -915,7 +914,7 @@ export class HitContext extends Context {
|
|||||||
willReadFrequently: true,
|
willReadFrequently: true,
|
||||||
}) as CanvasRenderingContext2D;
|
}) as CanvasRenderingContext2D;
|
||||||
}
|
}
|
||||||
_fill(shape) {
|
_fill(shape: Shape) {
|
||||||
this.save();
|
this.save();
|
||||||
this.setAttr('fillStyle', shape.colorKey);
|
this.setAttr('fillStyle', shape.colorKey);
|
||||||
shape._fillFuncHit(this);
|
shape._fillFuncHit(this);
|
||||||
@ -926,10 +925,10 @@ export class HitContext extends Context {
|
|||||||
this._stroke(shape);
|
this._stroke(shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_stroke(shape: Shape) {
|
_stroke(shape) {
|
||||||
if (shape.hasHitStroke()) {
|
if (shape.hasHitStroke()) {
|
||||||
// ignore strokeScaleEnabled for Text
|
// ignore strokeScaleEnabled for Text
|
||||||
const strokeScaleEnabled = shape.strokeScaleEnabled();
|
const strokeScaleEnabled = shape.getStrokeScaleEnabled();
|
||||||
if (!strokeScaleEnabled) {
|
if (!strokeScaleEnabled) {
|
||||||
this.save();
|
this.save();
|
||||||
var pixelRatio = this.getCanvas().getPixelRatio();
|
var pixelRatio = this.getCanvas().getPixelRatio();
|
||||||
|
Loading…
Reference in New Issue
Block a user