<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<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>
<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>
<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>
<p>If you are interested in graphics/morph sutff, I encourage you to
take a look and have fun with your creativity.</p>
<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 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>