BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with Arc needed

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Roy
Guest





PostPosted: Tue Jan 27, 2004 1:23 pm    Post subject: Help with Arc needed Reply with quote



Hi, I thought I'd posted this before but can find no reference to it.

I've gone daft trying to get the TCanvas.Arc proc to draw an arc from 0-360
based on the value of a slider (min=0 max=360) and was really REALLY hoping
someone out there could help.

The effect I'm looking for is much like those funky car RPM indicators.

Any takers?

Thanks,

Roy.


Back to top
David C. Ullrich
Guest





PostPosted: Tue Jan 27, 2004 2:51 pm    Post subject: Re: Help with Arc needed Reply with quote



On Tue, 27 Jan 2004 13:23:15 -0000, "Roy" <roy (AT) mechnet (DOT) liv.ac.uk>
wrote:

Quote:
Hi, I thought I'd posted this before but can find no reference to it.

I've gone daft trying to get the TCanvas.Arc proc to draw an arc from 0-360
based on the value of a slider (min=0 max=360) and was really REALLY hoping
someone out there could help.

Well, you really don't say exactly where you want to draw the arc...

This may get you started:

procedure DrawArc(Target: TCanvas; centerX, centerY, radius: integer;
startangle, endangle: double);
//angles are in radians, just to leave you something to figure out...
var x1, y1, x2, y2, x3, y3, x4, y4: integer;
begin
x1:= centerX - radius;
y1:= centerY - radius;
x2:= centerX + radius;
y2:= centerY + radius;
x3:= centerX + round(radius*Cos(startangle));
y3:= centerY - round(radius*Sin(startangle));
x4:= centerX + round(radius*Cos(endangle));
y4:= centerY - round(radius*Sin(endangle));
Target.Arc(x1, y1, x2, y2, x3, y3, x4, y4);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
DrawArc(Canvas, 100, 100, 50, Pi/4, Pi);
end;

Quote:
The effect I'm looking for is much like those funky car RPM indicators.

Any takers?

Thanks,

Roy.



************************

David C. Ullrich

Back to top
Rob Kennedy
Guest





PostPosted: Tue Jan 27, 2004 4:36 pm    Post subject: Re: Help with Arc needed Reply with quote



Roy wrote:
Quote:
Hi, I thought I'd posted this before but can find no reference to it.

http://groups.google.com/groups?q=arc+author:roy&scoring=d

Trouble use TCanvas.Arc
http://groups.google.com/groups?th=d0b60e9fa2f442c6

--
Rob

Back to top
AlanGLLoyd
Guest





PostPosted: Tue Jan 27, 2004 4:58 pm    Post subject: Re: Help with Arc needed Reply with quote

I gave the following reply on 16 Jan 2004 to a posting entitled "Trouble use
TCanvas.Arc" ...

= = = = = = = = = = = = = = = = = = = = = = = = = = = =
"In article <bu97kd$5j3$1 (AT) news (DOT) liv.ac.uk>, "Roy" <roy (AT) mechnet (DOT) liv.ac.uk>
writes:

Quote:
I want to use the arc procedure to draw an arc from 0 to 360 degrees, say
using a simple slider.


procedure Arc(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer);

The first four parameters define the bounding rectangle for the ellipse or
circle. If we assume definition from top-left to bottom-right, then X1,Y1 is
the top-left point of the rectangle, X2,Y2 is the bottom-right point. For a
circle this would define the opposite diagonal corners of a square.

A circle will have X2 - X1 == Y2 - Y1, and the circle will be drawn _within_
that square rectangle, touching the sides at their midpoints.

Now comes the obscure bit.

X3,Y3 and X4,Y4 define points _outside_ the circle. You know where the centre
of the circle is in the middle of the square rectangle. Imagine a line drawn
from X3,Y3 point to the centre of the circle. Imagine another line drawn from
the X4,Y4 point also to the centre of the circle.

Note the place where the line from X3, Y3 to the circle's centre, crosses the
circle. Call this place A.

Note the place where the line from X4, Y4 to the circle's centre, crosses the
circle. Call this place B.

Starting at place A on the circle, move counter-clockwise (opposite rotation to
a clock) towards and up to place B. This is the arc which TCanvas.Arc will
draw.

So an arc from 12 o'clock to 9 o'clock on a 50 dia circle centred at 200, 100
would have an arc definition (I think <g>) of ...

Arc(175, 75, 225, 125, 150, 100, 200, 50);

The same (but with slightly more conceptual difficulty) applies to an ellipse.

