我正在研究轮盘赌轮,最终将对其进行动画处理。以前,口袋中的数字显示出来,经过大量更改后,它们不再显示。我已经看了一段时间的代码。

希望由于缺少睡眠和初学者水平的知识而错过了一些显而易见的事情。

     #include <stdio.h>
#include <stdlib.h>
#include <gd.h>
#include <math.h>

#define USE_GLOBAL_COLORMAP  1
#define USE_LOCAL_COLORMAP   0

#define LOOP_ANIMATION_FOREVER  1
#define DO_NOT_LOOP_ANIMATION  0
#define AUTO_FRAME_DISPOSAL     1
#define ANIMATION_DELAY         1 /* in milliseconds */

#define IMAGE_WIDTH        500
#define IMAGE_HEIGHT       500
#define CENTERX IMAGE_WIDTH /2
#define CENTERY IMAGE_WIDTH /2

#define WHEEL_DIAMETER     IMAGE_WIDTH - 20
#define INSIDE_COVER_DIAMETER WHEEL_DIAMETER - 80
#define MAX_FRAMES_COUNT   100
#define MOVEMENT_PER_FRAME 5


int main( void )
{


  gdImagePtr Roulette = gdImageCreate (IMAGE_WIDTH, IMAGE_HEIGHT);


  //FILE *animatedGIF;
  FILE *jpgImageFile = NULL;

    int red, black, green, gold, silver, white, trim;
    int frameCount, frameImage;

    double degreesToRadiansMultiplier = 0.0174532925;
      char *pocketNumbers[] = { "32", "15", "19", "4",  "21", "2",  "25", "17",    "34",
                             "6",  "27", "13", "36", "11", "30", "8",  "23", "10",
                             "5",  "24", "16", "33", "1",  "20", "14", "31", "9",
                            "22", "18", "29", "7",  "28", "12", "35", "3",  "26", "0" };


     int sliceCounter = 0;
      int sliceStartingAngle = 0;
      int sliceEndingAngle = 0;
      int sliceAngleIncrement = 9;
      int textPositionAngle = 367;
      int textRotationAngle = 270;
      int textPositionX, textPositionY;
      int drawingColor;




      frameImage = gdImageCreate( IMAGE_WIDTH, IMAGE_HEIGHT );
    gdImageColorAllocate( Roulette, 34, 139, 34 );
    red = gdImageColorAllocate( Roulette, 204, 0, 0 );
    white = gdImageColorAllocate( Roulette,  255, 255, 255 );
    green = gdImageColorAllocate( Roulette, 0, 102, 0 );
    gold = gdImageColorAllocate( Roulette, 215, 215, 0 );
    silver = gdImageColorAllocate( Roulette, 192, 192, 192 );
    black = gdImageColorAllocate( Roulette, 0, 0, 0);
    trim = gdImageColorAllocate (Roulette, 102, 51, 0);

    gdImageSetThickness( Roulette, 4 );
    gdImageFilledArc(Roulette, CENTERX, CENTERY, 450, 450, 0, 360, trim, gdArc);

      do
{
sliceStartingAngle = sliceEndingAngle;
sliceEndingAngle = sliceStartingAngle + sliceAngleIncrement;
textRotationAngle -= sliceAngleIncrement;
textPositionAngle -= sliceAngleIncrement;

if ( sliceCounter == 36 )
{
  drawingColor = green;
  sliceEndingAngle += 1;
  textPositionAngle -= 3;
}
else if ( (sliceCounter % 2) == 0 )
{
  drawingColor = red;
  textRotationAngle += 2;
}
else
{
  drawingColor = black;
  sliceEndingAngle += 1;
  textPositionAngle -= 1;
  textRotationAngle -= 1;
}

if ( (sliceCounter % 5) == 0 ) sliceEndingAngle += 1;
if ( (sliceCounter % 7) == 6 ) { textPositionAngle -= 1; textRotationAngle -= 8; }
if ( (sliceCounter % 13) == 12 ) textPositionAngle -= 1;

textPositionX = (cos(textPositionAngle * degreesToRadiansMultiplier) * (WHEEL_DIAMETER / 2.25)) + CENTERX;
textPositionY = CENTERY - (sin(textPositionAngle * degreesToRadiansMultiplier) * (WHEEL_DIAMETER / 2.25));

gdImageFilledArc( Roulette, CENTERX, CENTERY, WHEEL_DIAMETER, WHEEL_DIAMETER, sliceStartingAngle, sliceEndingAngle, drawingColor, gdArc );
gdImageStringFT( Roulette, NULL, white, "Vera.ttf", 14, textRotationAngle * degreesToRadiansMultiplier, textPositionX, textPositionY, pocketNumbers[ sliceCounter ] );
  } while ( ++sliceCounter < 37 );

  gdImageFilledEllipse( Roulette, CENTERX, CENTERY, INSIDE_COVER_DIAMETER,    INSIDE_COVER_DIAMETER, white );





   //gdImageFilledArc( Roulette, CENTERX, CENTERY, WHEEL_DIAMETER, WHEEL_DIAMETER, sliceStartingAngle, sliceEndingAngle, gold, gdArc );



    jpgImageFile = fopen( "RouletteImage.jpg", "wb" );
      gdImageJpeg( Roulette, jpgImageFile, -1 );
      fclose( jpgImageFile );
      gdImageDestroy( Roulette );
    }


谢谢:)(哦,它是欧洲轮盘赌盘)

最佳答案

这真的很简单,我想我只是累了。

删除符号常量

#define WHEEL_DIAMETER IMAGE_WIDTH - 20


替换为整数

  int WHEEL_DIAMETER = IMAGE_WIDTH - 20;

关于c - 我的文字在哪里?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23176459/

10-11 21:45