Skip to content

Commit

Permalink
Better testing if objects are drawable.
Browse files Browse the repository at this point in the history
  • Loading branch information
stebanos committed Mar 5, 2018
1 parent 88c9dea commit f38690b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/libraries/vg/commands/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ vg.isDrawable = function (o) {
return false;
} else if (typeof o.draw === 'function') {
return true;
} else if (o.x !== undefined && o.y !== undefined) {
} else if (typeof o.x === 'number' && typeof o.y === 'number') {
return true;
} else if (o.r !== undefined && o.g !== undefined && o.b !== undefined) {
} else if (typeof o.r === 'number' && typeof o.g === 'number' && typeof o.b === 'number') {
return true;
} else {
return false;
Expand Down Expand Up @@ -87,15 +87,15 @@ vg.draw = function (ctx, o) {
} else {
o.draw(ctx);
}
} else if (k.x !== undefined && k.y !== undefined) {
if (k.r !== undefined && k.g !== undefined && k.b !== undefined) {
} else if (typeof k.x === 'number' && typeof k.y === 'number') {
if (typeof k.r === 'number' && typeof k.g === 'number' && typeof k.b === 'number') {
vg.drawColoredPoints(ctx, isArray ? o : [o]);
} else if (k.width !== undefined && k.height !== undefined) {
} else if (typeof k.width === 'number' && typeof k.height === 'number') {
vg.drawRectangles(ctx, isArray ? o : [o]);
} else {
vg.drawPoints(ctx, isArray ? o : [o]);
}
} else if (k.r !== undefined && k.g !== undefined && k.b !== undefined) {
} else if (typeof k.r === 'number' && typeof k.g === 'number' && typeof k.b === 'number') {
vg.drawColors(ctx, isArray ? o : [o]);
}
}
Expand Down

0 comments on commit f38690b

Please sign in to comment.