If you want to have a rotating slider then you will have to calculate the
positions of X3, Y3 and X4, Y4 using the Sin and Cos of the equivalent (or
actual) angle of your slider and a radius greater than that of the circle.

When you have mastered this (preferably with a piece of graph paper and a
pencil), then move on to TCanvas.Chord and TCanvas.Pie <g>."

= = = = = = = = = = = = = = = = = = = = = = = =

is it "Good job I keep what I posted" or "No-one reads what I write" <g>

Welcome back David C. Ullrich <g>.

Alan Lloyd
[email]alanglloyd (AT) aol (DOT) com[/email]


Back to top
Roy
Guest





PostPosted: Wed Jan 28, 2004 10:21 am    Post subject: Re: Help with Arc needed Reply with quote

Thanks a million guys - not only does the code snippet (now much modified)
solve my problem, but with Alan's tutorial it all makes sense too!

In case you're interested, the code is part of the instrumentation for this:

http://www.jetstream-club.org

a rare project!

Thanks again.

Roy.


Back to top
David C. Ullrich
Guest





PostPosted: Wed Jan 28, 2004 11:48 am    Post subject: Re: Help with Arc needed Reply with quote

On 27 Jan 2004 16:58:51 GMT, [email]alanglloyd (AT) aol (DOT) com[/email] (AlanGLLoyd) wrote:

Quote:
[...]

Welcome back David C. Ullrich <g>.

Thanks. Won't be staying long, doing other things. Since
I got a little help the other day (and may be asking for a
little more soon) I thought I should contribute a little,
and this seemed like a reasonable place to do that,
given my degree in trigonometry and all...

Quote:
Alan Lloyd
[email]alanglloyd (AT) aol (DOT) com[/email]


************************

David C. Ullrich

Back to top
AlanGLLoyd
Guest





PostPosted: Wed Jan 28, 2004 2:55 pm    Post subject: Re: Help with Arc needed Reply with quote

In article <bv82f3$98a$1 (AT) news (DOT) liv.ac.uk>, "Roy" <roy (AT) mechnet (DOT) liv.ac.uk> writes:

Quote:
but with Alan's tutorial it all makes sense too!


Perhaps it might be useful on the FAQ (Maarten ?), although I have not seen
this question frequently asked. But I must admit to a little head-scratching
and pencil-on-paper when I first saw it <g>.

Possibly it should be an Annotation for each individual's help file. Perhaps we
ought to start an "Explanation" area on the FAQ site where individual chunks of
text are available for people to copy and add to their help files as
annotations if they wish.

Alan Lloyd
[email]alanglloyd (AT) aol (DOT) com[/email]

Back to top
Dodgy
Guest





PostPosted: Wed Jan 28, 2004 4:29 pm    Post subject: Re: Help with Arc needed Reply with quote

On Wed, 28 Jan 2004 10:21:21 -0000, "Roy" <roy (AT) mechnet (DOT) liv.ac.uk>
waffled on about something:

Quote:
Thanks a million guys - not only does the code snippet (now much modified)
solve my problem, but with Alan's tutorial it all makes sense too!

In case you're interested, the code is part of the instrumentation for this:

http://www.jetstream-club.org

a rare project!

Very interesting... Just don't forget to connect the throttles! I hope
there's going to be a "Powered by Delphi" paint job. Surprised)

Dodgy.
--
MUSHROOMS ARE THE OPIATE OF THE MOOSES

Back to top
Dr John Stockton
Guest





PostPosted: Wed Jan 28, 2004 8:04 pm    Post subject: Re: Help with Arc needed Reply with quote

JRS: In article <20040128095540.07155.00000325 (AT) mb-m06 (DOT) aol.com>, seen in
news:comp.lang.pascal.delphi.misc, AlanGLLoyd <alanglloyd (AT) aol (DOT) com>
posted at Wed, 28 Jan 2004 14:55:40 :-
Quote:

Perhaps it might be useful on the FAQ (Maarten ?), although I have not seen
this question frequently asked. But I must admit to a little head-scratching
and pencil-on-paper when I first saw it <g>.


Presumably Arc was chosen as being a powerful primitive in <= TP4 days.

I was about to suggest that a Delphi library should be available that
builds on Arc to give Ellipse & Circle, etc.; then I saw that TP4 has
those, so Delphi should; but what Delphi has differs. There is also Pie
& PieSlice.

ISTM that it would still be useful to have such a library, with easily-
understood names and handy parameters, implemented by the primitives.

The body of Circle(X, Y, R) might just be
Ellipse(X-R, Y-R, X+R, Y+R) - which is not necessarily obvious to all.

