Permalink
Browse files

PaintWeb generic bug fixes.

- Fixed the simple demo to "work" in MSIE. That is: it should nicely tell the
user that PaintWeb does not work. Before this update, the scripts had JS
"errors".

- Improved the Bézier curve. When only two points were available, the line drawn
didn't use the correct color.

- Fixed an image save bug. At times it did "err", because the first argument of
the imageSave() method is a DOM event object instead of a string when invoked as
a command from the toolbar.

--HG--
extra : convert_revision : svn%3Afc1ba2b4-ac28-11dd-a772-7fcde58d38e6/trunk%40119
  • Loading branch information...
1 parent 4169ee4 commit a5cc1738432b63ba715742bf4820b37920df78de mihai.sucan committed Aug 24, 2009
Showing with 72 additions and 45 deletions.
  1. +14 −0 CHANGES
  2. +9 −3 demos/demo1.html
  3. +3 −3 ext/moodle/config.json
  4. +3 −3 src/config-example.json
  5. +4 −3 src/interfaces/default/script.js
  6. +10 −11 src/paintweb.js
  7. +29 −22 src/tools/bcurve.js
View
14 CHANGES
@@ -1,3 +1,17 @@
+2009-08-24:
+===========
+
+- Fixed the simple demo to "work" in MSIE. That is: it should nicely tell the
+user that PaintWeb does not work. Before this update, the scripts had JS
+"errors".
+
+- Improved the Bézier curve. When only two points were available, the line drawn
+didn't use the correct color.
+
+- Fixed an image save bug. At times it did "err", because the first argument of
+the imageSave() method is a DOM event object instead of a string when invoked as
+a command from the toolbar.
+
2009-08-23:
===========
View
12 demos/demo1.html
@@ -7,7 +7,7 @@
title="Marius and Mihai Şucan, ROBO Design">
<!-- $URL: http://code.google.com/p/paintweb $
- $Date: 2009-07-21 19:51:44 +0300 $ -->
+ $Date: 2009-08-24 14:14:53 +0300 $ -->
</head>
<body>
<h1>PaintWeb simple demo</h1>
@@ -26,7 +26,7 @@
href="http://moodle.org/mod/forum/discuss.php?d=126528">post it over at
Moodle</a>!</p>
- <!--[if IE]>
+ <!--[if lte IE 8]>
<p>Please note that this application does not work in Internet Explorer. Any
other modern browser should work fine. Try <a
href="http://www.google.com/chrome">Chrome</a>, <a
@@ -91,7 +91,13 @@
pw.config.configFile = 'config-example.json';
loadp.appendChild(document.createTextNode('Loading, please wait...'));
- btn.addEventListener('click', pwStart, false);
+ if (btn.addEventListener) {
+ btn.addEventListener('click', pwStart, false);
+ } else if (btn.attachEvent) {
+ btn.attachEvent('onclick', pwStart);
+ } else {
+ btn.onclick = pwStart;
+ }
})();
--></script>
</body>
View
6 ext/moodle/config.json
@@ -1,5 +1,5 @@
{
- // $Date: 2009-08-23 16:28:45 +0300 $
+ // $Date: 2009-08-24 21:08:14 +0300 $
/**
* The list of available languages. This associated language IDs to their
@@ -244,8 +244,8 @@
"toolDefault": "line",
/**
- * Tool drawing delay. Some tools delay their drawing operations for
- * performance reasons.
+ * Tool drawing delay (milliseconds). Some tools delay their drawing
+ * operations for performance reasons.
*
* @type Number
* @default 80
View
6 src/config-example.json
@@ -1,5 +1,5 @@
{
- // $Date: 2009-08-22 12:05:52 +0300 $
+ // $Date: 2009-08-24 20:54:41 +0300 $
// TODO: try jsdoc-toolkit on this json (!)
/**
@@ -241,8 +241,8 @@
"toolDefault": "line",
/**
- * Tool drawing delay. Some tools delay their drawing operations for
- * performance reasons.
+ * Tool drawing delay (milliseconds). Some tools delay their drawing
+ * operations for performance reasons.
*
* @type Number
* @default 80
View
7 src/interfaces/default/script.js
@@ -17,7 +17,7 @@
* along with PaintWeb. If not, see <http://www.gnu.org/licenses/>.
*
* $URL: http://code.google.com/p/paintweb $
- * $Date: 2009-08-13 20:20:10 +0300 $
+ * $Date: 2009-08-24 20:28:00 +0300 $
*/
/**
@@ -946,15 +946,16 @@ pwlib.gui = function (app) {
// Make PaintWeb visible.
var placeholder = config.guiPlaceholder,
- placeholderStyle = placeholder.style,
- cs = win.getComputedStyle(placeholder, null);
+ placeholderStyle = placeholder.style;
// We do not reset the display property. We leave this for the stylesheet.
placeholderStyle.height = '';
placeholderStyle.overflow = '';
placeholderStyle.position = '';
placeholderStyle.visibility = '';
+ var cs = win.getComputedStyle(placeholder, null);
+
// Do not allow the static positioning for the PaintWeb placeholder.
// Usually, the GUI requires absolute/relative positioning.
if (cs.position === 'static') {
View
21 src/paintweb.js
@@ -17,7 +17,7 @@
* along with PaintWeb. If not, see <http://www.gnu.org/licenses/>.
*
* $URL: http://code.google.com/p/paintweb $
- * $Date: 2009-08-20 17:51:19 +0300 $
+ * $Date: 2009-08-24 19:22:53 +0300 $
*/
/**
@@ -1140,15 +1140,14 @@ function PaintWeb (win, doc) {
* dispatched.
*/
this.updateCanvasScaling = function () {
- var res = _self.resolution,
- cs = win.getComputedStyle(res.elem, null),
- image = _self.image;
- bufferStyle = _self.buffer.canvas.style,
- layerStyle = _self.layer.canvas.style,
- scaleNew = 1;
-
- var width = parseInt(cs.width),
- height = parseInt(cs.height);
+ var res = _self.resolution,
+ cs = win.getComputedStyle(res.elem, null),
+ image = _self.image;
+ bufferStyle = _self.buffer.canvas.style,
+ layerStyle = _self.layer.canvas.style,
+ scaleNew = 1,
+ width = parseInt(cs.width),
+ height = parseInt(cs.height);
if (pwlib.browser.opera) {
// Opera zoom level detection.
@@ -2533,7 +2532,7 @@ function PaintWeb (win, doc) {
: 'image/png', 'gif' : 'image/gif'};
// Detect the MIME type of the image currently loaded.
- if (!type) {
+ if (typeof type !== 'string' || !type) {
if (imageLoad && imageLoad.src && imageLoad.src.substr(0, 5) !== 'data:') {
src = imageLoad.src;
pos = src.indexOf('?');
View
51 src/tools/bcurve.js
@@ -17,7 +17,7 @@
* along with PaintWeb. If not, see <http://www.gnu.org/licenses/>.
*
* $URL: http://code.google.com/p/paintweb $
- * $Date: 2009-07-01 18:43:53 +0300 $
+ * $Date: 2009-08-24 13:18:05 +0300 $
*/
/**
@@ -86,7 +86,7 @@ pwlib.tools.bcurve = function (app) {
timer = null;
}
- if (points.length) {
+ if (points.length > 0) {
context.clearRect(0, 0, image.width, image.height);
}
@@ -102,7 +102,7 @@ pwlib.tools.bcurve = function (app) {
* @param {Event} ev The DOM Event object.
*/
this.mousedown = function (ev) {
- if (points.length == 0) {
+ if (points.length === 0) {
gui.statusShow('bcurveSnapping');
points.push([mouse.x, mouse.y]);
}
@@ -141,19 +141,17 @@ pwlib.tools.bcurve = function (app) {
// Add the temporary point while the mouse button is down.
if (mouse.buttonDown) {
- if (shiftKey && n == 1) {
+ if (shiftKey && n === 1) {
snapXY(points[0][0], points[0][1]);
}
points.push([mouse.x, mouse.y]);
n++;
}
- var p0 = points[0],
- p1 = points[1],
- p2 = points[2],
- p3 = points[3] || points[2],
- lineWidth = context.lineWidth,
- strokeStyle = context.strokeStyle;
+ var p0 = points[0],
+ p1 = points[1],
+ p2 = points[2],
+ p3 = points[3] || points[2];
if (mouse.buttonDown) {
points.pop();
@@ -167,17 +165,26 @@ pwlib.tools.bcurve = function (app) {
}
// Draw the main line
- if (n == 2) {
+ if (n === 2) {
context.beginPath();
context.moveTo(p0[0], p0[1]+2);
context.lineTo(p1[0], p1[1]+2);
- context.lineWidth = 1;
- context.strokeStyle = '#000000';
+
+ if (config.shapeType === 'fill') {
+ var lineWidth = context.lineWidth,
+ strokeStyle = context.strokeStyle;
+
+ context.lineWidth = 1;
+ context.strokeStyle = context.fillStyle;
+ }
+
context.stroke();
context.closePath();
- context.lineWidth = lineWidth;
- context.strokeStyle = strokeStyle;
+ if (config.shapeType === 'fill') {
+ context.lineWidth = lineWidth;
+ context.strokeStyle = strokeStyle;
+ }
needsRedraw = false;
return;
@@ -192,11 +199,11 @@ pwlib.tools.bcurve = function (app) {
p3[0], p3[1],
p1[0], p1[1]);
- if (config.shapeType != 'stroke') {
+ if (config.shapeType !== 'stroke') {
context.fill();
}
- if (config.shapeType != 'fill') {
+ if (config.shapeType !== 'fill') {
context.stroke();
}
@@ -216,7 +223,7 @@ pwlib.tools.bcurve = function (app) {
// Allow click+mousemove+click, not only mousedown+mousemove+mouseup.
// Do this only for the start point.
- if (n == 1 && mouse.x == points[0][0] && mouse.y == points[0][1]) {
+ if (n === 1 && mouse.x === points[0][0] && mouse.y === points[0][1]) {
mouse.buttonDown = true;
return true;
}
@@ -226,7 +233,7 @@ pwlib.tools.bcurve = function (app) {
timer = null;
}
- if (n == 1 && ev.shiftKey) {
+ if (n === 1 && ev.shiftKey) {
snapXY(points[0][0], points[0][1]);
}
@@ -242,9 +249,9 @@ pwlib.tools.bcurve = function (app) {
shiftKey = ev.shiftKey;
_self.draw();
- if (n == 2 || n == 3) {
+ if (n === 2 || n === 3) {
gui.statusShow('bcurveControlPoint' + (n-1));
- } else if (n == 4) {
+ } else if (n === 4) {
gui.statusShow('bcurveActive');
app.layerUpdate();
points = [];
@@ -263,7 +270,7 @@ pwlib.tools.bcurve = function (app) {
* if not.
*/
this.keydown = function (ev) {
- if (!points.length || ev.kid_ != 'Escape') {
+ if (!points.length || ev.kid_ !== 'Escape') {
return false;
}

0 comments on commit a5cc173

Please sign in to comment.