I’m trying to find a nice way to do circular arc morphs; so far CurveMorph isn’t playing very nice for this and google is not finding anything that looks interesting.
Has anyone seen suitable code, or is anyone in possession of the Seekrit Knowledge of how to make CurveMorph do clean circular arcs?
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim For every action, there is an equal and opposite criticism.
Something like this, maybe?
'From Squeak5.1 of 23 August 2016 [latest update: #16548] on 3 April 2017 at 3:24:01 pm'! Morph subclass: #BobsArcMorph instanceVariableNames: 'lineWidth startAngle stopAngle' classVariableNames: '' poolDictionaries: '' category: 'MorphicExtras-AdditionalMorphs'!
!BobsArcMorph methodsFor: 'as yet unclassified' stamp: 'raa 4/3/2017 15:22'! drawOn: aCanvas " BobsArcMorph new openInWorld " | center radius angle pt lw2 stop step |
aCanvas fillRectangle: self bounds color: Color gray. lw2 _ lineWidth // 2. center _ self bounds center - (lw2@lw2). radius _ (self width min: self height) // 2 - lw2. angle _ startAngle min: stopAngle. stop _ (startAngle max: stopAngle) min: angle + Float twoPi. step _ 0.9 / radius. [ pt _ center + (Point r: radius degrees: angle radiansToDegrees) rounded. aCanvas fillRectangle: (pt extent: lineWidth@lineWidth) color: color. angle _ angle + step. angle > stop ] whileFalse! !
!BobsArcMorph methodsFor: 'as yet unclassified' stamp: 'raa 4/3/2017 15:23'! initialize
super initialize. lineWidth _ 2. startAngle _ 0. stopAngle _ Float pi * 1.3. self color: Color yellow. self extent: 200@200.! !
On 4/3/17 2:23 PM, tim Rowledge wrote:
I’m trying to find a nice way to do circular arc morphs; so far CurveMorph isn’t playing very nice for this and google is not finding anything that looks interesting.
Has anyone seen suitable code, or is anyone in possession of the Seekrit Knowledge of how to make CurveMorph do clean circular arcs?
tim
tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim For every action, there is an equal and opposite criticism.
On 03-04-2017, at 12:25 PM, Bob Arning arning315@comcast.net wrote:
Something like this, maybe?
Yeah, that’s an interesting start. I also found -http://wiki.squeak.org/squeak/uploads/2624/PieChartMorph-gm.cs which is ancient and I’m afraid I have no idea who ‘gm’ might be. That uses the low level polygon drawing on Canvas methods.
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Any nitwit can understand computers. Many do.
http://wiki.squeak.org/squeak/2291
On 4/3/17 3:37 PM, tim Rowledge wrote:
I have no idea who ‘gm’ might be.
From http://map.squeak.org/accountsbyname gm is for German Morales
Ken G. Brown
On Apr 3, 2017, at 13:37, tim Rowledge tim@rowledge.org wrote:
On 03-04-2017, at 12:25 PM, Bob Arning arning315@comcast.net wrote:
Something like this, maybe?
Yeah, that’s an interesting start. I also found -http://wiki.squeak.org/squeak/uploads/2624/PieChartMorph-gm.cs which is ancient and I’m afraid I have no idea who ‘gm’ might be. That uses the low level polygon drawing on Canvas methods.
tim
tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Any nitwit can understand computers. Many do.
Etoys image has a SectorMorph Not sure if it is in trunk http://lists.squeakland.org/pipermail/etoys-dev/2012-February/006787.html Best, Karl
On Mon, Apr 3, 2017 at 10:22 PM, Ken Brown kbrown@mac.com wrote:
From http://map.squeak.org/accountsbyname gm is for German Morales
Ken G. Brown
On Apr 3, 2017, at 13:37, tim Rowledge tim@rowledge.org wrote:
On 03-04-2017, at 12:25 PM, Bob Arning arning315@comcast.net wrote:
Something like this, maybe?
Yeah, that’s an interesting start. I also found -http://wiki.squeak.org/ squeak/uploads/2624/PieChartMorph-gm.cs which is ancient and I’m afraid I have no idea who ‘gm’ might be. That uses the low level polygon drawing on Canvas methods.
tim
tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Any nitwit can understand computers. Many do.
On 03-04-2017, at 1:32 PM, karl ramberg karlramberg@gmail.com wrote:
Etoys image has a SectorMorph Not sure if it is in trunk
It seems to be there and functioning in the latest Squeak6.0alpha-17086-32bit. It is not especially helpful when needing an arbitrary arc, though, since various methods seem to rely upon the first vertex in the list being the centre of the radius. And it draws a really ugly curved edge too.
There’s also the old Arc class that I hadn’t spotted (because I looked for “arcm” thinking to find ArcMorph) but that doesn’t help a great deal without translating to morphland. And anyway we really ought to be able to do good curves by now. Yes, we have the B2Dplugin and BalloonCanvas but it’s not all that convincing; try `WatchMorph new openInWorld` and then use its red menu to turn on anti-aliasing. A bit naff.
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Useful Latin Phrases:- Cave ne ante ullas catapultas ambules = If I were you, I wouldn't walk in front of any catapults.
squeak-dev@lists.squeakfoundation.org