draws wonky line

This commit is contained in:
Emanuele Trabattoni
2021-05-28 00:05:42 +02:00
parent 8325dcfdd8
commit a77b66e4ef
5 changed files with 100 additions and 41 deletions

View File

@@ -4,6 +4,7 @@
#include <stdio.h>
#include <pico/stdlib.h>
#include <pico/float.h>
extern "C" {
#include <DEV_Config.h>
@@ -14,6 +15,7 @@ extern "C" {
#include <string>
#include <cstring>
#include <memory>
#include <math.h>
namespace Render{
@@ -94,6 +96,11 @@ namespace Render{
public:
void render();
void setPixel(uint8_t* img, uint16_t x, uint16_t y, bool value);
void clearScreen() {
EPD_2IN9_V2_Clear();
clearBuffer(_screenBufferBackground, _bufferDim, Color::White);
EPD_2IN9_V2_Display_Base(_screenBufferBackground);
}
// members
private:
@@ -123,12 +130,19 @@ namespace Render{
void setId(const size_t id) { _id = id; };
void setOrigin(const pos_t origin) { _origin = origin; };
void setDirty() {_dirty = true;};
void resetDirty() {_dirty = false;};
void setBlendMode(const BlendMode mode) { _blendMode = BlendMode::Intersect; };
const bool isDirty() {return _dirty;}
const pos_t getOrigin() { return _origin; };
const bbox2d_t getBBox() { return _bbox; };
const BlendMode getBlendMode() { return _blendMode; };
uint8_t* getBuffer() {
if (_parent == nullptr) return engine()->bBuffer();
else return engine()->fBuffer();
}
Mare* engine() { return _engine; };
Drawable* parent() { return _parent; };
@@ -162,26 +176,27 @@ namespace Render{
};
class DrawableLine: public Drawable {
DrawableLine();
~DrawableLine();
public:
DrawableLine(const size_t id, Drawable* parent, Mare* engine);
~DrawableLine();
public:
void setThickness(uint16_t thickness);
const uint16_t getThickness();
void setRotation(float rotation);
const float getRotation();
void setLength(uint16_t length);
const uint16_t getLength();
void setThickness(uint16_t thickness) {_thickness = thickness;};
const uint16_t getThickness() {return _thickness;};
void setRotation(float rotation) {_rotation = rotation;};
const float getRotation() {return _rotation;};
void setLength(uint16_t length) {_lenght = length;};
const uint16_t getLength() {return _lenght;};
private:
void render(); // difficult business
// members
private:
uint16_t _thickness;
uint16_t _lenght;
float _rotation;
uint16_t _thickness;
uint16_t _lenght;
float _rotation;
};
class DrawableRectangle: public Drawable {