[Cuis-dev] Best way to draw arcs

Jon Hylands jhylands at gmail.com
Fri Mar 3 16:36:09 PST 2023


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:

[image: Cuis-Gauges.png]

I love the anti-aliasing, vector-based properly scalable graphics!

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230303/fedd3246/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Cuis-Gauges.png
Type: image/png
Size: 111623 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230303/fedd3246/attachment-0001.png>


More information about the Cuis-dev mailing list