[Cuis-dev] Best way to draw arcs
Hilaire Fernandes
hfern at free.fr
Sat Mar 4 00:32:55 PST 2023
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.
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>
> Date :
> 04/03/2023 01:36
>
> Pour :
> cuis-dev at lists.cuis.st
> Copie à :
> Jon Hylands <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:
>
> 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 list Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
--
GNU Dr. Geo
http://drgeo.eu
http://blog.drgeo.eu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230304/5b6ea0e2/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/5b6ea0e2/attachment-0002.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/5b6ea0e2/attachment-0003.png>
-------------- next part --------------
'From Cuis 6.0 [latest update: #5667] on 4 March 2023 at 9:30:10 am'!
!classDefinition: #Arc category: 'Morphic-Arc'!
PlacedMorph subclass: #Arc
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Morphic-Arc'!
!Arc methodsFor: 'as yet unclassified' stamp: 'hlsf 3/4/2023 09:29:55'!
drawOn: canvas
canvas strokeWidth: 1 color: Color black fillColor: Color green do: [:engine |
engine moveTo: 100 at 0;
arcTo: 0 at 100 radius: 100 angleOfXAxis: 0 largeFlag: false sweepFlag: true;
lineTo: 0 at 90;
arcTo: 90 at 0 radius: 90 angleOfXAxis: 0 largeFlag: false sweepFlag: false
]! !
More information about the Cuis-dev
mailing list