【问题标题】:How to draw a filled circle in Borland C++?如何在 Borland C++ 中画一个实心圆?
【发布时间】:2019-11-29 22:15:07
【问题描述】:

我被困在使用 Borland C++ 的程序上。我想用红色画一个实心圆,至少大到老人的眼睛可以看到。

xRed = random( 160 );
yRed = random( 120 );
PaintBox1->Canvas->Pixels[ xRed ][ yRed ] = clRed;

我写了这段代码,它只给了我一个非常非常小的点,即使是我的完美 眼睛看不清楚。请指教。

【问题讨论】:

  • 什么执行环境?视窗? MSDOS?你想用什么库?
  • at least big enough for a old man's eyes to see 这取决于这个人的年龄! ;) 开个玩笑..
  • 如果您使用 BGI,您可以使用 fillellipse,但看起来您正在尝试在某个位图上绘图,因此任何通用的圆形填充例程都应该适合您。
  • 如何将像素 (xRed, yRed) 周围的像素设置为红色,形成一个圆圈。这样会更显眼。
  • 我正在使用,我不知道我正在使用...我在 Windows XP 上,我的程序给了我一个用户图形界面。

标签: c++ drawing c++builder


【解决方案1】:

虽然我不记得这是否适用于圆形,但它肯定适用于矩形。检查类似这样的内容

setfillstyle(SOLID_FILL, BLUE);
Circle(x,y,radious);

【讨论】:

  • 你想画圆的地方
  • 在PaintBox1里面,是一个160*120大小的画布
  • 它将在当前窗口上绘制。根据中心x,y和radius。
  • 我的程序说未定义的函数 setfillstyle
  • 查看函数的头文件
【解决方案2】:

PaintBox1->Canvas-> 向我建议您使用的是 Turbo C++ Explorer,它是 Borland C++ Builder 的免费版本,并且正在使用 VCL 框架。

如果是这样,试试这个代码:

   PaintBox1->Canvas->Brush->Color = clRed; // Set the fill color
   PaintBox1->Canvas->Pen->Color = clRed;   // Set the border color

   int xRed = random( 160 );
   int yRed = random( 120 );
   int radius = 40;

   PaintBox1->Canvas->Ellipse(xRed - radius, yRed - radius, xRed + radius, yRed + radius);

【讨论】:

    【解决方案3】:

    如果我没记错的话,有FillEllipse() 过程(它确实画了一个实心椭圆)...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-31
      相关资源
      最近更新 更多