Drawing a synchronization timer with padding

I'm trying to make a timer that simulates a clock with a ticking hand. I have no problem drawing the texture of the clock and then the line for the hand, but I also want the space behind the clock to be filled. As time goes on, I want the clock to “fill” from the beginning (0:00) up to the clockwise direction.

I basically want to do this:

clocks

What is the best way for me to do this? I have a basis, I just don’t know how to add a filling part.

+4
source share
2 answers

You have to figure out how it creates a triangular fan.

  int n=0;
  VertexPostionColor[] V = new VertexPositionColor[num_triangles+2]
  V[0] = Center;
  for (var angle = start ;angle<=end; angle += (end - start) / num_triangles)
  {
       V[++N].Position = new Vector3( Math.Cos(angle), Math.Sin(angle)) * radius + Center;
       V[N].Color = CircleColor;
  }

  Short[] Index = new Short[num_triangles*3];

  for (int i = 0; i< num_triangles; i++)
  {
      Index[i*3] = 0;
      Index[i*3+1] = i+1;
      Index[i*3+2] = i+2;
  }

  GraphicsDevice.DrawUserIndexedPrimitives(...);

spritebatch, , .

enter image description here

, , .

  float SectorAngle = Mathhelper.ToRadians(10);
  Texture2D SectorTex;
  Vector2 Origin = new Vector2(SectorTex.Width/2, SectorTex.Height);
  for (var angle=start; angle<=end; angle+=SectorAngle) {
      spriteBatch.Draw(SectorTex, Center, null, Color.White, Origin, angle, scale,...)
  }
+2

, : ( ) .

. , .

, , " ". , .

, , . , " ".

, ; .

+1

Source: https://habr.com/ru/post/1539080/


All Articles