[Cuis-dev] Best way to draw arcs
Jon Hylands
jhylands at gmail.com
Sat Mar 4 04:40:30 PST 2023
I should add, the coordinate system of the morph is set to origin at the
center of the gauge, and yAxisPointsUp is enabled.
Also, #angleToValueRatio returns 3.15, since the gauge sweeps 315 degrees
over 100 mph.
- Jon
On Sat, 4 Mar 2023 at 07:36, Jon Hylands <jhylands at gmail.com> wrote:
> Hilaire,
>
> Thanks for the input.
>
> I've attached that method, with the #arcTo: sends.
>
> This is what I get:
>
> [image: usingArcTo.png]
>
> If I replace the #arcTo: sends with the commented out #lineTo: sends (from
> the attached code), this is what I get:
>
> [image: usingLineTo.png]
>
> So I know that I am specifying all the end points correctly.
>
> Any ideas?
>
> - Jon
>
>
> On Sat, 4 Mar 2023 at 03:33, Hilaire Fernandes via Cuis-dev <
> cuis-dev at lists.cuis.st> wrote:
>
>> Hi Jon,
>>
>> Your gauges look very sweet!
>>
>> See attached file out of a Morph to give you an idea how to draw your
>> green arc.
>>
>> [image: arc]
>>
>>
>> Adjust accordingly to yours needs.
>> Hilaire
>>
>>
>> Le 04/03/2023 à 01:36, Jon Hylands via Cuis-dev a écrit :
>>
>> Sujet :
>> [Cuis-dev] Best way to draw arcs
>>
>> De :
>> Jon Hylands via Cuis-dev <cuis-dev at lists.cuis.st>
>> <cuis-dev at lists.cuis.st>
>>
>> Date :
>> 04/03/2023 01:36
>>
>> Pour :
>> cuis-dev at lists.cuis.st
>>
>> Copie à :
>> Jon Hylands <jhylands at gmail.com> <jhylands at gmail.com>
>>
>> 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
>>
>>
>> --
>> Cuis-dev mailing listCuis-dev at lists.cuis.sthttps://lists.cuis.st/mailman/listinfo/cuis-dev
>>
>> --
>> GNU Dr. Geohttp://drgeo.euhttp://blog.drgeo.eu
>>
>> --
>> Cuis-dev mailing list
>> Cuis-dev at lists.cuis.st
>> https://lists.cuis.st/mailman/listinfo/cuis-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230304/545d0a95/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Capture d??cran de 2023-03-04 09-30-19.png
Type: image/png
Size: 22145 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230304/545d0a95/attachment-0004.png>
-------------- 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/20230304/545d0a95/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: usingArcTo.png
Type: image/png
Size: 59720 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230304/545d0a95/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: usingLineTo.png
Type: image/png
Size: 56422 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230304/545d0a95/attachment-0007.png>
More information about the Cuis-dev
mailing list