[Newbies] Drawing an Arc.
Hilaire Fernandes
hilaire at ext.cri74.org
Sun Jul 9 10:27:51 UTC 2006
Hello Claudio,
You may want to give a try to my simple DrGArcMorph in the enclosed
change set.
To use it:
a :=DrGArcMorph new
a center: 50 at 50 radius: 100 origin: 0 length: 3.1415
a openInWorld
origin and length are in radian unit
Hilaire
Claudio Acciaresi a écrit :
> Hello, I`m trying to draw an arc using Morphs, exists an easy way to do
> it?
> The acrs that i´m trying to create are like smiles of a face.
> I see FaceMorph, Gesture morph, but i do not want to use a PolygonMorph.
>
> Thanks a lot!!!!
> Claudio.
-------------- next part --------------
'From Squeak3.8 of ''5 May 2005'' [latest update: #6665] on 9 July 2006 at 12:23:31 pm'!
DrGPolylineMorph subclass: #DrGArcMorph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'DrGeoII-GeometryView'!
!DrGArcMorph methodsFor: 'accessing' stamp: 'HilaireFernandes 1/17/2006 12:29'!
center: aPoint radius: aFloat origin: anOrigin length: aLength
|step costep sinstep csteX csteY mobile|
step := 5 / aFloat * aLength sign.
(aLength / step) abs > 100 ifTrue: [step := aLength / 100].
costep := step cos.
sinstep := step sin.
csteX := aPoint x * (1 - costep) + (aPoint y * sinstep).
csteY := aPoint y * (1 - costep) - (aPoint x * sinstep).
mobile := aPoint + (aFloat * (anOrigin cos @ anOrigin sin)).
vertices := OrderedCollection new add: mobile; yourself.
0 to: (aLength / step) truncated -1 do: [:i|
mobile := (mobile x * costep - (mobile y * sinstep) + csteX)
@(mobile x * sinstep + (mobile y * costep) + csteY).
vertices add: mobile].
mobile := aPoint + (aFloat * ((anOrigin + aLength) cos @ (anOrigin + aLength) sin)).
vertices add: mobile.
self computeBounds! !
More information about the Beginners
mailing list