posted 2 years ago

Hello guys, I know the concept of how Threads work, and learning to play around with them won't be a problem I believe. I first need help to draw this exact shape, which later I will have to make it move anti-clockwise, but for now, I need some ideas on how to draw this thing:

First thing I can think of is drawArc, but not so sure...

First thing I can think of is drawArc, but not so sure...

posted 2 years ago

Question 1. What does threads have to do with this? It sounds like you are thinking about animation, and that somehow needs threads. Before you can animate, you need to draw on frame, and before you can draw one frame, you need to draw one circle, and before ... etc. You need draw one dot first.

Question 2. How much of your high school geometry do you remember?

A. Given two points, how do you calculate the distance between them?

B. Given one point and distance, can you calculate the other point? Or is it multiple point?

Try to figure out the math for this first. After that you can apply the math to get to what is needed to draw a circle.

Henry

Question 1. What does threads have to do with this? It sounds like you are thinking about animation, and that somehow needs threads. Before you can animate, you need to draw on frame, and before you can draw one frame, you need to draw one circle, and before ... etc. You need draw one dot first.

Question 2. How much of your high school geometry do you remember?

A. Given two points, how do you calculate the distance between them?

B. Given one point and distance, can you calculate the other point? Or is it multiple point?

Try to figure out the math for this first. After that you can apply the math to get to what is needed to draw a circle.

Henry

posted 2 years ago

Oh yea, I completely forgot that Java did all the work of drawing a circle for you. So, yes, you can skip all the calculations and let the drawArc() method draw the circle for you.

So... what is it that you are not sure of?

Henry

Kaspersky Ukshini wrote:

First thing I can think of is drawArc, but not so sure...

Oh yea, I completely forgot that Java did all the work of drawing a circle for you. So, yes, you can skip all the calculations and let the drawArc() method draw the circle for you.

So... what is it that you are not sure of?

Henry

posted 2 years ago

I need to make it look the one in the picture, I guess I need a critcle within a circle, or if possible a circle with bolded border, so I can fill it with colors then.

What I've no idea how to do is fill if with collors like it's done in the picture.

The thing about the threads is that it's not up to me how to solve it, they're asking specificaly to solve it with threads, because the colors need to move anticlockwise every X milliseconds, to make it look like an animation, that's the main point.

Henry Wong wrote:Kaspersky Ukshini wrote:

First thing I can think of is drawArc, but not so sure...

Oh yea, I completely forgot that Java did all the work of drawing a circle for you. So, yes, you can skip all the calculations and let the drawArc() method draw the circle for you.

So... what is it that you are not sure of?

Henry

I need to make it look the one in the picture, I guess I need a critcle within a circle, or if possible a circle with bolded border, so I can fill it with colors then.

What I've no idea how to do is fill if with collors like it's done in the picture.

The thing about the threads is that it's not up to me how to solve it, they're asking specificaly to solve it with threads, because the colors need to move anticlockwise every X milliseconds, to make it look like an animation, that's the main point.

Piet Souris

Rancher

Posts: 1782

54

posted 2 years ago

Well, easiest that I can think of:

1) create a BufferedImage, type int_argb;

2) make sure the image is fully transparant

3) draw the arcs in this BI, using a sufficient strokewidth

4) then, in a loop, draw this BI, each passage rotated slightly more than it's predecessor.

Greetz,

Piet

1) create a BufferedImage, type int_argb;

2) make sure the image is fully transparant

3) draw the arcs in this BI, using a sufficient strokewidth

4) then, in a loop, draw this BI, each passage rotated slightly more than it's predecessor.

Greetz,

Piet

posted 2 years ago

Once you've created the arcs, then make a (closed) path out of them and fill the area inside that path with some colour. Am I right in assuming that you used Arc2D objects to draw the arcs? (I have to guess because there's no code to discuss.) Then use other classes in the same package to do the rest.

Campbell Ritchie

Sheriff

Posts: 53734

127