render line with rotation method, still some bugs

This commit is contained in:
Emanuele Trabattoni
2021-06-02 18:04:23 +02:00
parent 7116885f2d
commit 60c6ca83c1
6 changed files with 109 additions and 73 deletions

View File

@@ -2,8 +2,10 @@
* Most Awesome Renderer Ever
*******************************************/
#include <stdio.h>
//#include <stdio.h>
#include <pico/stdlib.h>
#include <pico/printf.h>
#include <pico/int64_ops.h>
#include <pico/float.h>
extern "C" {
@@ -24,6 +26,11 @@ namespace Render{
uint16_t y;
};
struct spos_t {
int16_t x;
int16_t y;
};
struct bbox2d_t {
uint16_t xMin, Ymin;
uint16_t Xmax, Ymax;
@@ -92,12 +99,13 @@ namespace Render{
//render
private:
void clearBuffer(uint8_t* buffer, uint16_t len, Color col);
bool applyRotation(uint16_t* x, uint16_t* y);
bool applyScreenRotation(uint16_t* x, uint16_t* y);
void visitDrawables(Drawable* parent) {};
public:
void render();
void setPixel(uint8_t* img, uint16_t x, uint16_t y, bool value);
void setPixel(uint8_t* img, uint16_t x, uint16_t y, BlendMode bm);
spos_t rotateXY(int16_t x, int16_t y, float rot);
void clearScreen();
// members
@@ -129,7 +137,7 @@ namespace Render{
void setOrigin(const pos_t origin) { _origin = origin; };
void setDirty() {_dirty = true;};
void resetDirty() {_dirty = false;};
void setBlendMode(const BlendMode mode) { _blendMode = BlendMode::Intersect; };
void setBlendMode(const BlendMode mode) { _blendMode = mode; };
const bool isDirty() {return _dirty;}
const pos_t getOrigin() { return _origin; };
@@ -186,6 +194,8 @@ namespace Render{
const float getRotation() {return _rotation;};
void setLength(uint16_t length) {_lenght = length;};
const uint16_t getLength() {return _lenght;};
void setOutline(bool outline) {_outline = outline;};
const bool getOutline() {return _outline;};
private:
void render(); // difficult business
@@ -195,6 +205,7 @@ namespace Render{
uint16_t _thickness;
uint16_t _lenght;
float _rotation;
bool _outline;
};
class DrawableRectangle: public Drawable {