Risks: tiny - isolated to LzDrawView.arc()
Rewards: big - fixes arc() behavior, something that a lot of people
need!
--
Regards,
Max Carlson
OpenLaszlo.org
From: [EMAIL PROTECTED]
Date: 5 April 2007 18:44:14 EDT
To: [email protected]
Subject: [Laszlo-checkins] r4589 - in openlaszlo/trunk: WEB-INF/lps/
lfc/views test/drawing
Reply-To: [email protected]
Author: max
Date: 2007-04-05 15:44:12 -0700 (Thu, 05 Apr 2007)
New Revision: 4589
Added:
openlaszlo/trunk/test/drawing/arctest.lzx
Modified:
openlaszlo/trunk/WEB-INF/lps/lfc/views/LzDrawView.as
Log:
Change 20070402-maxcarlson-O by [EMAIL PROTECTED] on
2007-04-02 21:02:15 PDT
in /Users/maxcarlson/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Fix drawview.arc() method in trunk
New Features:
Bugs Fixed: LPP-2343 - arc(..) positions arc incorrectly if
starting angle is not equal to 0
Technical Reviewer: promanik
QA Reviewer: antun
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details: Merged changes from legals and http://www.openlaszlo.org/
jira/browse/LPP-3491 to trunk. Added testcase. Verified testcase.
Tests:
Files:
A test/drawing/arctest.lzx
M WEB-INF/lps/lfc/views/LzDrawView.as
! docs/src/wrappers/chart-basezoomarea.xml
! docs/src/wrappers/resources/contactsdata.xml
! docs/src/wrappers/data/columnchart-data-example1.xml
! docs/src/wrappers/data/ebay.xml
! docs/src/wrappers/data/columnchart-data-example2.xml
! docs/src/wrappers/data/ebay1.xml
! docs/src/wrappers/data/ebay1000.xml
! docs/src/wrappers/data/simple-redsox-data.xml
! docs/src/wrappers/data/pie-data.xml
! docs/src/wrappers/data/pie-data2.xml
! docs/src/wrappers/data/simple.xml
! docs/src/wrappers/data/redsox-data.xml
! docs/src/wrappers/data/redsox-data1.xml
! docs/src/wrappers/data/redsox-data2.xml
! docs/guide/cookie.jsp
! docs/guide/hello.lzx.test
Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20070402-
maxcarlson-O.tar
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/LzDrawView.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/views/LzDrawView.as 2007-04-05
19:54:25 UTC (rev 4588)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/views/LzDrawView.as 2007-04-05
22:44:12 UTC (rev 4589)
@@ -3,7 +3,7 @@
**********************************************************************
*******/
//* A_LZ_COPYRIGHT_BEGIN
******************************************************
-//* Copyright 2001-2006 Laszlo Systems, Inc. All Rights
Reserved. *
+//* Copyright 2001-2007 Laszlo Systems, Inc. All Rights
Reserved. *
//* Use is subject to license
terms. *
//* A_LZ_COPYRIGHT_END
********************************************************
@@ -280,12 +280,14 @@
// @param Number clockwise: anticlockwise if true, clockwise
otherwise
//-------------------------------------------------------------------
----------
LzDrawView.prototype.arc = function(x, y, radius, startAngle,
endAngle, clockwise) {
- x += radius*Math.cos(startAngle);
- y += radius*Math.sin(startAngle);
- startAngle *= 180/Math.PI;
- endAngle *= 180/Math.PI;
- var arc = clockwise == true ? startAngle - endAngle : endAngle
- startAngle;
- this.moveTo(x, y);
+ var sx = x + radius*Math.cos(startAngle);
+ var sy = y + radius*Math.sin(2 * Math.PI - startAngle);
+ startAngle *= 180/Math.PI;
+ endAngle *= 180/Math.PI;
+ var arc = clockwise == true ? ((endAngle - startAngle) - 360):
endAngle - startAngle;
+ //move pen to the point along the circle at startAngle
+ this.moveTo(sx, sy);
+ //retain the center of the arc as the center point passed in.
return this._drawArc(x, y, radius, arc, startAngle);
}
@@ -452,7 +454,7 @@
yRadius = radius;
}
// Init vars
- var segAngle, theta, angle, angleMid, segs, ax, ay, bx, by,
cx, cy;
+ var segAngle, theta, angle, angleMid, segs,bx, by, cx, cy;
// no sense in drawing more than is needed :)
if (Math.abs(arc)>360) {
arc = 360;
@@ -464,13 +466,11 @@
// Now calculate the sweep of each segment
segAngle = arc/segs;
// The math requires radians rather than degrees. To convert
from degrees
- // use the formula (degrees/180)*Math.PI to get radians.
+ // use the formula (degrees/180)*Math.PI to get radians.
theta = -(segAngle/180)*Math.PI;
// convert angle startAngle to radians
angle = -(startAngle/180)*Math.PI;
- // find our starting points (ax,ay) relative to the secified x,y
- ax = x-Math.cos(angle)*radius;
- ay = y-Math.sin(angle)*yRadius;
+
// if our arc is larger than 45 degrees, draw as 45 degree
segments
// so that we match Flash's native circle routines.
if (segs>0) {
@@ -481,19 +481,19 @@
// find the angle halfway between the last angle and
the new
angleMid = angle-(theta/2);
// calculate our end point
- bx = ax+Math.cos(angle)*radius;
- by = ay+Math.sin(angle)*yRadius;
+ bx = x+Math.cos(angle)*radius;
+ by = y+Math.sin(angle)*yRadius;
// calculate our control point
- cx = ax+Math.cos(angleMid)*(radius/Math.cos(theta/2));
- cy = ay+Math.sin(angleMid)*(yRadius/Math.cos(theta/2));
+ cx = x+Math.cos(angleMid)*(radius/Math.cos(theta/2));
+ cy = y+Math.sin(angleMid)*(yRadius/Math.cos(theta/2));
// draw the arc segment
this.quadraticCurveTo(cx, cy, bx, by);
}
}
// In the native draw methods the user must specify the end point
// which means that they always know where they are ending at,
but
- // here the endpoint is unknown unless the user calculates it
on their
- // own. Lets be nice and let save them the hassle by passing
it back.
+ // here the endpoint is unknown unless the user calculates it
on their
+ // own. Lets be nice and let save them the hassle by passing
it back.
return {x:bx, y:by};
}
Added: openlaszlo/trunk/test/drawing/arctest.lzx
Property changes on: openlaszlo/trunk/test/drawing/arctest.lzx
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins