Hi Igor, I think have I found a bug when circle are drawn. I have added "(start = end) ifTrue: [ ^ self ]." in this method: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= AthensCairoPathBuilder>>arcTo: newEndPoint angle: angle cw: aBool " Add a clockwise arc segment, starting from current path endpoint and ending at andPt. Angle should be specified in radians " | start end center v radius startAngle endAngle cwAngle | angle isZero ifTrue: [ ^ self lineTo: newEndPoint ]. start := endPoint. endPoint := end := self toAbsolute: newEndPoint. "we have to transform the input. because Cario expects the center , radius, starting and ending angle, and we have the starting point, the ending point , and the angle. " aBool ifTrue: [cwAngle := angle] ifFalse: [cwAngle := angle negated]. "Do nothing if the two points are the same" (start = end) ifTrue: [ ^ self ]. center := self calcCenter: start end: end angle: cwAngle. v := (start - center). radius := v r. startAngle := self angleOfVector: v. endAngle := self angleOfVector: (end-center). aBool ifTrue: [ self arcCenterX: center x centerY: center y radius: radius startAngle: startAngle endAngle: endAngle ] ifFalse: [ self arcNegativeCenterX: center x centerY: center y radius: radius startAngle: startAngle endAngle: endAngle ] -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= I have attached a new version of the package. It simply defines this new method. It would be great to have a solution in case the start and end points are the same. Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
On 7 August 2013 10:03, Alexandre Bergel <alexandre.bergel@me.com> wrote:
Hi Igor,
I think have I found a bug when circle are drawn.
I have added "(start = end) ifTrue: [ ^ self ]." in this method:
your change just makes it fool-proof. The bug is in user code which specifies wrong data (drawing arc with two coinciding points?) Anyways, i added it.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= AthensCairoPathBuilder>>arcTo: newEndPoint angle: angle cw: aBool
" Add a clockwise arc segment, starting from current path endpoint and ending at andPt. Angle should be specified in radians "
| start end center v radius startAngle endAngle cwAngle |
angle isZero ifTrue: [ ^ self lineTo: newEndPoint ].
start := endPoint. endPoint := end := self toAbsolute: newEndPoint.
"we have to transform the input. because Cario expects the center , radius, starting and ending angle, and we have the starting point, the ending point , and the angle. " aBool ifTrue: [cwAngle := angle] ifFalse: [cwAngle := angle negated].
"Do nothing if the two points are the same" (start = end) ifTrue: [ ^ self ]. center := self calcCenter: start end: end angle: cwAngle. v := (start - center). radius := v r. startAngle := self angleOfVector: v. endAngle := self angleOfVector: (end-center). aBool ifTrue: [ self arcCenterX: center x centerY: center y radius: radius startAngle: startAngle endAngle: endAngle ] ifFalse: [ self arcNegativeCenterX: center x centerY: center y radius: radius startAngle: startAngle endAngle: endAngle ] -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
I have attached a new version of the package. It simply defines this new method. It would be great to have a solution in case the start and end points are the same.
Cheers, Alexandre
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
-- Best regards, Igor Stasenko.
Just to make it clear: when you get zero-divide error, where you think the bug is , in #/ method, or maybe in code which passed zero as divisor? by analogy, when you want to draw an arc with zero length, which makes it non-arc, where you think the bug is, in code which implements drawing an arc or in code which provides wrong input? because this change actually hiding the mistakes, so instead of getting error and fixing it, user now will have hard times figuring out, why it not draws things as intended and where his mistake is. -- Best regards, Igor Stasenko.
Yes, you're right. The Morphic version of drawing arc does not complain, however it did with Athens. Thanks for fixing this Alexandre On Aug 7, 2013, at 9:00 AM, Igor Stasenko <siguctua@gmail.com> wrote:
Just to make it clear:
when you get zero-divide error, where you think the bug is , in #/ method, or maybe in code which passed zero as divisor?
by analogy, when you want to draw an arc with zero length, which makes it non-arc, where you think the bug is, in code which implements drawing an arc or in code which provides wrong input?
because this change actually hiding the mistakes, so instead of getting error and fixing it, user now will have hard times figuring out, why it not draws things as intended and where his mistake is.
-- Best regards, Igor Stasenko.
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
participants (2)
-
Alexandre Bergel -
Igor Stasenko