📄 circlefun.cpp
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -