<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><font size="+1">Hi, <br>
</font></p>
<p><font size="+1">I have been porting part of the Squeak
PolygonMorph (in fact I am just porting the polygon part not the
curved part). WIP file out attached, the Vector Engine Paste Up
morph hack posted by Juan a few days ago is needed.<br>
</font></p>
<p><font size="+1">I need to adress the #morphContainsPoint:</font></p>
<p><font size="+1">The current code is as bellow, the filled polygon
detection part seems to use the mask technique you described.<br>
</font></p>
<pre><font size="+1"><font color="#863266">containsPoint: aPoint
(super containsPoint: aPoint) ifFalse: [^ false].
(closed and: [color isTransparent not]) ifTrue:
[ ^ (self filledForm pixelValueAt: aPoint - bounds topLeft + 1) > 0].
self lineSegmentsDo:
[ :p1 :p2 |
(aPoint onLineFrom: p1 to: p2 within: (3 max: borderWidth+1//2) asFloat)
ifTrue: [^ true]].
self arrowForms do:
[ :f | (f pixelValueAt: aPoint - f offset) > 0 ifTrue: [^ true]].
^ false</font>
</font></pre>
<p>Juan, can you document a bit more how to use your technique
described bellow to make morph detection on the filled part of the
polygon shape?</p>
<p>Thanks</p>
<p>Hilaire<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">Le 19/06/2020 à 17:30, Juan Vuletich
via Cuis-dev a écrit :<br>
</div>
<blockquote type="cite" cite="mid:5EECDA11.5050308@jvuletich.org">VectorEngine
already does this. It includes an extra buffer, ivar 'morphIds' in
VectorEngine classes. Recently I also added ivar 'id' to Morph.
For every pixel the engine draws in the context of a Morph, its id
is stored at pixel position in morphIds. Then, it is just a matter
of querying morphIds.
<br>
<br>
For Cairo, the technique you wrote can be used. For regular,
orthorectangular morhps in BitBlt canvas, the simple existing code
can still be used. For morphs that use VectorGraphics to build
cached Forms, as developed by Hilaire, it is just a matter of
querying the form for transparency.
<br>
<br>
All this means that soon no morph will need to include geometry
specific code for hit detection (#morphContainsPoint:) at all.
<br>
<br>
All we need to do is to make all this work consistently in a
framework.
<br>
</blockquote>
<pre class="moz-signature" cols="72">--
GNU Dr. Geo
<a class="moz-txt-link-freetext" href="http://drgeo.eu">http://drgeo.eu</a>
<a class="moz-txt-link-freetext" href="https://pouet.chapril.org/@hilaire">https://pouet.chapril.org/@hilaire</a></pre>
</body>
</html>