diff --git a/draw/Image.cpp b/draw/Image.cpp index 9fc73b6..b4697e3 100644 --- a/draw/Image.cpp +++ b/draw/Image.cpp @@ -39,7 +39,7 @@ draw::Image::Image(void) : Init(); } -draw::Image::Image(Vector2D size) : +draw::Image::Image(etk::Vector2D size) : m_renderingBuffer(NULL), m_pixFrame(NULL), m_renderBase(NULL), @@ -120,7 +120,7 @@ draw::Image::~Image(void) } } -void draw::Image::Resize(Vector2D size) +void draw::Image::Resize(etk::Vector2D size) { if (NULL != m_renderArea) { delete(m_renderArea); @@ -196,22 +196,22 @@ void draw::Image::End(void) } -void draw::Image::MoveTo(Vector2D pos) +void draw::Image::MoveTo(etk::Vector2D pos) { } -void draw::Image::MoveToAbs(Vector2D pos) +void draw::Image::MoveToAbs(etk::Vector2D pos) { } -void draw::Image::LineTo(Vector2D pos) +void draw::Image::LineTo(etk::Vector2D pos) { } -void draw::Image::LineToAbs(Vector2D pos) +void draw::Image::LineToAbs(etk::Vector2D pos) { } @@ -226,18 +226,18 @@ void draw::Image::Draw(void) } -void draw::Image::Dot(Vector2D pos) +void draw::Image::Dot(etk::Vector2D pos) { /* Begin(); MoveTo(pos); - LineTo(pos+Vector2D(1,1)); + LineTo(pos+etk::Vector2D(1,1)); End(); */ Set(pos, m_fillColor); } -void draw::Image::Line(Vector2D posStart, Vector2D posEnd) +void draw::Image::Line(etk::Vector2D posStart, etk::Vector2D posEnd) { Begin(); MoveTo(posStart); @@ -245,10 +245,10 @@ void draw::Image::Line(Vector2D posStart, Vector2D posEnd) End(); } -void draw::Image::Rectangle(Vector2D pos, Vector2D size) +void draw::Image::Rectangle(etk::Vector2D pos, etk::Vector2D size) { Begin(); - Vector2D tmp = pos; + etk::Vector2D tmp = pos; MoveTo(pos); tmp.x += size.x; LineTo(tmp); @@ -260,12 +260,12 @@ void draw::Image::Rectangle(Vector2D pos, Vector2D size) End(); } -void draw::Image::Circle(Vector2D pos, float radius, float angleStart, float angleStop) +void draw::Image::Circle(etk::Vector2D pos, float radius, float angleStart, float angleStop) { } -void draw::Image::Disc(Vector2D pos, float radius, float angleStart, float angleStop) +void draw::Image::Disc(etk::Vector2D pos, float radius, float angleStart, float angleStop) { } @@ -274,10 +274,10 @@ void draw::Image::Disc(Vector2D pos, float radius, float angleStart, floa void Grid::GenerateSDF() { // Pass 0 - Vector2D tmpPos; + etk::Vector2D tmpPos; for (tmpPos.y=1 ; tmpPos.y p = Get(tmpPos); + etk::Vector2D p = Get(tmpPos); Compare(p, tmpPos, -1, 0 ); Compare(p, tmpPos, 0, -1 ); Compare(p, tmpPos, -1, -1 ); @@ -285,7 +285,7 @@ void Grid::GenerateSDF() Set(tmpPos, p); } for (tmpPos.x=m_size.x-2 ; tmpPos.x>0 ; tmpPos.x--) { - Vector2D p = Get(tmpPos); + etk::Vector2D p = Get(tmpPos); Compare(p, tmpPos, 1, 0 ); Set(tmpPos, p ); } @@ -293,7 +293,7 @@ void Grid::GenerateSDF() // Pass 1 for (tmpPos.y=m_size.y-2 ; tmpPos.y>0 ; tmpPos.y--) { for (tmpPos.x=m_size.x-2 ; tmpPos.x>1 ; tmpPos.x--) { - Vector2D p = Get(tmpPos); + etk::Vector2D p = Get(tmpPos); Compare(p, tmpPos, 1, 0 ); Compare(p, tmpPos, 0, 1 ); Compare(p, tmpPos, -1, 1 ); @@ -301,7 +301,7 @@ void Grid::GenerateSDF() Set(tmpPos, p); } for (tmpPos.x=1 ; tmpPos.x p = Get(tmpPos); + etk::Vector2D p = Get(tmpPos); Compare(p, tmpPos, -1, 0 ); Set(tmpPos, p); } @@ -312,18 +312,18 @@ void Grid::GenerateSDF() void draw::Image::DistanceField(void) { - DistanceField(Vector2D(0,0), m_size); + DistanceField(etk::Vector2D(0,0), m_size); } #endif #define META_DIST (8) -void draw::Image::DistanceField(Vector2D pos, Vector2D size, int32_t upscaler, int32_t startPos) +void draw::Image::DistanceField(etk::Vector2D pos, etk::Vector2D size, int32_t upscaler, int32_t startPos) { #ifndef BASIC_GRADIENT float maxVal = 1/(1000.0*sqrt(META_DIST*META_DIST+META_DIST*META_DIST)); - Vector2D tmpPos; + etk::Vector2D tmpPos; // generate distance system ... matrix ... - Grid grid2(Vector2D(META_DIST*2,META_DIST*2)); + Grid grid2(etk::Vector2D(META_DIST*2,META_DIST*2)); for(tmpPos.y=0 ; tmpPos.y pos, Vector2D size, i // when out no distance find ... grid1.SetErrorVal(insideOrOutsideCurrentPixel); - Vector2D tmpPos2; + etk::Vector2D tmpPos2; int32_t newDist = 50000000; for(tmpPos2.y=-META_DIST ; tmpPos2.y(META_DIST,META_DIST)); + int32_t tmpDist = grid2.Get(tmpPos2 + etk::Vector2D(META_DIST,META_DIST)); if (newDist > tmpDist) { newDist = tmpDist; } @@ -384,7 +384,7 @@ void draw::Image::DistanceField(Vector2D pos, Vector2D size, i grid1.SetErrorVal(0); grid2.SetErrorVal(500000); - Vector2D tmpPos; + etk::Vector2D tmpPos; for(tmpPos.y=0 ; tmpPos.y pos, Vector2D size, i for(tmpPos.y=startPos ; tmpPos.y elem1 = grid1.Get(tmpPos); - Vector2D elem2 = grid2.Get(tmpPos); + etk::Vector2D elem1 = grid1.Get(tmpPos); + etk::Vector2D elem2 = grid2.Get(tmpPos); // Calculate the actual distance from the x/y float dist1 = sqrt( (double)elem1.QuadDist() ); float dist2 = sqrt( (double)elem2.QuadDist() ); diff --git a/draw/Image.h b/draw/Image.h index 86260d2..ca016fb 100644 --- a/draw/Image.h +++ b/draw/Image.h @@ -48,11 +48,11 @@ class Grid { public: - Vector2D m_size; + etk::Vector2D m_size; etk::Vector m_data; int32_t m_outsideVal; int32_t m_errorVal; - Grid(Vector2D size) + Grid(etk::Vector2D size) { m_size = size; m_outsideVal = 20; @@ -71,14 +71,14 @@ class Grid { m_errorVal = newVal; } - void SetInide(Vector2D pos) + void SetInide(etk::Vector2D pos) { if( pos.x>=0 && pos.x=0 && pos.y pos) + void SetOutside(etk::Vector2D pos) { if( pos.x>=0 && pos.x=0 && pos.y pos) + int32_t Get(etk::Vector2D pos) { ; if( pos.x>0 && pos.x pos, int32_t val) + void Set(etk::Vector2D pos, int32_t val) { if( pos.x>0 && pos.x0 && pos.y m_size; - etk::Vector > m_data; - int32_t m_outsideVal; - int32_t m_errorVal; - Grid(Vector2D size) + etk::Vector2D m_size; + etk::Vector > m_data; + int32_t m_outsideVal; + int32_t m_errorVal; + Grid(etk::Vector2D size) { m_size = size; m_outsideVal = 20; m_errorVal = 0; // basic element : - Vector2D tmpPoint(0,0); + etk::Vector2D tmpPoint(0,0); // preallocate data with a basic bg elements : m_data.ReSize(m_size.x*m_size.y, tmpPoint); }; @@ -132,7 +132,7 @@ class Grid { m_errorVal = newVal; } - void SetInide(Vector2D pos) + void SetInide(etk::Vector2D pos) { //if( pos.x>=0 && pos.x=0 && pos.y pos) + void SetOutside(etk::Vector2D pos) { //if( pos.x>=0 && pos.x=0 && pos.y Get(Vector2D pos) + etk::Vector2D Get(etk::Vector2D pos) { //if( pos.x>0 && pos.x0 && pos.y(m_errorVal,m_errorVal); + //return etk::Vector2D(m_errorVal,m_errorVal); }; - void Set(Vector2D pos, Vector2D val) + void Set(etk::Vector2D pos, etk::Vector2D val) { //if( pos.x>0 && pos.x0 && pos.y &p, Vector2D pos, int32_t offsetx, int32_t offsety ) + void Compare(etk::Vector2D &p, etk::Vector2D pos, int32_t offsetx, int32_t offsety ) { pos.x += offsetx; pos.y += offsety; - Vector2D other = Get(pos); + etk::Vector2D other = Get(pos); other.x += offsetx; other.y += offsety; if (other.QuadDist() < p.QuadDist()) { @@ -191,7 +191,7 @@ namespace draw class Image { private: - Vector2D m_size; + etk::Vector2D m_size; etk::Vector m_data; agg::rendering_buffer * m_renderingBuffer; agg::pixfmt_rgba32 * m_pixFrame; @@ -205,7 +205,7 @@ namespace draw float m_strokeSize; public: // constructor : - Image(Vector2D size); + Image(etk::Vector2D size); Image(void); // destructor ~Image(void); @@ -220,10 +220,10 @@ namespace draw // -- basic tools : // ----------------------------------------------- public : - void Resize(Vector2D size); - //void Resize(Vector2D startPos, Vector2D size); + void Resize(etk::Vector2D size); + //void Resize(etk::Vector2D startPos, Vector2D size); - Vector2D GetSize(void) const + etk::Vector2D GetSize(void) const { return m_size; }; @@ -236,7 +236,7 @@ namespace draw return m_size.y; }; - //void Move(Vector2D pos); + //void Move(etk::Vector2D pos); //void Rotate(float angle); // radian @@ -254,7 +254,7 @@ namespace draw //Image & operator= (const Image &image) - draw::Color Get(Vector2D pos) + draw::Color Get(etk::Vector2D pos) { draw::Color outColor(0x00000000); if( pos.x>0 && pos.x pos, draw::Color newColor) + void Set(etk::Vector2D pos, draw::Color newColor) { if( pos.x>=0 && pos.x=0 && pos.y startPos, Vector2D size) const; + //Image GetSubImage(etk::Vector2D startPos, Vector2D size) const; - //void SetData(uint8_t *data, Vector2D size); + //void SetData(uint8_t *data, etk::Vector2D size); // ----------------------------------------------- // -- Drawing tools : @@ -291,21 +291,21 @@ namespace draw void SetStrokeSize(float thickness) { m_strokeSize = thickness; } - void MoveTo(Vector2D pos); - void MoveToAbs(Vector2D pos); - void LineTo(Vector2D pos); - void LineToAbs(Vector2D pos); + void MoveTo(etk::Vector2D pos); + void MoveToAbs(etk::Vector2D pos); + void LineTo(etk::Vector2D pos); + void LineToAbs(etk::Vector2D pos); void Join(void); void Draw(void); - void Line(Vector2D posStart, Vector2D posEnd); - void Dot(Vector2D pos); - void Rectangle(Vector2D pos, Vector2D size); - void Circle(Vector2D pos, float radius, float angleStart=0, float angleStop=2*M_PI); - void Disc(Vector2D pos, float radius, float angleStart=0, float angleStop=2*M_PI); + void Line(etk::Vector2D posStart, etk::Vector2D posEnd); + void Dot(etk::Vector2D pos); + void Rectangle(etk::Vector2D pos, etk::Vector2D size); + void Circle(etk::Vector2D pos, float radius, float angleStart=0, float angleStop=2*M_PI); + void Disc(etk::Vector2D pos, float radius, float angleStart=0, float angleStop=2*M_PI); // generate the distant field from the alpha value of the Image void DistanceField(void); - void DistanceField(Vector2D pos, Vector2D size, int32_t upscaler=1, int32_t startPos=0); + void DistanceField(etk::Vector2D pos, etk::Vector2D size, int32_t upscaler=1, int32_t startPos=0); void SaveFile(const char * file) {}; private: