placeholders fro drawables

This commit is contained in:
Emanuele Trabattoni
2021-05-20 23:05:55 +02:00
parent 263741519b
commit b8ef6b7231
4 changed files with 206 additions and 20 deletions

View File

@@ -1,22 +1,164 @@
/*******************************************
* Most Awesome Renderer Ever
*******************************************/
#pragma once
#include <DEV_Config.h>
#include <EPD_2in9b_V3.h>
#include <fonts.h>
extern "C" {
#include <DEV_Config.h>
#include <EPD_2in9b_V3.h>
#include <fonts.h>
}
#include <vector>
#include <string>
namespace Render{
class Mare {
public:
Mare();
virtual ~Mare();
struct pos_t {
uint16_t x;
uint16_t y;
};
struct bbox2d_t {
uint16_t xMin, Ymin;
uint16_t Xmax, Ymax;
};
enum class ScreenRotation {
Rot0 = 0,
Rot90 = 90,
Rot180 = 180,
Rot270 = 270
};
enum class BlendMode {
Add,
Intersect
};
class Page;
class Drawable;
typedef pos_t dim_t;
typedef std::vector<Page*> Pages;
typedef std::vector<Drawable*> Drawables;
class Mare {
Mare();
virtual ~Mare();
// getters, setters
public:
void render();
void setSize(const uint16_t x, const uint16_t y);
const dim_t getSize();
void setRotation(const ScreenRotation r);
const ScreenRotation getRotation();
const Pages& getPages();
const uint8_t getCurrentPage();
void setCurrentPage(const uint8_t p);
const Drawables& getDrawables();
// drawables, pages
public:
void addDrawable();
void removeDrawable(size_t id);
void addPage(uint8_t num);
void removePage(uint8_t num);
private:
int _var;
void visitDrawables(Drawable* parent);
void render();
void setPixel(uint16_t x, uint16_t y, bool value);
// members
private:
uint8_t* _screenBufferForeground;
uint8_t* _screenBufferBackgrund;
dim_t _screenSize;
Pages _pages;
Drawables _drawables;
ScreenRotation _rotation;
};
class Drawable {
Drawable(const size_t id, const pos_t position, const Drawable* parent);
virtual ~Drawable();
public:
virtual void render();
public:
void setId(const size_t id);
void setOrigin(const pos_t origin);
void setDirty();
void setBlendMode(const BlendMode mode);
const bbox2d_t getBBox();
const BlendMode getBlendMode();
private:
bool _dirty;
size_t _id;
pos_t _origin;
bbox2d_t _bbox;
Drawables _children;
Drawable* _parent;
};
class DrawablePoint: public Drawable {
DrawablePoint();
~DrawablePoint();
public:
private:
void render();
// members
private:
};
class DrawableLine: public Drawable {
DrawableLine();
~DrawableLine();
public:
private:
void render() {};
// members
private:
};
class DrawableRectangle: public Drawable {
DrawableRectangle();
~DrawableRectangle();
public:
private:
void render() {};
// members
private:
};
class Page {
Page();
~Page();
public:
private:
};
}

View File

@@ -0,0 +1,31 @@
#include "mare.h"
namespace Render {
Drawable::Drawable(const size_t id, const pos_t position, const Drawable* parent) {
}
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
//Point
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
//Line
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
//Rectangle
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
//Circle
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
//Character
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
//String
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
//Custom
}

10
libs/mare/mare_pages.cpp Normal file
View File

@@ -0,0 +1,10 @@
#include "mare.h"
namespace Render {
Page::Page(){
}
}

View File

@@ -15,11 +15,11 @@ void setPixel(uint8_t* img, uint16_t x, uint16_t y, bool value){
else *img |= 0x01 << y%8;
}
void drawSquare(uint8_t* img, uint16_t x, uint16_t y, uint16_t dimX, uint16_t dimY){
void drawSquare(uint8_t* img, uint16_t x, uint16_t y, uint16_t dimX, uint16_t dimY, bool col){
for (auto xx(0); xx< dimX; xx++){
for (auto yy(0); yy < dimY; yy++)
{
setPixel(img,x+xx,y+yy,true);
setPixel(img,x+xx,y+yy,col);
}
}
@@ -54,22 +54,25 @@ int main(){
delta[i][j]=0xff;
}
}
uint8_t dot(16);
uint8_t dot(8);
bool col(false);
while(true){
EPD_2IN9_V2_Display_Base((uint8_t*)img);
//EPD_2IN9_V2_Clear();
for (auto x(0); x <= EPD_2IN9_V2_HEIGHT-dot;x+=dot){
for(auto y(0); y <= EPD_2IN9_V2_WIDTH-dot;y+=dot){
drawSquare((uint8_t*)delta,x,y,dot,dot);
EPD_2IN9_V2_Display_Partial((uint8_t*)delta);
}
for(auto i(0); i < EPD_2IN9B_V3_HEIGHT; ++i){
for (auto j(0); j< EPD_2IN9B_V3_WIDTH/8; ++j){
delta[i][j]=0xff;
for(auto k(0); k<2; ++k){
col = col ? false : true;
for (auto x(0); x <= EPD_2IN9_V2_WIDTH-dot;x+=dot){
for(auto y(0); y <= EPD_2IN9_V2_HEIGHT-dot;y+=dot){
drawSquare((uint8_t*)delta,y,EPD_2IN9_V2_WIDTH-x-dot,dot,dot,col);
EPD_2IN9_V2_Display_Partial((uint8_t*)delta);
}
}
}
for(auto i(0); i < EPD_2IN9B_V3_HEIGHT; ++i){
for (auto j(0); j< EPD_2IN9B_V3_WIDTH/8; ++j){
delta[i][j]=0xff;
}
}
printf("[%u] Hello, world!\n",i++);
gpio_put(LED_PIN,s);
s = s ? false : true;