[squeak-dev] raised bordered ellipse

karl ramberg karlramberg at gmail.com
Tue Mar 7 18:53:49 UTC 2023


On Mon, Mar 6, 2023 at 7:23 PM Eduardo Ochs <eduardoochs at gmail.com> wrote:

> Hi Lauren,
>
> can you send detailed instructions for how to run your code?
> I will need to learn how to use canvases soon(*) and your
> code looks like a good starting point...
>

See attachment.
I added antialiasing to the drawing.
Not sure it improved things...

Best,
Karl




>
>   Thanks in advance! =)
>     Eduardo Ochs
>     http://anggtwu.net/eev-squeak.html
>
>
> (*): actually I tried to write a drawing program a few weeks
> ago, but that turned out to be far above my level, and I am
> still working on debugging tools and on ways to organize my
> note... =(
>
>
> On Sun, 5 Mar 2023 at 03:07, Lauren Pullen <drurowin at gmail.com> wrote:
>
>> Hi List,
>>
>> After much pulling of my hair out on how to make GradientFillStyle work,
>> I managed to get an EllipseMorph with a raised border.
>>
>> I've brute forced it by calling fillOval: twice; first call for the
>> border, then again for the innards.  FormCanvas and BalloonCanvas do not
>> draw the same ellipse, scaled; the difference at a small radius is quite
>> noticeable.
>>
>> Here is the code I've got.  It only works with opaque filling, but
>> that's all I need it to work with.  (I mean, it doesn't crash... but
>> it's certainly wrong.)  I think I got the border width math correct?
>> How would List tackle this?
>>
>> drawOn: aCanvas
>>    "manual drawing of RaisedBorder oval"
>>
>>    aCanvas isShadowDrawing
>>       ifTrue: [^ super drawOn: aCanvas].
>>    aCanvas
>>    "draw the border"
>>       fillOval: self bounds
>>       fillStyle: ((GradientFillStyle ramp: {
>>             0.2 -> (self color mixed: 0.65 with: Color white).
>>             0.5 -> (self color).
>>             0.8 -> (self color mixed: 0.7 with: Color black)})
>>          origin: self bounds origin;
>>          direction: self extent;
>>          radial: true);
>>    "fill the inside"
>>       balloonFillOval: ((self bounds origin + (self borderWidth))
>> corner: self bounds corner - (self borderWidth))
>>       fillStyle: self color
>>       borderWidth: 0
>>       borderColor: Color transparent
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230307/23a18871/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BorderedEllipseMorph.st
Type: application/octet-stream
Size: 1270 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230307/23a18871/attachment.obj>


More information about the Squeak-dev mailing list