[Cuis-dev] Pretty Cool Juan!

Juan Vuletich juan at jvuletich.org
Wed Jan 13 11:28:32 PST 2021


On 1/13/2021 3:59 PM, Hilaire Fernandes via Cuis-dev wrote:
>
> Work pretty well adding submorphs. Only requires little vector 
> calculus to coop with the rotation center:
>
> ProtractorMorph>>initialize
> | label p1 font |
>      super initialize .
>      font _ FontFamily familyName: FontFamily defaultFamilyName pointSize: 4.
>      10 to: 170 by: 10 do: [:angle |
>          p1 _ Point r: 88 degrees: angle negated.
>          p1 _ p1 - (p1 normal * (font widthOfString: angle asString) / 2).
>          label _ LabelMorph contents: angle asString font: font.
>          label rotation: (90 - angle) degreesToRadians.
>          self addMorph: label.
>          label morphPosition: p1]
>
> All the the necessary knowledge do construct such morph is in The Cuis 
> Book.
>
> What is interesting is how the width of the lines can be float number, 
> here 1.0 ; 0.5 ; 0.6
>
>
> Le 13/01/2021 à 16:17, Juan Vuletich via Cuis-dev a écrit :
>> One way to do it is to add a submorph for each label, rotating it as 
>> needed.
> -- 
> GNU Dr. Geo
> http://drgeo.eu
> http://blog.drgeo.eu

Very nice!

It looks like that math could be extracted into a helper method, right? 
Something like #addLabel:centeredAt:rotationDegrees:

Thanks,

-- 
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20210113/dad75d8d/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 118093 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20210113/dad75d8d/attachment-0001.png>


More information about the Cuis-dev mailing list