hi everybody...
finally continuing this topic....
{"name":"596641","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/8\/c82856649779aed183b067e5e0f22817.jpg","w":271,"h":274,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/8\/c82856649779aed183b067e5e0f22817"}
sure it will be once again something very simple , but ....
How to obtain coordonnates of the Black side and the White Side of my triangle, knowing my r and hue sommit , as we move the hue with mouse ??
1 | float position_curseur_hue_x, position_curseur_hue_y;//mouse position on click= HUE |
2 | float vx, vy;// |
3 | float vxh,vyh;//triangle HUe position |
4 | float vxd,vyd;//triangle Dark position |
5 | flaot vxw,vyw;//triangle white position |
6 | |
7 | int Interface_Trichromie(int xchroma, int ychroma, int rayon, int largeurchroma) |
8 | { |
9 | for(float angle = 0 ; angle < 360 ; angle++) |
10 | { |
11 | |
12 | vx = cos(angle* 3.14116/180)*rayon; |
13 | vy = sin(angle* 3.14116/180)*rayon; |
14 | Line(Vec2D(xchroma+vx,ychroma+vy),Vec2D(xchroma+vx+1,ychroma+vy+1)).Draw( CouleurLigne ); |
15 | |
16 | if(mouse_x>xchroma+vx-10 && mouse_x< xchroma+vx+10 && mouse_y>ychroma+vy-10 && mouse_y<ychroma+vy+10) |
17 | { |
18 | if (mouse_b&1)//setting hue summit |
19 | { |
20 | position_curseur_hue_x=xchroma+vx; |
21 | position_curseur_hue_y=ychroma+vy; |
22 | vxh = cos(angle* 3.14116/180)*(rayon-15); //hue triangle position |
23 | vyh = sin(angle* 3.14116/180)*(rayon-15); |
24 | } |
25 | } |
26 | } |
27 | Circle monCurseurHue( Vec2D( position_curseur_hue_x,position_curseur_hue_y ), 12 ); |
28 | monCurseurHue.SetLineWidth(epaisseur_ligne_fader*1.5); |
29 | monCurseurHue.DrawOutline( Rgba::BLACK ); |
30 | |
31 | //triangle |
32 | V3D_f v1 = |
33 | { |
34 | xchroma+vxd, ychroma+vyd, 0, |
35 | 0., 0., |
36 | makecol(0, 0, 0) // black vertex |
37 | }; |
38 | V3D_f v2 = |
39 | { |
40 | 150., 350., 0, |
41 | 0., 0., |
42 | makecol(255, 255, 255) // white vertex |
43 | }; |
44 | V3D_f v3 = |
45 | { |
46 | xchroma+vxh, ychroma+vyh, 0, |
47 | 0., 0., |
48 | makecol(255, 0, 0) // color vertex |
49 | }; |
50 | |
51 | triangle3d_f(screen, POLYTYPE_GCOL, NULL, &v1, &v2, &v3); |
52 | |
53 | return(0); |
54 | } |
You got the red vertex angle, right? Add pi*2/3 to it and you get one of them. Add pi*4/3 to get the other one. That's adding 120° and 240°. That's how far the vertices are from each other along the circle, right?
Here's a complete working example as an Allegro GUI widget. Not tested since the file date >:)
thanks ! this was pi*4/3 i was missing (and the fact once upon a time i learned that a triangle sum of angle should b 360°)! cheers ! and thxs mat for this nice bit of code, I would look at it closely and carefully ! ;-)
Matt, you probably spoiled the fun! Help is supposed to be given bit by bit (or byte by byte ), so that the person still feels he did it all by himself.
hum... do not worry about the fun ;-)