[Cuis-dev] VectorGraphics and Morph

Mariano Montone marianomontone at gmail.com
Fri Jun 19 06:55:33 PDT 2020


El 19/6/20 a las 07:41, Hilaire Fernandes via Cuis-dev escribió:

> It is the vector rendering, specific to the Morph.
> 
> *isOrthoRectangularMorph*     ^ false
> 
> Inform it is not rectangular, Juan already prepare this.
> 
> *morphContainsPoint: aLocalPoint*     | polarPoint min max |     (self
> morphLocalBounds containsPoint: aLocalPoint) ifFalse: [^ false].    
> polarPoint _ (aLocalPoint + bounds topLeft - radius asPoint) * (1 @ -1).
>     min _  Float halfPi - (aperture / 2) - shift.     max _ Float halfPi
> + (aperture / 2) - shift.     ^ (polarPoint r         between:
> innerRadius         and: radius)             and: ["Deal when crossing
> zero"                 (polarPoint theta                     between: min
>                     and:  max)                 or: [polarPoint theta    
>                     between: min + Float twoPi                        
> and:  max + Float twoPi                     ]                 ]
> 
> Then you can have Morph detection/selecting really matching the vector
> shape.

I've been developing a Diagrams tool in Cuis using Cairo, and needed
this for shapes and connectors there.

And used the hit canvas technique:
https://www.w3.org/wiki/Canvas_hit_testing

The interesting thing about it is that you get precise
morphContainsPoint implementation, without having to do any calculations
at all! You just let the morph draw (both on vector canvas and hit
canvas, then use hit canvas for point containment detection).

Implementation is here at the moment:
https://bitbucket.org/mmontone/mold/src/master/Dia.pck.st

Cheers!

Mariano


More information about the Cuis-dev mailing list