There could be Conic for more general shapes, and a Wodge more like
Pascal than Delphi.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Delphi 3 Turnpike 4 ©
<URL:http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htm> clpdmFAQ;
<URL:http://www.borland.com/newsgroups/guide.html> news:borland.* Guidelines

Back to top
Maarten Wiltink
Guest





PostPosted: Wed Jan 28, 2004 9:38 pm    Post subject: Re: Help with Arc needed Reply with quote

"AlanGLLoyd" <alanglloyd (AT) aol (DOT) com> wrote

Quote:
In article <bv82f3$98a$1 (AT) news (DOT) liv.ac.uk>, "Roy" <roy (AT) mechnet (DOT) liv.ac.uk
writes:


Quote:
but with Alan's tutorial it all makes sense too!

Perhaps it might be useful on the FAQ (Maarten ?), although I have
not seen this question frequently asked. But I must admit to a little
head-scratching and pencil-on-paper when I first saw it

Not a chance. It's not frequently asked and what's more, it's a FAQ
and *not* a tutorial collection. It's my stated policy to be strict
about that distinction.


Quote:
Possibly it should be an Annotation for each individual's help file.
Perhaps we ought to start an "Explanation" area on the FAQ site where
individual chunks of text are available for people to copy and add to
their help files as annotations if they wish.

A tutorial collection associated with the miniFAQ would be nice to
have, because there is demand for it - or rather, supply to which we
do want to point people.

But it would be rather a lot of work and I'm not about to volunteer
for doing an entire collection next to the miniFAQ. I have one or two
attempts on my own website and that was quite humbling enough, thank you.

Groetjes,
Maarten Wiltink / Evil miniFAQ Boss



Back to top
AlanGLLoyd
Guest





PostPosted: Thu Jan 29, 2004 6:15 am    Post subject: Re: Help with Arc needed Reply with quote

In article <40182bc3$0$327$e4fe514c (AT) news (DOT) xs4all.nl>, "Maarten Wiltink"
<maarten (AT) kittensandcats (DOT) net> writes:

Quote:
A tutorial collection associated with the miniFAQ would be nice to
have, because there is demand for it - or rather, supply to which we
do want to point people.

But it would be rather a lot of work and I'm not about to volunteer
for doing an entire collection next to the miniFAQ. I have one or two
attempts on my own website and that was quite humbling enough, thank you.


Do you mean a tutorial for any FAQ in the list, or a general one for a
repository when a possible candidate turned up.

I was not suggesting an "all-out effort to construct an edifice" but rather a
"pit where we throw bricks as they turn up".

Would providing such a "pit" be a big exercise.

Alan Lloyd
[email]alanglloyd (AT) aol (DOT) com[/email]

Back to top
Jeremy Collins
Guest





PostPosted: Thu Jan 29, 2004 8:10 am    Post subject: Re: Help with Arc needed Reply with quote

AlanGLLoyd wrote:

Quote:

Do you mean a tutorial for any FAQ in the list, or a general one for a
repository when a possible candidate turned up.

I was not suggesting an "all-out effort to construct an edifice" but rather a
"pit where we throw bricks as they turn up".

Would providing such a "pit" be a big exercise.

I think Borland's CodeCentral already does this, have you thought
about submitting your Arc example?


--
jc

Remove the -not from email

Back to top
Jeremy Collins
Guest





PostPosted: Thu Jan 29, 2004 8:12 am    Post subject: Re: Help with Arc needed Reply with quote

Dodgy wrote:

Quote:
Very interesting... Just don't forget to connect the throttles! I hope
there's going to be a "Powered by Delphi" paint job. Surprised)

I'd forgotten about this:

http://tinyurl.com/2rqmn

--
jc

Remove the -not from email

Back to top
Maarten Wiltink
Guest





PostPosted: Thu Jan 29, 2004 6:47 pm    Post subject: Re: Help with Arc needed Reply with quote

"AlanGLLoyd" <alanglloyd (AT) aol (DOT) com> wrote

[...]
Quote:
I was not suggesting an "all-out effort to construct an edifice" but
rather a "pit where we throw bricks as they turn up".

Would providing such a "pit" be a big exercise.

No. Yes. It depends. The bottom line remains: what would be the
added value? Everybody who writes a tutorial can publish it on
her own website, or submit it to any number of brick pits. I'll
be happy to accept hyperlinks in either category for the miniFAQ.
Because the question is not if tutorials would fit in nicely with
the idea of the miniFAQ; they would. The question is if we should
duplicate other efforts, and if we could beat them at it, and if
we should even try (either the duplication or the beating).

Groetjes,
Maarten Wiltink



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.