Permalink
Browse files

Fixed a bug that caused polygons to be slightly misdrawn

Also fixed a bug that caused images to inherit properties of future
objects
  • Loading branch information...
1 parent 7da49c2 commit 0c45a1c10afd9b19503164361810c139b7928b8d @caleb531 committed Mar 20, 2013
Showing with 51 additions and 51 deletions.
  1. 0 build/Pull from GitHub.command
  2. +1 −1 jcanvas.jquery.json
  3. +12 −12 jcanvas.js
  4. +38 −38 jcanvas.min.js
View
0 build/Pull from GitHub.command 100644 → 100755
No changes.
View
@@ -1,7 +1,7 @@
{
"name": "jcanvas",
"title": "jCanvas",
- "version": "13.03.13",
+ "version": "13.03.20",
"author": {
"name": "Caleb Evans",
"email": "calebevans.me@gmail.com",
View
@@ -1,5 +1,5 @@
/**
- * @license jCanvas v13.03.13
+ * @license jCanvas v13.03.20
* Copyright 2013 Caleb Evans
* Released under the MIT license
*/
@@ -700,7 +700,7 @@ function addLayer(canvas, params, args, method) {
// Store arguments object for later use
params._args = args;
params.canvas = canvas;
-
+
// Only add layer if it hasn't been added before
if (params.layer && !params._layer) {
@@ -1620,14 +1620,14 @@ $.fn.drawPolygon = function self(args) {
ctx.beginPath();
for (i=0; i<params.sides; i+=1) {
// Draw side of polygon
- x = params.x + round(params.radius * cos(theta));
- y = params.y + round(params.radius * sin(theta));
+ x = params.x + (params.radius * cos(theta));
+ y = params.y + (params.radius * sin(theta));
ctx.lineTo(x, y);
// Project side if chosen
if (params.concavity) {
// Sides are projected from the polygon's apothem
- x = params.x + round((apothem + -apothem*params.concavity) * cos(theta + hdtheta));
- y = params.y + round((apothem + -apothem*params.concavity) * sin(theta + hdtheta));
+ x = params.x + ((apothem + -apothem*params.concavity) * cos(theta + hdtheta));
+ y = params.y + ((apothem + -apothem*params.concavity) * sin(theta + hdtheta));
ctx.lineTo(x, y);
}
theta += dtheta;
@@ -2290,9 +2290,12 @@ $.fn.drawImage = function self(args) {
}
- // Only position image
+ // Set global canvas properties
+ setGlobalProps(ctx, params);
+
+ // Position/transform image if necessary
transformShape(ctx, params, params.width, params.height);
-
+
// Draw image
ctx.drawImage(
img,
@@ -2306,7 +2309,6 @@ $.fn.drawImage = function self(args) {
params.height
);
// Ensure the rectangle is actually invisible (still allow stroking)
- ctx.fillStyle = 'transparent';
// Draw invisible rectangle to allow for events and masking
ctx.beginPath();
ctx.rect(
@@ -2340,9 +2342,7 @@ $.fn.drawImage = function self(args) {
args = addLayer($canvases[e], params, args, self);
if (params.visible) {
-
- setGlobalProps(ctx, params);
-
+
// Draw image if already loaded
if (img) {
if (img.complete || imgCtx) {
Oops, something went wrong.

0 comments on commit 0c45a1c

Please sign in to comment.