⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 circlefun.cpp

📁 C++&datastructure书籍源码,以前外教提供现在与大家共享
💻 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 + -