Robert Ryan wrote:
>
>
> I am putting the numbers on the screen by laborious handwork. I am
> sure that there is a for loop for such a process. does anyone know of
> such a loop for the numbers (and /or) the lines for the seconds
> Text t12;
> Text t5;
> Text t10;
> Text t15;
>
> t12(Point(444, 175), "12"),
> t5(Point(540, 198), "5"),
> t10(Point(600, 265), "10"),
> t15(Point(628, 362), "15"),
>
> t12.set_font_size(20);
> attach(t12);
> t5.set_font_size(20);
> attach(t5);
> t10.set_font_size(20);
> attach(t10);
> t15.set_font_size(20);
> attach(t15);
>
> --- On Thu, 4/30/09, Robert Ryan <[email protected]
> <mailto:bobzcplpl%40yahoo.com>> wrote:
>
> From: Robert Ryan <[email protected] <mailto:bobzcplpl%40yahoo.com>>
> Subject: [c-prog] clock function
> To: [email protected] <mailto:c-prog%40yahoogroups.com>
> Date: Thursday, April 30, 2009, 10:21 PM
>
> This function makes a circle with buttons.
>
> I want to know if there is a function to make the numbers
> for the clock
>
> and makes the lines going inward for the seconds
>
> // open brace: makes it a definition
>
> double circle_pi = 3.14;
>
> // This can
> be any number, the point is that we are generating
>
> // the
> buttons automatically
>
> for (double
> i = 0 ; i<(2*circle_ pi); i+=(2*circle_ pi/60))
>
> {
>
> My_Button*
> tempButton = new My_Button(Point
>
> (x_max()/2+( 200*cos(i) ),
>
>
> y_max()/2+(200* sin(i))), 12, 12, "0", cb_button);
>
> attach(*tempButton) ;
>
> v1.push_back( tempButton) ;
>
> v2.push_back( tempButton- >
>
> get_fltk_button_ address() );
>
> }_
>
> [Non-text portions of this message have been removed]
>
> [Non-text portions of this message have been removed]
>
>
for (int i = 0; i < 12; i++)
{
// this will give us the number of degrees from the '12' on the
circle to the number 'i'. (0 equals 12)
float deg = (i / 11) * 360;
// get x and y
float x = cos(deg) * radius;
float y = sin(deg) * radius;
// now you can draw your text or create your button..
doSomething(x, y, i);
}
You can do the same thing for second and minute tick marks, as well as
the second, minute, and hour hands.