83 lines
2.2 KiB
C++
83 lines
2.2 KiB
C++
//
|
|
// Created by shaohuatong on 21.11.19.
|
|
//
|
|
#ifndef SIMPLE_DRAW_DRAWRENDER_HPP
|
|
#define SIMPLE_DRAW_DRAWRENDER_HPP
|
|
|
|
#include <string>
|
|
#include <Color.hpp>
|
|
#include <vkvm.hpp>
|
|
#include <iostream>
|
|
#include "Font.h"
|
|
#include "vector"
|
|
#include <cmath>
|
|
|
|
#define CIRCLE 0
|
|
#define SQUARE 1
|
|
#define RECTANGLE 2
|
|
#define BRUSH 3
|
|
|
|
class DrawRender {
|
|
public:
|
|
DrawRender(int windowWidth, int windowHeight, vkvm::Color defaultBackgroundColor, vkvm::Color penColor, int penWidth);
|
|
void brushUpdate(vkvm::Coordinates mousePosition);
|
|
void graphicsUpdate(int type);
|
|
|
|
void setMouseLeftDownPostion(vkvm::Coordinates newMousePosition);
|
|
vkvm::Coordinates getMouseLeftDownPosition();
|
|
void setMousePostion(vkvm::Coordinates newMousePosition);
|
|
vkvm::Coordinates getMousePostion();
|
|
void setKeyCode(vkvm::KeyCode newKeyCode);
|
|
void setTurnOnBrush(bool turnOnBrush);
|
|
bool getTurnOnBrush();
|
|
vkvm::KeyCode getKeyCode();
|
|
void setKeyCode();
|
|
void setMouseDown(bool isMouseDown);
|
|
bool getMouseDown();
|
|
void setPainting(bool isOneFinish);
|
|
bool getPainting();
|
|
int getRadius();
|
|
|
|
void clear();
|
|
|
|
private:
|
|
std::vector<std::vector<bool>> oldGraphics;
|
|
vkvm::Coordinates mouseLeftDownPosition;
|
|
vkvm::Coordinates mousePosition;
|
|
vkvm::Color backgroundColor;
|
|
vkvm::Color penColor;
|
|
vkvm::KeyCode keyCode;
|
|
int penWidth;
|
|
int windowWidth;
|
|
int windowHeight;
|
|
int radius;
|
|
int length;
|
|
int width;
|
|
int startX;
|
|
int startY;
|
|
bool painting = true;
|
|
bool mouseDown = false;
|
|
bool turnOnBrush = false;
|
|
|
|
std::vector<std::vector<bool>> rectangleCreator();
|
|
std::vector<std::vector<bool>> circleAndSquareCreator(int type);
|
|
std::vector<std::vector<bool>> brushCreator(vkvm::Coordinates mousePosition);
|
|
int squareOfDistance(vkvm::Coordinates x, vkvm::Coordinates y);
|
|
int getDistance(vkvm::Coordinates x, vkvm::Coordinates y);
|
|
int min(int x, int y);
|
|
int max(int x, int y);
|
|
void translateToSharedMemory(std::vector<std::vector<bool>> graphics, int startX, int startY);
|
|
void clearToSharedMemory(std::vector<std::vector<bool>> graphics, int startX, int startY);
|
|
};
|
|
|
|
#endif //SIMPLE_DRAW_DRAWRENDER_HPP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|