S
S
Slavka2014-04-27 10:54:40
Canvas
Slavka, 2014-04-27 10:54:40

Draw an arrow at the tachometer, new coordinates

const double PI=3.14;
  double rad = 0.0;
  int X,Y;
  const int R=10*size;

  float k=(max-min)/6;
  int n[7];
  for (int i = 0; i < 7; i++) {

     n[i]=min+k*i;
  }
   for (int i = -45, j=6; i <315;i+=45) {

   if (i!=270) {
    rad = (i * (PI/180));
    Y = y-R * sin(rad);
    X = x+R * cos(rad);

    int Y1 = y-R*0.8 * sin(rad);
    int X1 = x+R*0.8 * cos(rad);

    int Y2 = y-R*0.7 * sin(rad);
    int X2 = x+R*0.7 * cos(rad);

    image ->Canvas->MoveTo(X1,Y1);
    image ->Canvas->LineTo(X,Y);
    image->Canvas->TextOutW(X2,Y2, n[j]);
    j--;
   }

//стрелка
if (max!=0 && min!=0) {


   float i =225-value*(360/(float(max - min)) );

   ShowMessage(i);
     rad = (i * PI/180);

     int	Y3 = y-R * sin(rad);
     int  X3 = x+R * cos(rad);

    image ->Canvas->MoveTo(x,y);
    image ->Canvas->LineTo(X3,Y3);
    image ->Canvas->TextOutW(X3,Y3,value);

   }

code for the value, but it is only suitable for the full dial, which has a bypass of 360, but I have 270, help me how to shift this.
577a8625cc2f4456a22029621d2b340f.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2014-04-27
@GavriKos

We translate the value for the tachometer into the range from 0 to 1 (0 is the minimum, judging by the figure - 720, 1 - the maximum value, 960). Multiply by the maximum number of degrees (270). Thus, for 720 you will have 0 degrees, for 960 - 270. Add the desired constant angle (your 720 is clearly not at the zero of the circle)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question