Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control cusomization part 3 - allow for rounded corners #2942

Merged
merged 5 commits into from
May 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/mixins/object_interactivity.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
scaleOffset = this.cornerSize,
left = -(width + scaleOffset) / 2,
top = -(height + scaleOffset) / 2,
methodName = this.transparentCorners ? 'strokeRect' : 'fillRect';
methodName = this.transparentCorners ? 'stroke' : 'fill';

ctx.save();
ctx.strokeStyle = ctx.fillStyle = this.cornerColor;
Expand Down Expand Up @@ -357,11 +357,22 @@
if (!this.isControlVisible(control)) {
return;
}
var size = this.cornerSize;
isVML() || this.transparentCorners || ctx.clearRect(left, top, size, size);
ctx[methodName](left, top, size, size);
if (!this.transparentCorners && this.cornerStrokeColor) {
ctx.strokeRect(left, top, size, size);
var size = this.cornerSize, stroke = !this.transparentCorners && this.cornerStrokeColor;
switch (this.cornerStyle) {
case 'circle':
ctx.beginPath();
ctx.arc(left + size/2, top + size/2, size/2, 0, 2 * Math.PI, false);
ctx[methodName]();
if (stroke) {
ctx.stroke();
}
break;
default:
isVML() || this.transparentCorners || ctx.clearRect(left, top, size, size);
ctx[methodName + 'Rect'](left, top, size, size);
if (stroke) {
ctx.strokeRect(left, top, size, size);
}
}
},

Expand Down
7 changes: 7 additions & 0 deletions src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,13 @@
*/
cornerStrokeColor: null,

/**
* Specify style of control, 'rect' or 'circle'
* @since 1.6.2
* @type String
*/
cornerStyle: 'rect',

/**
* Array specifying dash pattern of an object's control (hasBorder must be true)
* @since 1.6.2
Expand Down