circlefun.cpp
来自「C++&datastructure书籍源码,以前外教提供现在与大家共享」· C++ 代码 · 共 36 行
CPP
36 行
#include <iostream>
using namespace std;
#include "canvas.h"
#include "dice.h"
// illustrate MKAdapter, make a circle where mouse is clicked
class MakeCircle : public MKAdapter // stateless, make a circle where clicked
{
public:
MakeCircle()
{ }
void processClick(const Point& p, AnimatedCanvas& ac)
// post: circle of random radius created at mouse click point
// center labeled withcoordinates
{
Dice d(6);
CircleShape circ(p,d.Roll()*5, CanvasColor::MAGENTA);
ac.addShape(circ);
TextShape label(p,p.tostring(),CanvasColor::BLACK);
ac.addShape(label);
}
};
int main()
{
AnimatedCanvas ac(200,200,20,20);
MakeCircle mc;
ac.addShape(mc);
ac.runUntilEscape(10);
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?