[DEV] change coding style
This commit is contained in:
parent
64280cda08
commit
ed0661317b
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
* @file draw/Color.h
|
* @file draw/Color.h
|
||||||
* @brief Ewol Tool Kit : basic colors
|
* @brief Ewol tool Kit : basic colors
|
||||||
* @author Edouard DUPIN
|
* @author Edouard DUPIN
|
||||||
* @date 23/04/2012
|
* @date 23/04/2012
|
||||||
* @par Project
|
* @par Project
|
||||||
@ -362,7 +362,7 @@ static bool strnCmpNoCase(const char * input1, const char * input2, int32_t maxL
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void draw::ParseColor(const char* _input, struct agg::rgba8& color)
|
void draw::parseColor(const char* _input, struct agg::rgba8& color)
|
||||||
{
|
{
|
||||||
color = draw::color::white;
|
color = draw::color::white;
|
||||||
if (NULL == _input) {
|
if (NULL == _input) {
|
||||||
@ -385,7 +385,7 @@ void draw::ParseColor(const char* _input, struct agg::rgba8& color)
|
|||||||
} else {
|
} else {
|
||||||
TK_ERROR(" pb in parsing the color : \"" << inputData << "\"");
|
TK_ERROR(" pb in parsing the color : \"" << inputData << "\"");
|
||||||
}
|
}
|
||||||
} else if (len==5) {
|
} else if (len == 5) {
|
||||||
int32_t red=0, green=0, blue=0, alpha=0;
|
int32_t red=0, green=0, blue=0, alpha=0;
|
||||||
if (sscanf(inputData + 1, "%1x%1x%1x%1x", &red, &green, &blue, &alpha) == 4) {
|
if (sscanf(inputData + 1, "%1x%1x%1x%1x", &red, &green, &blue, &alpha) == 4) {
|
||||||
color.r = (red | red << 4);
|
color.r = (red | red << 4);
|
||||||
@ -415,7 +415,7 @@ void draw::ParseColor(const char* _input, struct agg::rgba8& color)
|
|||||||
TK_ERROR(" pb in parsing the color : \"" << inputData << "\"");
|
TK_ERROR(" pb in parsing the color : \"" << inputData << "\"");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TK_ERROR(" pb in parsing the color : \"" << inputData << "\" ==> unknown methode ...");
|
TK_ERROR(" pb in parsing the color : \"" << inputData << "\" == > unknown methode ...");
|
||||||
}
|
}
|
||||||
} else if( 4 <= len
|
} else if( 4 <= len
|
||||||
&& inputData[0] == 'r'
|
&& inputData[0] == 'r'
|
||||||
@ -450,7 +450,7 @@ void draw::ParseColor(const char* _input, struct agg::rgba8& color)
|
|||||||
color.g = (uint8_t)(fgreen * 255.);
|
color.g = (uint8_t)(fgreen * 255.);
|
||||||
color.b = (uint8_t)(fblue * 255.);
|
color.b = (uint8_t)(fblue * 255.);
|
||||||
} else {
|
} else {
|
||||||
TK_ERROR(" pb in parsing the color : \"" << inputData << "\" ==> unknown methode ...");
|
TK_ERROR(" pb in parsing the color : \"" << inputData << "\" == > unknown methode ...");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bool findIt = false;
|
bool findIt = false;
|
||||||
@ -468,7 +468,7 @@ void draw::ParseColor(const char* _input, struct agg::rgba8& color)
|
|||||||
TK_ERROR(" pb in parsing the color : \"" << inputData << "\" not find ...");
|
TK_ERROR(" pb in parsing the color : \"" << inputData << "\" not find ...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TK_VERBOSE("Parse color : \"" << inputData << "\" ==> " << color);
|
TK_VERBOSE("Parse color : \"" << inputData << "\" == > " << color);
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& agg::operator <<(etk::CCout &os, const struct agg::rgba8& obj)
|
etk::CCout& agg::operator <<(etk::CCout &os, const struct agg::rgba8& obj)
|
||||||
@ -480,14 +480,14 @@ etk::CCout& agg::operator <<(etk::CCout &os, const struct agg::rgba8& obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
etk::UString draw::GetHexString(const draw::Color& color)
|
etk::UString draw::getHexString(const draw::Color& color)
|
||||||
{
|
{
|
||||||
char colorText[256];
|
char colorText[256];
|
||||||
sprintf(colorText, "0x%08X", color.Get());
|
sprintf(colorText, "0x%08X", color.Get());
|
||||||
return colorText;
|
return colorText;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::UString draw::GetString(const draw::Color& color)
|
etk::UString draw::getString(const draw::Color& color)
|
||||||
{
|
{
|
||||||
char colorText[256];
|
char colorText[256];
|
||||||
sprintf(colorText, "#%08X", color.Get());
|
sprintf(colorText, "#%08X", color.Get());
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
* @file draw/Color.h
|
* @file draw/Color.h
|
||||||
* @brief Ewol Tool Kit : basic colors
|
* @brief Ewol tool Kit : basic colors
|
||||||
* @author Edouard DUPIN
|
* @author Edouard DUPIN
|
||||||
* @date 23/04/2012
|
* @date 23/04/2012
|
||||||
* @par Project
|
* @par Project
|
||||||
@ -83,9 +83,9 @@ namespace draw {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
void ParseColor(const char* _input, struct agg::rgba8& color);
|
void parseColor(const char* _input, struct agg::rgba8& color);
|
||||||
etk::UString GetHexString(const draw::Color& color);
|
etk::UString getHexString(const draw::Color& color);
|
||||||
etk::UString GetString(const draw::Color& color);
|
etk::UString getString(const draw::Color& color);
|
||||||
|
|
||||||
namespace color {
|
namespace color {
|
||||||
extern const Color none;
|
extern const Color none;
|
||||||
|
@ -57,8 +57,8 @@ void draw::Image::Init(void)
|
|||||||
// basic element :
|
// basic element :
|
||||||
draw::Color tmpBg(0,0,0,0);
|
draw::Color tmpBg(0,0,0,0);
|
||||||
// preallocate data with a basic bg elements :
|
// preallocate data with a basic bg elements :
|
||||||
m_data.ReSize(m_size.x()*m_size.y(), tmpBg);
|
m_data.reSize(m_size.x()*m_size.y(), tmpBg);
|
||||||
if (m_size.x()*m_size.y() > m_data.Size()) {
|
if (m_size.x()*m_size.y() > m_data.size()) {
|
||||||
DRAW_ERROR("Allocation of data buffer in error");
|
DRAW_ERROR("Allocation of data buffer in error");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -142,8 +142,8 @@ void draw::Image::Resize(ivec2 size)
|
|||||||
// basic element :
|
// basic element :
|
||||||
draw::Color tmpBg(0,0,0,0);
|
draw::Color tmpBg(0,0,0,0);
|
||||||
// preallocate data with a basic bg elements :
|
// preallocate data with a basic bg elements :
|
||||||
m_data.ReSize(m_size.x()*m_size.y(), tmpBg);
|
m_data.reSize(m_size.x()*m_size.y(), tmpBg);
|
||||||
if (m_size.x()*m_size.y() > m_data.Size()) {
|
if (m_size.x()*m_size.y() > m_data.size()) {
|
||||||
DRAW_ERROR("Allocation of data buffer in error");
|
DRAW_ERROR("Allocation of data buffer in error");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ void draw::Image::Join(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
// generate the display
|
// generate the display
|
||||||
void draw::Image::Draw(void)
|
void draw::Image::draw(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -234,7 +234,7 @@ void draw::Image::Dot(vec2 pos)
|
|||||||
LineTo(pos+etk::Vector2D<float>(1,1));
|
LineTo(pos+etk::Vector2D<float>(1,1));
|
||||||
End();
|
End();
|
||||||
*/
|
*/
|
||||||
Set(pos, m_fillColor);
|
set(pos, m_fillColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw::Image::Line(vec2 posStart, vec2 posEnd)
|
void draw::Image::Line(vec2 posStart, vec2 posEnd)
|
||||||
@ -271,39 +271,39 @@ void draw::Image::Disc(vec2 pos, float radius, float angleStart, float angleStop
|
|||||||
}
|
}
|
||||||
#ifdef BASIC_GRADIENT
|
#ifdef BASIC_GRADIENT
|
||||||
|
|
||||||
void Grid::GenerateSDF()
|
void Grid::generateSDF()
|
||||||
{
|
{
|
||||||
// Pass 0
|
// Pass 0
|
||||||
ivec2 tmpPos(1,1);
|
ivec2 tmpPos(1,1);
|
||||||
for (tmpPos.setY(1) ; tmpPos.y()<m_size.y()-1 ; tmpPos+=vec2(0,1)) {
|
for (tmpPos.setY(1) ; tmpPos.y()<m_size.y()-1 ; tmpPos+=vec2(0,1)) {
|
||||||
for (tmpPos.setX(1) ; tmpPos.x()<m_size.x()-1 ; tmpPos+=vec2(1,0) ) {
|
for (tmpPos.setX(1) ; tmpPos.x()<m_size.x()-1 ; tmpPos+=vec2(1,0) ) {
|
||||||
ivec2 p = Get(tmpPos);
|
ivec2 p = get(tmpPos);
|
||||||
Compare(p, tmpPos, -1, 0 );
|
Compare(p, tmpPos, -1, 0 );
|
||||||
Compare(p, tmpPos, 0, -1 );
|
Compare(p, tmpPos, 0, -1 );
|
||||||
Compare(p, tmpPos, -1, -1 );
|
Compare(p, tmpPos, -1, -1 );
|
||||||
Compare(p, tmpPos, 1, -1 );
|
Compare(p, tmpPos, 1, -1 );
|
||||||
Set(tmpPos, p);
|
set(tmpPos, p);
|
||||||
}
|
}
|
||||||
for (tmpPos.setX(m_size.x()-2) ; tmpPos.x()>0 ; tmpPos-=vec2(1,0) ) {
|
for (tmpPos.setX(m_size.x()-2) ; tmpPos.x()>0 ; tmpPos-=vec2(1,0) ) {
|
||||||
ivec2 p = Get(tmpPos);
|
ivec2 p = get(tmpPos);
|
||||||
Compare(p, tmpPos, 1, 0 );
|
Compare(p, tmpPos, 1, 0 );
|
||||||
Set(tmpPos, p );
|
set(tmpPos, p );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Pass 1
|
// Pass 1
|
||||||
for (tmpPos.setY(m_size.y()-2) ; tmpPos.y()>0 ; tmpPos-=vec2(0,1)) {
|
for (tmpPos.setY(m_size.y()-2) ; tmpPos.y()>0 ; tmpPos-=vec2(0,1)) {
|
||||||
for (tmpPos.setX(m_size.x()-2) ; tmpPos.x()>1 ; tmpPos-=vec2(1,0)) {
|
for (tmpPos.setX(m_size.x()-2) ; tmpPos.x()>1 ; tmpPos-=vec2(1,0)) {
|
||||||
ivec2 p = Get(tmpPos);
|
ivec2 p = get(tmpPos);
|
||||||
Compare(p, tmpPos, 1, 0 );
|
Compare(p, tmpPos, 1, 0 );
|
||||||
Compare(p, tmpPos, 0, 1 );
|
Compare(p, tmpPos, 0, 1 );
|
||||||
Compare(p, tmpPos, -1, 1 );
|
Compare(p, tmpPos, -1, 1 );
|
||||||
Compare(p, tmpPos, 1, 1 );
|
Compare(p, tmpPos, 1, 1 );
|
||||||
Set(tmpPos, p);
|
set(tmpPos, p);
|
||||||
}
|
}
|
||||||
for (tmpPos.setX(1) ; tmpPos.x()<m_size.x()-1 ; tmpPos+=vec2(1,0)) {
|
for (tmpPos.setX(1) ; tmpPos.x()<m_size.x()-1 ; tmpPos+=vec2(1,0)) {
|
||||||
ivec2 p = Get(tmpPos);
|
ivec2 p = get(tmpPos);
|
||||||
Compare(p, tmpPos, -1, 0 );
|
Compare(p, tmpPos, -1, 0 );
|
||||||
Set(tmpPos, p);
|
set(tmpPos, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,38 +327,38 @@ void draw::Image::DistanceField(ivec2 pos, ivec2 size, int32_t upscaler, int32_t
|
|||||||
for(tmpPos.setY(0) ; tmpPos.y()<META_DIST*2 ; tmpPos+=vec2(0,1) ) {
|
for(tmpPos.setY(0) ; tmpPos.y()<META_DIST*2 ; tmpPos+=vec2(0,1) ) {
|
||||||
for(tmpPos.setX(0) ; tmpPos.x<META_DIST*2 ; tmpPos+=vec2(1,0) ) {
|
for(tmpPos.setX(0) ; tmpPos.x<META_DIST*2 ; tmpPos+=vec2(1,0) ) {
|
||||||
int32_t val = 1000.0*sqrtf((tmpPos.x()-META_DIST)*(tmpPos.x()-META_DIST) + (tmpPos.y()-META_DIST)*(tmpPos.y()-META_DIST));
|
int32_t val = 1000.0*sqrtf((tmpPos.x()-META_DIST)*(tmpPos.x()-META_DIST) + (tmpPos.y()-META_DIST)*(tmpPos.y()-META_DIST));
|
||||||
grid2.Set(tmpPos, val);
|
grid2.set(tmpPos, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Grid grid1(size);
|
Grid grid1(size);
|
||||||
grid1.SetErrorVal(0);
|
grid1.setErrorVal(0);
|
||||||
|
|
||||||
for(tmpPos.setY(0) ; tmpPos.y()<size.y() ; tmpPos+=vec2(0,1) ) {
|
for(tmpPos.setY(0) ; tmpPos.y()<size.y() ; tmpPos+=vec2(0,1) ) {
|
||||||
for(tmpPos.setX(0) ; tmpPos.x<size.x() ; tmpPos+=vec2(1,0) ) {
|
for(tmpPos.setX(0) ; tmpPos.x<size.x() ; tmpPos+=vec2(1,0) ) {
|
||||||
draw::Color tmpColor = Get(pos+tmpPos);
|
draw::Color tmpColor = get(pos+tmpPos);
|
||||||
// Points inside get marked with a x/y of zero.
|
// Points inside get marked with a x/y of zero.
|
||||||
// Points outside get marked with an infinitely large distance.
|
// Points outside get marked with an infinitely large distance.
|
||||||
if (tmpColor.a<=0x7F) {
|
if (tmpColor.a<=0x7F) {
|
||||||
grid1.SetInide(tmpPos);
|
grid1.setInide(tmpPos);
|
||||||
} else {
|
} else {
|
||||||
grid1.SetOutside(tmpPos);
|
grid1.setOutside(tmpPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(tmpPos.setY(startPos) ; tmpPos.y()<size.y() ; tmpPos+=vec2(0,upscaler) ) {
|
for(tmpPos.setY(startPos) ; tmpPos.y()<size.y() ; tmpPos+=vec2(0,upscaler) ) {
|
||||||
for(tmpPos.setX(startPos) ; tmpPos.x<size.x() ; tmpPos+=vec2(upscaler,0) ) {
|
for(tmpPos.setX(startPos) ; tmpPos.x<size.x() ; tmpPos+=vec2(upscaler,0) ) {
|
||||||
int32_t insideOrOutsideCurrentPixel = grid1.Get(tmpPos);
|
int32_t insideOrOutsideCurrentPixel = grid1.get(tmpPos);
|
||||||
// when out no distance find ...
|
// when out no distance find ...
|
||||||
grid1.SetErrorVal(insideOrOutsideCurrentPixel);
|
grid1.setErrorVal(insideOrOutsideCurrentPixel);
|
||||||
|
|
||||||
ivec2 tmpPos2;
|
ivec2 tmpPos2;
|
||||||
int32_t newDist = 50000000;
|
int32_t newDist = 50000000;
|
||||||
for(tmpPos2.setY(-META_DIST) ; tmpPos2.y()<META_DIST ; tmpPos+=vec2(0,1) ) {
|
for(tmpPos2.setY(-META_DIST) ; tmpPos2.y()<META_DIST ; tmpPos+=vec2(0,1) ) {
|
||||||
for(tmpPos2.setX(-META_DIST) ; tmpPos2.x()<META_DIST ; tmpPos+=vec2(1,0) ) {
|
for(tmpPos2.setX(-META_DIST) ; tmpPos2.x()<META_DIST ; tmpPos+=vec2(1,0) ) {
|
||||||
// we have an opposite factor ...
|
// we have an opposite factor ...
|
||||||
if (insideOrOutsideCurrentPixel != grid1.Get(tmpPos+tmpPos2)) {
|
if (insideOrOutsideCurrentPixel != grid1.get(tmpPos+tmpPos2)) {
|
||||||
// get new distance
|
// get new distance
|
||||||
int32_t tmpDist = grid2.Get(tmpPos2 + ivec2(META_DIST,META_DIST));
|
int32_t tmpDist = grid2.get(tmpPos2 + ivec2(META_DIST,META_DIST));
|
||||||
if (newDist > tmpDist) {
|
if (newDist > tmpDist) {
|
||||||
newDist = tmpDist;
|
newDist = tmpDist;
|
||||||
}
|
}
|
||||||
@ -366,47 +366,47 @@ void draw::Image::DistanceField(ivec2 pos, ivec2 size, int32_t upscaler, int32_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// set the finded distance :
|
// set the finded distance :
|
||||||
draw::Color tmpColor = Get(pos+tmpPos);
|
draw::Color tmpColor = get(pos+tmpPos);
|
||||||
float tmpValue = ((1.0-((float)newDist * maxVal)) * 0.5) * 128.0;
|
float tmpValue = ((1.0-((float)newDist * maxVal)) * 0.5) * 128.0;
|
||||||
if (tmpColor.a<=0x7F) {
|
if (tmpColor.a<=0x7F) {
|
||||||
tmpColor.a = etk_avg(0, tmpValue, 255);
|
tmpColor.a = etk_avg(0, tmpValue, 255);
|
||||||
} else {
|
} else {
|
||||||
tmpColor.a = etk_avg(0, 255-tmpValue, 255);
|
tmpColor.a = etk_avg(0, 255-tmpValue, 255);
|
||||||
}
|
}
|
||||||
Set(pos+tmpPos, tmpColor);
|
set(pos+tmpPos, tmpColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Grid grid1(size);
|
Grid grid1(size);
|
||||||
Grid grid2(size);
|
Grid grid2(size);
|
||||||
grid1.SetOutsideVal(500000);
|
grid1.setOutsideVal(500000);
|
||||||
grid2.SetOutsideVal(500000);
|
grid2.setOutsideVal(500000);
|
||||||
grid1.SetErrorVal(0);
|
grid1.setErrorVal(0);
|
||||||
grid2.SetErrorVal(500000);
|
grid2.setErrorVal(500000);
|
||||||
|
|
||||||
ivec2 tmpPos;
|
ivec2 tmpPos;
|
||||||
for(tmpPos.setY(0) ; tmpPos.y()<size.y() ; tmpPos+=vec2(0,1) ) {
|
for(tmpPos.setY(0) ; tmpPos.y()<size.y() ; tmpPos+=vec2(0,1) ) {
|
||||||
for(tmpPos.setX(0) ; tmpPos.x()<size.x() ; tmpPos+=vec2(1,0) ) {
|
for(tmpPos.setX(0) ; tmpPos.x()<size.x() ; tmpPos+=vec2(1,0) ) {
|
||||||
draw::Color tmpColor = Get(pos+tmpPos);
|
draw::Color tmpColor = get(pos+tmpPos);
|
||||||
// Points inside get marked with a x/y of zero.
|
// Points inside get marked with a x/y of zero.
|
||||||
// Points outside get marked with an infinitely large distance.
|
// Points outside get marked with an infinitely large distance.
|
||||||
if (tmpColor.a<=0x7F) {
|
if (tmpColor.a<=0x7F) {
|
||||||
grid1.SetInide(tmpPos);
|
grid1.setInide(tmpPos);
|
||||||
grid2.SetOutside(tmpPos);
|
grid2.setOutside(tmpPos);
|
||||||
} else {
|
} else {
|
||||||
grid2.SetInide(tmpPos);
|
grid2.setInide(tmpPos);
|
||||||
grid1.SetOutside(tmpPos);
|
grid1.setOutside(tmpPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Generate the SDF:
|
// generate the SDF:
|
||||||
grid1.GenerateSDF();
|
grid1.generateSDF();
|
||||||
grid2.GenerateSDF();
|
grid2.generateSDF();
|
||||||
|
|
||||||
for(tmpPos.setY(startPos) ; tmpPos.y()<size.y() ; tmpPos+=vec2(0,upscaler) ) {
|
for(tmpPos.setY(startPos) ; tmpPos.y()<size.y() ; tmpPos+=vec2(0,upscaler) ) {
|
||||||
for(tmpPos.setX(startPos) ; tmpPos.x()<size.x() ; tmpPos+=vec2(upscaler,0) ) {
|
for(tmpPos.setX(startPos) ; tmpPos.x()<size.x() ; tmpPos+=vec2(upscaler,0) ) {
|
||||||
ivec2 elem1 = grid1.Get(tmpPos);
|
ivec2 elem1 = grid1.get(tmpPos);
|
||||||
ivec2 elem2 = grid2.Get(tmpPos);
|
ivec2 elem2 = grid2.get(tmpPos);
|
||||||
// Calculate the actual distance from the x/y
|
// Calculate the actual distance from the x/y
|
||||||
float dist1 = elem1.length();
|
float dist1 = elem1.length();
|
||||||
float dist2 = elem2.length();
|
float dist2 = elem2.length();
|
||||||
@ -414,16 +414,16 @@ void draw::Image::DistanceField(ivec2 pos, ivec2 size, int32_t upscaler, int32_t
|
|||||||
/*
|
/*
|
||||||
if (tmpPos.y < 32) {
|
if (tmpPos.y < 32) {
|
||||||
if (tmpPos.x < 32) {
|
if (tmpPos.x < 32) {
|
||||||
DRAW_DEBUG( "generate Distance : " << dist1 << "," << dist2 << " ==> " << (dist*3 + 128));
|
DRAW_DEBUG( "generate Distance : " << dist1 << "," << dist2 << " == > " << (dist*3 + 128));
|
||||||
} else if (tmpPos.x == 32) {
|
} else if (tmpPos.x == 32) {
|
||||||
DRAW_DEBUG( " ---" );
|
DRAW_DEBUG( " ---" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
draw::Color tmpColor = Get(pos+tmpPos);
|
draw::Color tmpColor = get(pos+tmpPos);
|
||||||
// Clamp and scale it, just for display purposes.
|
// Clamp and scale it, just for display purposes.
|
||||||
tmpColor.a = etk_avg(0, (dist*3 + 128), 255);
|
tmpColor.a = etk_avg(0, (dist*3 + 128), 255);
|
||||||
Set(pos+tmpPos, tmpColor);
|
set(pos+tmpPos, tmpColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
60
draw/Image.h
60
draw/Image.h
@ -61,25 +61,25 @@ class Grid
|
|||||||
// basic element :
|
// basic element :
|
||||||
int32_t tmpPoint = 0;
|
int32_t tmpPoint = 0;
|
||||||
// preallocate data with a basic bg elements :
|
// preallocate data with a basic bg elements :
|
||||||
m_data.ReSize(m_size.x()*m_size.y(), tmpPoint);
|
m_data.reSize(m_size.x()*m_size.y(), tmpPoint);
|
||||||
};
|
};
|
||||||
~Grid(void) { };
|
~Grid(void) { };
|
||||||
void SetOutsideVal(int32_t newVal)
|
void setOutsideVal(int32_t newVal)
|
||||||
{
|
{
|
||||||
m_outsideVal = newVal;
|
m_outsideVal = newVal;
|
||||||
}
|
}
|
||||||
void SetErrorVal(int32_t newVal)
|
void setErrorVal(int32_t newVal)
|
||||||
{
|
{
|
||||||
m_errorVal = newVal;
|
m_errorVal = newVal;
|
||||||
}
|
}
|
||||||
void SetInide(etk::Vector2D<int32_t> pos)
|
void setInide(etk::Vector2D<int32_t> pos)
|
||||||
{
|
{
|
||||||
if( pos.x()>=0 && pos.x()<m_size.x()
|
if( pos.x()>=0 && pos.x()<m_size.x()
|
||||||
&& pos.y()>=0 && pos.y()<m_size.y()) {
|
&& pos.y()>=0 && pos.y()<m_size.y()) {
|
||||||
m_data[pos.x()+pos.y()*m_size.x()]=0;
|
m_data[pos.x()+pos.y()*m_size.x()]=0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
void SetOutside(etk::Vector2D<int32_t> pos)
|
void setOutside(etk::Vector2D<int32_t> pos)
|
||||||
{
|
{
|
||||||
if( pos.x()>=0 && pos.x()<m_size.x()
|
if( pos.x()>=0 && pos.x()<m_size.x()
|
||||||
&& pos.y()>=0 && pos.y()<m_size.y()) {
|
&& pos.y()>=0 && pos.y()<m_size.y()) {
|
||||||
@ -87,7 +87,7 @@ class Grid
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t Get(etk::Vector2D<int32_t> pos)
|
int32_t get(etk::Vector2D<int32_t> pos)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
if( pos.x()>0 && pos.x()<m_size.x()
|
if( pos.x()>0 && pos.x()<m_size.x()
|
||||||
@ -97,7 +97,7 @@ class Grid
|
|||||||
return m_errorVal;
|
return m_errorVal;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Set(etk::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()
|
if( pos.x()>0 && pos.x()<m_size.x()
|
||||||
&& pos.y()>0 && pos.y()<m_size.y()) {
|
&& pos.y()>0 && pos.y()<m_size.y()) {
|
||||||
@ -122,18 +122,18 @@ class Grid
|
|||||||
// basic element :
|
// basic element :
|
||||||
etk::Vector2D<int32_t> tmpPoint(0,0);
|
etk::Vector2D<int32_t> tmpPoint(0,0);
|
||||||
// preallocate data with a basic bg elements :
|
// preallocate data with a basic bg elements :
|
||||||
m_data.ReSize(m_size.x()*m_size.y(), tmpPoint);
|
m_data.reSize(m_size.x()*m_size.y(), tmpPoint);
|
||||||
};
|
};
|
||||||
~Grid(void) { };
|
~Grid(void) { };
|
||||||
void SetOutsideVal(int32_t newVal)
|
void setOutsideVal(int32_t newVal)
|
||||||
{
|
{
|
||||||
m_outsideVal = newVal;
|
m_outsideVal = newVal;
|
||||||
}
|
}
|
||||||
void SetErrorVal(int32_t newVal)
|
void setErrorVal(int32_t newVal)
|
||||||
{
|
{
|
||||||
m_errorVal = newVal;
|
m_errorVal = newVal;
|
||||||
}
|
}
|
||||||
void SetInide(ivec2 pos)
|
void setInide(ivec2 pos)
|
||||||
{
|
{
|
||||||
//if( pos.x>=0 && pos.x<m_size.x
|
//if( pos.x>=0 && pos.x<m_size.x
|
||||||
// && pos.y>=0 && pos.y<m_size.y) {
|
// && pos.y>=0 && pos.y<m_size.y) {
|
||||||
@ -141,7 +141,7 @@ class Grid
|
|||||||
m_data[pos.x()+pos.y()*m_size.x()].setY(0);
|
m_data[pos.x()+pos.y()*m_size.x()].setY(0);
|
||||||
//}
|
//}
|
||||||
};
|
};
|
||||||
void SetOutside(ivec2 pos)
|
void setOutside(ivec2 pos)
|
||||||
{
|
{
|
||||||
//if( pos.x>=0 && pos.x<m_size.x
|
//if( pos.x>=0 && pos.x<m_size.x
|
||||||
// && pos.y>=0 && pos.y<m_size.y) {
|
// && pos.y>=0 && pos.y<m_size.y) {
|
||||||
@ -150,7 +150,7 @@ class Grid
|
|||||||
//}
|
//}
|
||||||
};
|
};
|
||||||
|
|
||||||
ivec2 Get(ivec2 pos)
|
ivec2 get(ivec2 pos)
|
||||||
{
|
{
|
||||||
//if( pos.x>0 && pos.x<m_size.x
|
//if( pos.x>0 && pos.x<m_size.x
|
||||||
// && pos.y>0 && pos.y<m_size.y) {
|
// && pos.y>0 && pos.y<m_size.y) {
|
||||||
@ -159,7 +159,7 @@ class Grid
|
|||||||
//return etk::Vector2D<int32_t>(m_errorVal,m_errorVal);
|
//return etk::Vector2D<int32_t>(m_errorVal,m_errorVal);
|
||||||
};
|
};
|
||||||
|
|
||||||
void Set(ivec2 pos, ivec2 val)
|
void set(ivec2 pos, ivec2 val)
|
||||||
{
|
{
|
||||||
//if( pos.x>0 && pos.x<m_size.x
|
//if( pos.x>0 && pos.x<m_size.x
|
||||||
// && pos.y>0 && pos.y<m_size.y) {
|
// && pos.y>0 && pos.y<m_size.y) {
|
||||||
@ -170,13 +170,13 @@ class Grid
|
|||||||
void Compare(ivec2 &p, ivec2 pos, int32_t offsetx, int32_t offsety )
|
void Compare(ivec2 &p, ivec2 pos, int32_t offsetx, int32_t offsety )
|
||||||
{
|
{
|
||||||
pos += ivec2(offsetx,offsety);
|
pos += ivec2(offsetx,offsety);
|
||||||
ivec2 other = Get(pos);
|
ivec2 other = get(pos);
|
||||||
other += ivec2(offsetx,offsety);
|
other += ivec2(offsetx,offsety);
|
||||||
if (other.dot(p) < p.dot(p)) {
|
if (other.dot(p) < p.dot(p)) {
|
||||||
p = other;
|
p = other;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
void GenerateSDF(void);
|
void generateSDF(void);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ namespace draw
|
|||||||
|
|
||||||
// EWOL internal API for Texture system :
|
// EWOL internal API for Texture system :
|
||||||
public:
|
public:
|
||||||
void* GetTextureDataPointer(void) { return &m_data[0]; };
|
void* getTextureDataPointer(void) { return &m_data[0]; };
|
||||||
|
|
||||||
// -----------------------------------------------
|
// -----------------------------------------------
|
||||||
// -- basic tools :
|
// -- basic tools :
|
||||||
@ -222,15 +222,15 @@ namespace draw
|
|||||||
void Resize(ivec2 size);
|
void Resize(ivec2 size);
|
||||||
//void Resize(etk::Vector2D<int32_t> startPos, Vector2D<int32_t> size);
|
//void Resize(etk::Vector2D<int32_t> startPos, Vector2D<int32_t> size);
|
||||||
|
|
||||||
ivec2 GetSize(void) const
|
ivec2 getSize(void) const
|
||||||
{
|
{
|
||||||
return m_size;
|
return m_size;
|
||||||
};
|
};
|
||||||
int32_t GetWidth(void) const
|
int32_t getWidth(void) const
|
||||||
{
|
{
|
||||||
return m_size.x();
|
return m_size.x();
|
||||||
};
|
};
|
||||||
int32_t GetHeight(void) const
|
int32_t getHeight(void) const
|
||||||
{
|
{
|
||||||
return m_size.y();
|
return m_size.y();
|
||||||
};
|
};
|
||||||
@ -242,7 +242,7 @@ namespace draw
|
|||||||
//void Zoom(float coefficient);
|
//void Zoom(float coefficient);
|
||||||
|
|
||||||
|
|
||||||
void Clear(void)
|
void clear(void)
|
||||||
{
|
{
|
||||||
for (int32_t iii=0; iii<m_size.x()*m_size.y(); iii++) {
|
for (int32_t iii=0; iii<m_size.x()*m_size.y(); iii++) {
|
||||||
m_data[iii] = m_fillColor;
|
m_data[iii] = m_fillColor;
|
||||||
@ -253,7 +253,7 @@ namespace draw
|
|||||||
|
|
||||||
//Image & operator= (const Image &image)
|
//Image & operator= (const Image &image)
|
||||||
|
|
||||||
draw::Color Get(ivec2 pos)
|
draw::Color get(ivec2 pos)
|
||||||
{
|
{
|
||||||
draw::Color outColor(0x00000000);
|
draw::Color outColor(0x00000000);
|
||||||
if( pos.x()>0 && pos.x()<m_size.x()
|
if( pos.x()>0 && pos.x()<m_size.x()
|
||||||
@ -263,7 +263,7 @@ namespace draw
|
|||||||
return outColor;
|
return outColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set(ivec2 pos, draw::Color newColor)
|
void set(ivec2 pos, draw::Color newColor)
|
||||||
{
|
{
|
||||||
if( pos.x()>=0 && pos.x()<m_size.x()
|
if( pos.x()>=0 && pos.x()<m_size.x()
|
||||||
&& pos.y()>=0 && pos.y()<m_size.y()) {
|
&& pos.y()>=0 && pos.y()<m_size.y()) {
|
||||||
@ -271,23 +271,23 @@ namespace draw
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Image GetSubImage(etk::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, etk::Vector2D<int32_t> size);
|
//void setData(uint8_t *data, etk::Vector2D<int32_t> size);
|
||||||
|
|
||||||
// -----------------------------------------------
|
// -----------------------------------------------
|
||||||
// -- Drawing tools :
|
// -- drawing tools :
|
||||||
// -----------------------------------------------
|
// -----------------------------------------------
|
||||||
public :
|
public :
|
||||||
void Begin(void);
|
void Begin(void);
|
||||||
void End(void);
|
void End(void);
|
||||||
void SetFillColor(draw::Color newColor) {
|
void setFillColor(draw::Color newColor) {
|
||||||
m_fillColor = newColor;
|
m_fillColor = newColor;
|
||||||
}
|
}
|
||||||
void SetStrokeColor(draw::Color newColor) {
|
void setStrokeColor(draw::Color newColor) {
|
||||||
m_strokeColor = newColor;
|
m_strokeColor = newColor;
|
||||||
}
|
}
|
||||||
void SetStrokeSize(float thickness) {
|
void setStrokeSize(float thickness) {
|
||||||
m_strokeSize = thickness;
|
m_strokeSize = thickness;
|
||||||
}
|
}
|
||||||
void MoveTo(vec2 pos);
|
void MoveTo(vec2 pos);
|
||||||
@ -295,7 +295,7 @@ namespace draw
|
|||||||
void LineTo(vec2 pos);
|
void LineTo(vec2 pos);
|
||||||
void LineToAbs(vec2 pos);
|
void LineToAbs(vec2 pos);
|
||||||
void Join(void);
|
void Join(void);
|
||||||
void Draw(void);
|
void draw(void);
|
||||||
|
|
||||||
void Line(vec2 posStart, vec2 posEnd);
|
void Line(vec2 posStart, vec2 posEnd);
|
||||||
void Dot(vec2 pos);
|
void Dot(vec2 pos);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user