circles.cpp
来自「C++&datastructure书籍源码,以前外教提供现在与大家共享」· C++ 代码 · 共 29 行
CPP
29 行
#include "canvas.h"
// show simple Canvas functions, change style and color of drawing
void circles(Canvas& c, const Point& p, double size)
// post: series of circles drawn on c, centered at p
// initial size = size (decreased by 20% for each one
{
color spectrum[] = {CanvasColor::RED, CanvasColor::ORANGE, CanvasColor::YELLOW,
CanvasColor::GREEN, CanvasColor::BLUE, CanvasColor::INDIGO,
CanvasColor::VIOLET};
int k;
for(k=0; k < 7; k++)
{ c.SetColor(spectrum[k]);
c.DrawCircle(p,size);
size *= 0.80;
}
}
int main()
{
const int WIDTH = 250, HEIGHT = 150;
Canvas c(WIDTH, HEIGHT, 20,20);
circles(c, Point(WIDTH/4, HEIGHT/2), WIDTH/4);
c.SetFrame();
circles(c, Point(3*WIDTH/4, HEIGHT/2), WIDTH/4);
c.runUntilEscape();
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?