[DEV] change Vector2D ==> etk::Vector2D
This commit is contained in:
parent
18e51a5e97
commit
4c65a1049a
@ -39,7 +39,7 @@ draw::Image::Image(void) :
|
||||
Init();
|
||||
}
|
||||
|
||||
draw::Image::Image(Vector2D<int32_t> size) :
|
||||
draw::Image::Image(etk::Vector2D<int32_t> size) :
|
||||
m_renderingBuffer(NULL),
|
||||
m_pixFrame(NULL),
|
||||
m_renderBase(NULL),
|
||||
@ -120,7 +120,7 @@ draw::Image::~Image(void)
|
||||
}
|
||||
}
|
||||
|
||||
void draw::Image::Resize(Vector2D<int32_t> size)
|
||||
void draw::Image::Resize(etk::Vector2D<int32_t> size)
|
||||
{
|
||||
if (NULL != m_renderArea) {
|
||||
delete(m_renderArea);
|
||||
@ -196,22 +196,22 @@ void draw::Image::End(void)
|
||||
|
||||
}
|
||||
|
||||
void draw::Image::MoveTo(Vector2D<float> pos)
|
||||
void draw::Image::MoveTo(etk::Vector2D<float> pos)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void draw::Image::MoveToAbs(Vector2D<float> pos)
|
||||
void draw::Image::MoveToAbs(etk::Vector2D<float> pos)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void draw::Image::LineTo(Vector2D<float> pos)
|
||||
void draw::Image::LineTo(etk::Vector2D<float> pos)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void draw::Image::LineToAbs(Vector2D<float> pos)
|
||||
void draw::Image::LineToAbs(etk::Vector2D<float> pos)
|
||||
{
|
||||
|
||||
}
|
||||
@ -226,18 +226,18 @@ void draw::Image::Draw(void)
|
||||
|
||||
}
|
||||
|
||||
void draw::Image::Dot(Vector2D<float> pos)
|
||||
void draw::Image::Dot(etk::Vector2D<float> pos)
|
||||
{
|
||||
/*
|
||||
Begin();
|
||||
MoveTo(pos);
|
||||
LineTo(pos+Vector2D<float>(1,1));
|
||||
LineTo(pos+etk::Vector2D<float>(1,1));
|
||||
End();
|
||||
*/
|
||||
Set(pos, m_fillColor);
|
||||
}
|
||||
|
||||
void draw::Image::Line(Vector2D<float> posStart, Vector2D<float> posEnd)
|
||||
void draw::Image::Line(etk::Vector2D<float> posStart, etk::Vector2D<float> posEnd)
|
||||
{
|
||||
Begin();
|
||||
MoveTo(posStart);
|
||||
@ -245,10 +245,10 @@ void draw::Image::Line(Vector2D<float> posStart, Vector2D<float> posEnd)
|
||||
End();
|
||||
}
|
||||
|
||||
void draw::Image::Rectangle(Vector2D<float> pos, Vector2D<float> size)
|
||||
void draw::Image::Rectangle(etk::Vector2D<float> pos, etk::Vector2D<float> size)
|
||||
{
|
||||
Begin();
|
||||
Vector2D<float> tmp = pos;
|
||||
etk::Vector2D<float> tmp = pos;
|
||||
MoveTo(pos);
|
||||
tmp.x += size.x;
|
||||
LineTo(tmp);
|
||||
@ -260,12 +260,12 @@ void draw::Image::Rectangle(Vector2D<float> pos, Vector2D<float> size)
|
||||
End();
|
||||
}
|
||||
|
||||
void draw::Image::Circle(Vector2D<float> pos, float radius, float angleStart, float angleStop)
|
||||
void draw::Image::Circle(etk::Vector2D<float> pos, float radius, float angleStart, float angleStop)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void draw::Image::Disc(Vector2D<float> pos, float radius, float angleStart, float angleStop)
|
||||
void draw::Image::Disc(etk::Vector2D<float> pos, float radius, float angleStart, float angleStop)
|
||||
{
|
||||
|
||||
}
|
||||
@ -274,10 +274,10 @@ void draw::Image::Disc(Vector2D<float> pos, float radius, float angleStart, floa
|
||||
void Grid::GenerateSDF()
|
||||
{
|
||||
// Pass 0
|
||||
Vector2D<int32_t> tmpPos;
|
||||
etk::Vector2D<int32_t> tmpPos;
|
||||
for (tmpPos.y=1 ; tmpPos.y<m_size.y-1 ; tmpPos.y++) {
|
||||
for (tmpPos.x=1 ; tmpPos.x<m_size.x-1 ; tmpPos.x++) {
|
||||
Vector2D<int32_t> p = Get(tmpPos);
|
||||
etk::Vector2D<int32_t> 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<int32_t> p = Get(tmpPos);
|
||||
etk::Vector2D<int32_t> 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<int32_t> p = Get(tmpPos);
|
||||
etk::Vector2D<int32_t> 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<m_size.x-1 ; tmpPos.x++) {
|
||||
Vector2D<int32_t> p = Get(tmpPos);
|
||||
etk::Vector2D<int32_t> 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<int32_t>(0,0), m_size);
|
||||
DistanceField(etk::Vector2D<int32_t>(0,0), m_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define META_DIST (8)
|
||||
void draw::Image::DistanceField(Vector2D<int32_t> pos, Vector2D<int32_t> size, int32_t upscaler, int32_t startPos)
|
||||
void draw::Image::DistanceField(etk::Vector2D<int32_t> pos, etk::Vector2D<int32_t> 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<int32_t> tmpPos;
|
||||
etk::Vector2D<int32_t> tmpPos;
|
||||
// generate distance system ... matrix ...
|
||||
Grid grid2(Vector2D<int32_t>(META_DIST*2,META_DIST*2));
|
||||
Grid grid2(etk::Vector2D<int32_t>(META_DIST*2,META_DIST*2));
|
||||
for(tmpPos.y=0 ; tmpPos.y<META_DIST*2 ; tmpPos.y++ ) {
|
||||
for(tmpPos.x=0 ; tmpPos.x<META_DIST*2 ; tmpPos.x++ ) {
|
||||
int32_t val = 1000.0*sqrt((tmpPos.x-META_DIST)*(tmpPos.x-META_DIST) + (tmpPos.y-META_DIST)*(tmpPos.y-META_DIST));
|
||||
@ -351,14 +351,14 @@ void draw::Image::DistanceField(Vector2D<int32_t> pos, Vector2D<int32_t> size, i
|
||||
// when out no distance find ...
|
||||
grid1.SetErrorVal(insideOrOutsideCurrentPixel);
|
||||
|
||||
Vector2D<int32_t> tmpPos2;
|
||||
etk::Vector2D<int32_t> tmpPos2;
|
||||
int32_t newDist = 50000000;
|
||||
for(tmpPos2.y=-META_DIST ; tmpPos2.y<META_DIST ; tmpPos2.y++ ) {
|
||||
for(tmpPos2.x=-META_DIST ; tmpPos2.x<META_DIST ; tmpPos2.x++ ) {
|
||||
// we have an opposite factor ...
|
||||
if (insideOrOutsideCurrentPixel != grid1.Get(tmpPos+tmpPos2)) {
|
||||
// get new distance
|
||||
int32_t tmpDist = grid2.Get(tmpPos2 + Vector2D<int32_t>(META_DIST,META_DIST));
|
||||
int32_t tmpDist = grid2.Get(tmpPos2 + etk::Vector2D<int32_t>(META_DIST,META_DIST));
|
||||
if (newDist > tmpDist) {
|
||||
newDist = tmpDist;
|
||||
}
|
||||
@ -384,7 +384,7 @@ void draw::Image::DistanceField(Vector2D<int32_t> pos, Vector2D<int32_t> size, i
|
||||
grid1.SetErrorVal(0);
|
||||
grid2.SetErrorVal(500000);
|
||||
|
||||
Vector2D<int32_t> tmpPos;
|
||||
etk::Vector2D<int32_t> tmpPos;
|
||||
for(tmpPos.y=0 ; tmpPos.y<size.y ; tmpPos.y++ ) {
|
||||
for(tmpPos.x=0 ; tmpPos.x<size.x ; tmpPos.x++ ) {
|
||||
draw::Color tmpColor = Get(pos+tmpPos);
|
||||
@ -405,8 +405,8 @@ void draw::Image::DistanceField(Vector2D<int32_t> pos, Vector2D<int32_t> size, i
|
||||
|
||||
for(tmpPos.y=startPos ; tmpPos.y<size.y ; tmpPos.y+=upscaler ) {
|
||||
for(tmpPos.x=startPos ; tmpPos.x<size.x ; tmpPos.x+=upscaler ) {
|
||||
Vector2D<int32_t> elem1 = grid1.Get(tmpPos);
|
||||
Vector2D<int32_t> elem2 = grid2.Get(tmpPos);
|
||||
etk::Vector2D<int32_t> elem1 = grid1.Get(tmpPos);
|
||||
etk::Vector2D<int32_t> elem2 = grid2.Get(tmpPos);
|
||||
// Calculate the actual distance from the x/y
|
||||
float dist1 = sqrt( (double)elem1.QuadDist() );
|
||||
float dist2 = sqrt( (double)elem2.QuadDist() );
|
||||
|
78
draw/Image.h
78
draw/Image.h
@ -48,11 +48,11 @@
|
||||
class Grid
|
||||
{
|
||||
public:
|
||||
Vector2D<int32_t> m_size;
|
||||
etk::Vector2D<int32_t> m_size;
|
||||
etk::Vector<int32_t > m_data;
|
||||
int32_t m_outsideVal;
|
||||
int32_t m_errorVal;
|
||||
Grid(Vector2D<int32_t> size)
|
||||
Grid(etk::Vector2D<int32_t> size)
|
||||
{
|
||||
m_size = size;
|
||||
m_outsideVal = 20;
|
||||
@ -71,14 +71,14 @@ class Grid
|
||||
{
|
||||
m_errorVal = newVal;
|
||||
}
|
||||
void SetInide(Vector2D<int32_t> pos)
|
||||
void SetInide(etk::Vector2D<int32_t> pos)
|
||||
{
|
||||
if( pos.x>=0 && pos.x<m_size.x
|
||||
&& pos.y>=0 && pos.y<m_size.y) {
|
||||
m_data[pos.x+pos.y*m_size.x]=0;
|
||||
}
|
||||
};
|
||||
void SetOutside(Vector2D<int32_t> pos)
|
||||
void SetOutside(etk::Vector2D<int32_t> pos)
|
||||
{
|
||||
if( pos.x>=0 && pos.x<m_size.x
|
||||
&& pos.y>=0 && pos.y<m_size.y) {
|
||||
@ -86,7 +86,7 @@ class Grid
|
||||
}
|
||||
};
|
||||
|
||||
int32_t Get(Vector2D<int32_t> pos)
|
||||
int32_t Get(etk::Vector2D<int32_t> pos)
|
||||
{
|
||||
;
|
||||
if( pos.x>0 && pos.x<m_size.x
|
||||
@ -96,7 +96,7 @@ class Grid
|
||||
return m_errorVal;
|
||||
};
|
||||
|
||||
void Set(Vector2D<int32_t> pos, int32_t val)
|
||||
void Set(etk::Vector2D<int32_t> pos, int32_t val)
|
||||
{
|
||||
if( pos.x>0 && pos.x<m_size.x
|
||||
&& pos.y>0 && pos.y<m_size.y) {
|
||||
@ -109,17 +109,17 @@ class Grid
|
||||
class Grid
|
||||
{
|
||||
public:
|
||||
Vector2D<int32_t> m_size;
|
||||
etk::Vector<Vector2D<int32_t> > m_data;
|
||||
int32_t m_outsideVal;
|
||||
int32_t m_errorVal;
|
||||
Grid(Vector2D<int32_t> size)
|
||||
etk::Vector2D<int32_t> m_size;
|
||||
etk::Vector<etk::Vector2D<int32_t> > m_data;
|
||||
int32_t m_outsideVal;
|
||||
int32_t m_errorVal;
|
||||
Grid(etk::Vector2D<int32_t> size)
|
||||
{
|
||||
m_size = size;
|
||||
m_outsideVal = 20;
|
||||
m_errorVal = 0;
|
||||
// basic element :
|
||||
Vector2D<int32_t> tmpPoint(0,0);
|
||||
etk::Vector2D<int32_t> 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<int32_t> pos)
|
||||
void SetInide(etk::Vector2D<int32_t> pos)
|
||||
{
|
||||
//if( pos.x>=0 && pos.x<m_size.x
|
||||
// && pos.y>=0 && pos.y<m_size.y) {
|
||||
@ -140,7 +140,7 @@ class Grid
|
||||
m_data[pos.x+pos.y*m_size.x].y=0;
|
||||
//}
|
||||
};
|
||||
void SetOutside(Vector2D<int32_t> pos)
|
||||
void SetOutside(etk::Vector2D<int32_t> pos)
|
||||
{
|
||||
//if( pos.x>=0 && pos.x<m_size.x
|
||||
// && pos.y>=0 && pos.y<m_size.y) {
|
||||
@ -149,16 +149,16 @@ class Grid
|
||||
//}
|
||||
};
|
||||
|
||||
Vector2D<int32_t> Get(Vector2D<int32_t> pos)
|
||||
etk::Vector2D<int32_t> Get(etk::Vector2D<int32_t> pos)
|
||||
{
|
||||
//if( pos.x>0 && pos.x<m_size.x
|
||||
// && pos.y>0 && pos.y<m_size.y) {
|
||||
return m_data[pos.x+pos.y*m_size.x];
|
||||
//}
|
||||
//return Vector2D<int32_t>(m_errorVal,m_errorVal);
|
||||
//return etk::Vector2D<int32_t>(m_errorVal,m_errorVal);
|
||||
};
|
||||
|
||||
void Set(Vector2D<int32_t> pos, Vector2D<int32_t> val)
|
||||
void Set(etk::Vector2D<int32_t> pos, etk::Vector2D<int32_t> val)
|
||||
{
|
||||
//if( pos.x>0 && pos.x<m_size.x
|
||||
// && pos.y>0 && pos.y<m_size.y) {
|
||||
@ -166,11 +166,11 @@ class Grid
|
||||
//}
|
||||
};
|
||||
|
||||
void Compare(Vector2D<int32_t> &p, Vector2D<int32_t> pos, int32_t offsetx, int32_t offsety )
|
||||
void Compare(etk::Vector2D<int32_t> &p, etk::Vector2D<int32_t> pos, int32_t offsetx, int32_t offsety )
|
||||
{
|
||||
pos.x += offsetx;
|
||||
pos.y += offsety;
|
||||
Vector2D<int32_t> other = Get(pos);
|
||||
etk::Vector2D<int32_t> other = Get(pos);
|
||||
other.x += offsetx;
|
||||
other.y += offsety;
|
||||
if (other.QuadDist() < p.QuadDist()) {
|
||||
@ -191,7 +191,7 @@ namespace draw
|
||||
|
||||
class Image {
|
||||
private:
|
||||
Vector2D<int32_t> m_size;
|
||||
etk::Vector2D<int32_t> m_size;
|
||||
etk::Vector<draw::Color> 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<int32_t> size);
|
||||
Image(etk::Vector2D<int32_t> size);
|
||||
Image(void);
|
||||
// destructor
|
||||
~Image(void);
|
||||
@ -220,10 +220,10 @@ namespace draw
|
||||
// -- basic tools :
|
||||
// -----------------------------------------------
|
||||
public :
|
||||
void Resize(Vector2D<int32_t> size);
|
||||
//void Resize(Vector2D<int32_t> startPos, Vector2D<int32_t> size);
|
||||
void Resize(etk::Vector2D<int32_t> size);
|
||||
//void Resize(etk::Vector2D<int32_t> startPos, Vector2D<int32_t> size);
|
||||
|
||||
Vector2D<int32_t> GetSize(void) const
|
||||
etk::Vector2D<int32_t> GetSize(void) const
|
||||
{
|
||||
return m_size;
|
||||
};
|
||||
@ -236,7 +236,7 @@ namespace draw
|
||||
return m_size.y;
|
||||
};
|
||||
|
||||
//void Move(Vector2D<int32_t> pos);
|
||||
//void Move(etk::Vector2D<int32_t> pos);
|
||||
|
||||
//void Rotate(float angle); // radian
|
||||
|
||||
@ -254,7 +254,7 @@ namespace draw
|
||||
|
||||
//Image & operator= (const Image &image)
|
||||
|
||||
draw::Color Get(Vector2D<int32_t> pos)
|
||||
draw::Color Get(etk::Vector2D<int32_t> pos)
|
||||
{
|
||||
draw::Color outColor(0x00000000);
|
||||
if( pos.x>0 && pos.x<m_size.x
|
||||
@ -264,7 +264,7 @@ namespace draw
|
||||
return outColor;
|
||||
}
|
||||
|
||||
void Set(Vector2D<int32_t> pos, draw::Color newColor)
|
||||
void Set(etk::Vector2D<int32_t> pos, draw::Color newColor)
|
||||
{
|
||||
if( pos.x>=0 && pos.x<m_size.x
|
||||
&& pos.y>=0 && pos.y<m_size.y) {
|
||||
@ -272,9 +272,9 @@ namespace draw
|
||||
}
|
||||
}
|
||||
|
||||
//Image GetSubImage(Vector2D<int32_t> startPos, Vector2D<int32_t> size) const;
|
||||
//Image GetSubImage(etk::Vector2D<int32_t> startPos, Vector2D<int32_t> size) const;
|
||||
|
||||
//void SetData(uint8_t *data, Vector2D<int32_t> size);
|
||||
//void SetData(uint8_t *data, etk::Vector2D<int32_t> size);
|
||||
|
||||
// -----------------------------------------------
|
||||
// -- Drawing tools :
|
||||
@ -291,21 +291,21 @@ namespace draw
|
||||
void SetStrokeSize(float thickness) {
|
||||
m_strokeSize = thickness;
|
||||
}
|
||||
void MoveTo(Vector2D<float> pos);
|
||||
void MoveToAbs(Vector2D<float> pos);
|
||||
void LineTo(Vector2D<float> pos);
|
||||
void LineToAbs(Vector2D<float> pos);
|
||||
void MoveTo(etk::Vector2D<float> pos);
|
||||
void MoveToAbs(etk::Vector2D<float> pos);
|
||||
void LineTo(etk::Vector2D<float> pos);
|
||||
void LineToAbs(etk::Vector2D<float> pos);
|
||||
void Join(void);
|
||||
void Draw(void);
|
||||
|
||||
void Line(Vector2D<float> posStart, Vector2D<float> posEnd);
|
||||
void Dot(Vector2D<float> pos);
|
||||
void Rectangle(Vector2D<float> pos, Vector2D<float> size);
|
||||
void Circle(Vector2D<float> pos, float radius, float angleStart=0, float angleStop=2*M_PI);
|
||||
void Disc(Vector2D<float> pos, float radius, float angleStart=0, float angleStop=2*M_PI);
|
||||
void Line(etk::Vector2D<float> posStart, etk::Vector2D<float> posEnd);
|
||||
void Dot(etk::Vector2D<float> pos);
|
||||
void Rectangle(etk::Vector2D<float> pos, etk::Vector2D<float> size);
|
||||
void Circle(etk::Vector2D<float> pos, float radius, float angleStart=0, float angleStop=2*M_PI);
|
||||
void Disc(etk::Vector2D<float> 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<int32_t> pos, Vector2D<int32_t> size, int32_t upscaler=1, int32_t startPos=0);
|
||||
void DistanceField(etk::Vector2D<int32_t> pos, etk::Vector2D<int32_t> size, int32_t upscaler=1, int32_t startPos=0);
|
||||
|
||||
void SaveFile(const char * file) {};
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user