[squeak-dev] Arc morph?
Bob Arning
arning315 at comcast.net
Mon Apr 3 19:25:44 UTC 2017
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 at 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 at 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 at 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 at rowledge.org; http://www.rowledge.org/tim
> For every action, there is an equal and opposite criticism.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170403/50d8a58e/attachment.html>
More information about the Squeak-dev
mailing list
|