Skip to content

Commit

Permalink
fixes for strand-guide
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonykoerber committed May 11, 2016
1 parent b32e39c commit f9e0973
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
31 changes: 9 additions & 22 deletions src/strand-guide-canvas/strand-guide-canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,22 @@

var Rectangle = StrandLib.Rectangle;

function drawEllipseWithQuatraticCurve(ctx, x, y, w, h, style) {
var kappa = .5522848,
ox = (w / 2) * kappa, // control point offset horizontal
oy = (h / 2) * kappa, // control point offset vertical
xe = x + w, // x-end
ye = y + h, // y-end
xm = x + w / 2, // x-middle
ym = y + h / 2; // y-middle
function drawCircle(ctx, x, y, r, sa, ea, style) {
if (!sa) sa = 0;
if (!ea) ea = 2 * Math.PI;

ctx.save();
ctx.beginPath();
ctx.moveTo(x, ym);
ctx.quadraticCurveTo(x,y,xm,y);
ctx.quadraticCurveTo(xe,y,xe,ym);
ctx.quadraticCurveTo(xe,ye,xm,ye);
ctx.quadraticCurveTo(x,ye,x,ym);
ctx.arc(x, y, r, sa, ea);
if(style)
ctx.strokeStyle = style;
ctx.stroke();
ctx.restore();
}

function drawCircle(ctx, x, y, r, sa, ea, style) {
if (!sa) sa = 0;
if (!ea) ea = 2 * Math.PI;

function drawRectangle(ctx, x, y, w, h, style) {
ctx.save();
ctx.beginPath();
ctx.arc(x, y, r, sa, ea);
ctx.fillRect(x, y, w, h);
if(style)
ctx.strokeStyle = style;
ctx.stroke();
Expand Down Expand Up @@ -105,7 +92,7 @@
ctx.globalCompositeOperation = 'destination-out';
ctx.fillStyle = 'red';

if (this.spotlightType === this.TYPE_CIRCLE) {
if (this.spotlightType === 'circle') {
var greater = (rect.width > rect.height) ? rect.width : rect.height;
drawCircle(
ctx,
Expand All @@ -114,8 +101,8 @@
greater/2 + this.spotlightOffset
);
} else {
drawEllipseWithQuatraticCurve(
ctx,
drawRectangle(
ctx,
rect.x - this.spotlightOffset,
rect.y - this.spotlightOffset,
rect.width + this.spotlightOffset*2,
Expand Down
1 change: 1 addition & 0 deletions src/strand-guide/strand-guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
id="focus"
hidden="{{hidden}}"
spotlight-offset="{{spotlightOffset}}"
spotlight-type="{{spotlightType}}"
opacity="{{opacity}}"
data="{{_tooltipData}}"
current-step="{{_currentStep}}"></strand-guide-canvas>
Expand Down
2 changes: 1 addition & 1 deletion src/strand-guide/strand-guide.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],

TYPE_CIRCLE: 'circle',
TYPE_ELLIPSE: 'ellipse',
TYPE_RECTANGLE: 'rectangle',

properties: {
contentTarget: {
Expand Down

0 comments on commit f9e0973

Please sign in to comment.