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

📄 d-rect.h

📁 一些学习c++的例题
💻 H
字号:
#ifndef __RECTANGLE_H__
#define __RECTANGLE_H__

#include "graphenv.h"
#include "d-shape.h"
#include "d-point.h"

class CRectangle : public CShape
{
protected:
   CPoint m_Points[2];

public:
   CRectangle(const int left = 0, const int top = 0,
   const int right = 10, const int bottom = 10)
   {
      m_Points[0] = CPoint(left, top);
      m_Points[1] = CPoint(right, bottom);
   }

   CRectangle(const CPoint& p1, const CPoint& p2)
   {
      m_Points[0] = p1;
      m_Points[1] = p2;
   }

   CRectangle(const CRectangle& r)
   {
      m_Points[0] = r.m_Points[0];
      m_Points[1] = r.m_Points[1];
   }

   ~CRectangle() {}

   void Show(const int color) const
   {
      CGraphEnv::SetColor(color);
      CGraphEnv::Rectangle(m_Points[0].x, m_Points[0].y, m_Points[1].x, m_Points[1].y);
   }

   void Move(const int offsetX, const int offsetY)
   {
      CPoint tmp(offsetX, offsetY);
      m_Points[0] += tmp;
      m_Points[1] += tmp;
      Show(CGraphEnv::COLOR_LIGHTBLUE);
      CGraphEnv::Outtextxy(m_Points[0].x + 4, m_Points[0].y + 4, "moved");
   }

   void Inflate(const float s)
   {
      m_Points[0] *= s;
      m_Points[1] *= s;
      Show(CGraphEnv::COLOR_LIGHTGREEN);
      CGraphEnv::Outtextxy(m_Points[0].x + 4, m_Points[0].y + 4, "inflated");
   }
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -