mirror of
https://github.com/konvajs/konva.git
synced 2025-06-27 21:30:35 +08:00
refactored fillStroke() method
This commit is contained in:
parent
47b8a8e0d6
commit
c698005adc
9
dist/kinetic-core.js
vendored
9
dist/kinetic-core.js
vendored
@ -2182,9 +2182,12 @@ Kinetic.Shape.prototype = {
|
|||||||
context.fill();
|
context.fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.attrs.stroke !== undefined || this.attrs.strokeWidth !== undefined) {
|
var hasStroke = this.attrs.stroke !== undefined;
|
||||||
var stroke = this.attrs.stroke !== undefined ? this.attrs.stroke : 'black';
|
var hasStrokeWidth = this.attrs.strokeWidth !== undefined && this.attrs.strokeWidth !== 0;
|
||||||
var strokeWidth = this.attrs.strokeWidth !== undefined ? this.attrs.strokeWidth : 2;
|
|
||||||
|
if(hasStroke || hasStrokeWidth) {
|
||||||
|
var stroke = hasStroke ? this.attrs.stroke : 'black';
|
||||||
|
var strokeWidth = hasStrokeWidth ? this.attrs.strokeWidth : 2;
|
||||||
|
|
||||||
context.lineWidth = strokeWidth;
|
context.lineWidth = strokeWidth;
|
||||||
context.strokeStyle = stroke;
|
context.strokeStyle = stroke;
|
||||||
|
4
dist/kinetic-core.min.js
vendored
4
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
@ -67,9 +67,12 @@ Kinetic.Shape.prototype = {
|
|||||||
context.fill();
|
context.fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.attrs.stroke !== undefined || this.attrs.strokeWidth !== undefined) {
|
var hasStroke = this.attrs.stroke !== undefined;
|
||||||
var stroke = this.attrs.stroke !== undefined ? this.attrs.stroke : 'black';
|
var hasStrokeWidth = this.attrs.strokeWidth !== undefined && this.attrs.strokeWidth !== 0;
|
||||||
var strokeWidth = this.attrs.strokeWidth !== undefined ? this.attrs.strokeWidth : 2;
|
|
||||||
|
if(hasStroke || hasStrokeWidth) {
|
||||||
|
var stroke = hasStroke ? this.attrs.stroke : 'black';
|
||||||
|
var strokeWidth = hasStrokeWidth ? this.attrs.strokeWidth : 2;
|
||||||
|
|
||||||
context.lineWidth = strokeWidth;
|
context.lineWidth = strokeWidth;
|
||||||
context.strokeStyle = stroke;
|
context.strokeStyle = stroke;
|
||||||
|
@ -578,7 +578,7 @@ Test.prototype.tests = {
|
|||||||
layer.add(circle);
|
layer.add(circle);
|
||||||
stage.add(layer);
|
stage.add(layer);
|
||||||
},
|
},
|
||||||
'EVENTS - modify fill stroke and stroke width on hover with circle with star': function(containerId) {
|
'EVENTS - modify fill stroke and stroke width on hover with star': function(containerId) {
|
||||||
var stage = new Kinetic.Stage({
|
var stage = new Kinetic.Stage({
|
||||||
container: containerId,
|
container: containerId,
|
||||||
width: 578,
|
width: 578,
|
||||||
@ -615,7 +615,7 @@ Test.prototype.tests = {
|
|||||||
layer.add(star);
|
layer.add(star);
|
||||||
stage.add(layer);
|
stage.add(layer);
|
||||||
},
|
},
|
||||||
'EVENTS - modify fill stroke and stroke width on hover with circle with image': function(containerId) {
|
'EVENTS - modify fill stroke and stroke width on hover with image': function(containerId) {
|
||||||
var imageObj = new Image();
|
var imageObj = new Image();
|
||||||
imageObj.onload = function() {
|
imageObj.onload = function() {
|
||||||
var stage = new Kinetic.Stage({
|
var stage = new Kinetic.Stage({
|
||||||
@ -631,14 +631,12 @@ Test.prototype.tests = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
darth.on('mouseover', function() {
|
darth.on('mouseover', function() {
|
||||||
this.setFill('yellow');
|
|
||||||
this.setStroke('purple');
|
this.setStroke('purple');
|
||||||
this.setStrokeWidth(20);
|
this.setStrokeWidth(20);
|
||||||
layer.draw();
|
layer.draw();
|
||||||
});
|
});
|
||||||
|
|
||||||
darth.on('mouseout', function() {
|
darth.on('mouseout', function() {
|
||||||
this.setFill(undefined);
|
|
||||||
this.setStroke(undefined);
|
this.setStroke(undefined);
|
||||||
this.setStrokeWidth(0);
|
this.setStrokeWidth(0);
|
||||||
layer.draw();
|
layer.draw();
|
||||||
|
Loading…
Reference in New Issue
Block a user