<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Hilaire,<br>
<br>
On 6/19/2020 7:41 AM, Hilaire Fernandes via Cuis-dev wrote:
<blockquote cite="mid:5f78ec17-a6ca-d524-9301-6f289dfa65ab@drgeo.eu"
type="cite">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<p><font size="+1">Hello,</font></p>
<p><font size="+1">I will resume my understanding of the situation
and I will make an hopefully small request to Juan.</font></p>
<p><font size="+1">VectorGraphics canvas long time objective is to
move from bitmap canvas to vector canvas. Then, the whole Cuis
display content will be defined with vector operations. When
needed, to display the whole screen or to refresh a damaged
area, a rasterizing will occur. I think this part is pretty
tricky with vector canvas.<br>
</font></p>
<p><font size="+1">As long as the Cuis world relies on the bitmap
canvas, it is not directly possible to use vector operations
to draw a morph because the canvas argument in the drawOn: is
bitmap based and therefore does not understand the vector
operations<br>
</font></p>
</blockquote>
<br>
Yep. Right.<br>
<br>
<blockquote cite="mid:5f78ec17-a6ca-d524-9301-6f289dfa65ab@drgeo.eu"
type="cite">
<p><font size="+1"> </font></p>
<p><font size="+1">Nevertheless, as shown with the circular
toolbar, with a small hack, it is possible to draw a morph
with vector operations. You needs to instantiate an
intermediate vector canvas and a form where rasterization will
take place. If you remember, Juan did some recent changes to
make this work smoothly with transparent Form (a ticket was
open to make the change hopefully permanent in the BitBlt
plugin, for faster rendering). As a side benefit, the form
instances are kept as cache for quick Morph rendering. As long
as the Morph size does not change, no more vectors and
rasterization operations are needed.<br>
</font></p>
<p><font size="+1">So all in all, although the Cuis canvas is
still defined with Bitmap operations, it is now possible to
have nice looking vector Morphs.</font></p>
<p><font size="+1">The typical code of such a Morph will look like
this:</font></p>
<pre><font size="+1"><font color="#863266"><b>drawOn: aCanvas</b>
aCanvas
image: (self mouseIsOver ifTrue:[ self buttonOverForm] ifFalse: [self buttonNormalForm])
at: `0@0`.</font></font>
</pre>
<p><font size="+1"><font size="+1">You can have two form caches,
one for mouse over rendering.<br>
</font></font></p>
<pre><b><font size="+1" color="#863266">buttonOverForm</font></b></pre>
<pre><font size="+1" color="#863266"> ^ buttonOverForm ifNil: [</font></pre>
<pre><font size="+1" color="#863266"> buttonOverForm _ self drawMyShapeWith: (Color white alpha: color alpha).</font></pre>
<pre><font size="+1" color="#863266"> icon ifNotNil: [icon displayOn: buttonOverForm at: center - (icon extent // 2) rule: Form blend].</font></pre>
<pre><font size="+1" color="#863266"> buttonOverForm]</font></pre>
<p><font size="+1">You can compose the vector rendered part with
other bitmap operation, ie to add an icon here.</font></p>
<pre><font size="+1"><font color="#863266"><b>drawMyShapeWith: background</b>
| vectorCanvas aLocation aForm |
aForm _ Form extent: extent depth: Display depth.
aForm fillColor: Color transparent.
vectorCanvas _ VectorCanvas onForm: aForm.
aLocation _ AffineTransformation withTranslation: bounds topLeft negated.
vectorCanvas engine geometryTransformation: aLocation.
vectorCanvas strokeWidth: 2 color: color muchDarker fillColor: background do: [: engine |
engine abs_MoveToX: (corners floatAt: 1) y: (corners floatAt: 2);
abs_LineToX: (corners floatAt: 3) y: (corners floatAt: 4);
abs_ArcToX: (corners floatAt: 5) y: (corners floatAt: 6)
radiusX: radius radiusY: radius angleOfXAxis: aperture largeFlag: false sweepFlag: false;
abs_LineToX: (corners floatAt: 7) y: (corners floatAt: 8);
abs_ArcToX: (corners floatAt: 1) y: (corners floatAt: 2)
radiusX: innerRadius radiusY: innerRadius angleOfXAxis: aperture largeFlag: false sweepFlag: true].
^ aForm</font>
</font></pre>
<p><font size="+1">It is the vector rendering, specific to the
Morph.</font></p>
</blockquote>
<br>
This is a very cool idea, and you are the first to come up with it,
and make it work. Kudos for that!<br>
<br>
<blockquote cite="mid:5f78ec17-a6ca-d524-9301-6f289dfa65ab@drgeo.eu"
type="cite">
<pre><font size="+1" color="#863266"><b>isOrthoRectangularMorph</b>
^ false</font></pre>
<p><font size="+1">Inform it is not rectangular, Juan already
prepare this.<br>
</font></p>
<pre><font size="+1"><font color="#863266"><b>morphContainsPoint: aLocalPoint</b>
| 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
]
]</font>
</font></pre>
<p>Then you can have Morph detection/selecting really matching the
vector shape.<br>
</p>
</blockquote>
<br>
This is also true. But see my answer to Mariano's comment in this
thread, for the interesting and cool part :)<br>
<br>
<blockquote cite="mid:5f78ec17-a6ca-d524-9301-6f289dfa65ab@drgeo.eu"
type="cite">
<p> </p>
<p>If you are interested in graphics/morph sutff, I encourage you
to take a look and have fun with your creativity.</p>
</blockquote>
<br>
Indeed!<br>
<br>
<blockquote cite="mid:5f78ec17-a6ca-d524-9301-6f289dfa65ab@drgeo.eu"
type="cite">
<p>Juan, about my request. An intermediate step to the whole
Vector things for the Cuis display is a kind of PasteUpMorph
accepting sub morphs directly rendered with vectorCanvas
instance. I will be the first client with DrGeo to test and to
use it. It could be a next step to Dyanbook display too.</p>
<p>Hilaire<br>
</p>
<pre class="moz-signature" cols="72">--
GNU Dr. Geo
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://drgeo.eu">http://drgeo.eu</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://pouet.chapril.org/@hilaire">https://pouet.chapril.org/@hilaire</a></pre>
</blockquote>
<br>
You mean making your caching strategy part of the framework? Sounds
like a good idea, and not too hard to do (you already did the work).
Still, Morphs would need a message to invalidate the cached Form and
redraw it again with VectorCanvas, right? Right now, you are caching
2 Forms, but a genera framework solution should allow easily
invalidating the cached form without needing to know how many
variants could exist, and what triggers the change.<br>
<br>
This is getting really interesting. Let's move it forward!<br>
<br>
Cheers,<br>
<pre class="moz-signature" cols="72">--
Juan Vuletich
<a class="moz-txt-link-abbreviated" href="http://www.cuis-smalltalk.org">www.cuis-smalltalk.org</a>
<a class="moz-txt-link-freetext" href="https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev">https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev</a>
<a class="moz-txt-link-freetext" href="https://github.com/jvuletich">https://github.com/jvuletich</a>
<a class="moz-txt-link-freetext" href="https://www.linkedin.com/in/juan-vuletich-75611b3">https://www.linkedin.com/in/juan-vuletich-75611b3</a>
@JuanVuletich</pre>
</body>
</html>