[Cuis-dev] Best way to draw arcs
Juan Vuletich
juan at cuis.st
Sun Mar 5 10:15:21 PST 2023
Hi Jon,
Long time, no see!
(Jon was a very active member of the Squeak community many years ago).
Welcome to Cuis!
On 3/3/2023 9:36 PM, Jon Hylands via Cuis-dev wrote:
>
> Hi everyone,
>
> New to the list, new to Cuis (just downloaded it today).
>
> I'm designing some gauges for an ultralight plane that will run on a
> Raspberry Pi 4 with a 10" LCD panel. Right now, this is what I have:
>
> Cuis-Gauges.png
>
> I love the anti-aliasing, vector-based properly scalable graphics!
>
This looks really nice!
> The part that I'm not happy with is the green, yellow and red
> indicator bands on the airspeed gauge. They look nice, but I'm drawing
> them by drawing a sequence of filled polygons.
>
> The code looks like this:
>
> drawShadeFrom: startSpeed to: endSpeed color: color on: aCanvas
> | ratio |
> ratio := self angleToValueRatio.
> aCanvas strokeWidth: 1 color: color fillColor: color do: [
> startSpeed to: endSpeed - 2 do:[:each |
> | startAngle endAngle |
> startAngle := (90 - (each * ratio)) degreesToRadians.
> endAngle := (90 - ((each + 2) * ratio) degreesToRadians.
> aCanvas
> moveTo: (Point rho: 85 theta: startAngle);
> lineTo: (Point rho: 95 theta: startAngle);
> lineTo: (Point rho: 95 theta: endAngle);
> lineTo: (Point rho: 85 theta: endAngle);
> lineTo: (Point rho: 85 theta: startAngle)]].
>
> I tried using the #arcTo: method, but I just couldn't get it to work
> at all (not to mention the line ends of the arc are round, which
> doesn't work here anyways).
>
> Is there a more reasonable way to do this?
>
> Thanks,
> Jon
>
The #arcTo: method was done following the way to specify arcs in SVG.
Yes, it is a bad api. Pretty hard to use. I guess I'm late to answer
about this, as others (thanks folks!) have already answered.
WRT the ends being round, yes, Cuis Vector Graphics only support a round
pen nib. The solution is to draw the border of the arc with small, or
zero pen width, and use fill.
Cheers,
--
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230305/ca156215/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 111623 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230305/ca156215/attachment-0001.png>
More information about the Cuis-dev
mailing list