[squeak-dev] raised bordered ellipse

Lauren Pullen drurowin at gmail.com
Sun Mar 5 06:07:09 UTC 2023


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 --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2023-03-04 at 22.55.21.png
Type: image/png
Size: 146541 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230305/1a4fcd6b/attachment-0001.png>


More information about the Squeak-dev mailing list