Draw now a simple circle
This commit is contained in:
parent
76ceb4a67d
commit
061037ab67
@ -185,7 +185,60 @@ void ewol::OObject2DColored::Rectangle(float x, float y, float w, float h)
|
||||
|
||||
void ewol::OObject2DColored::Circle(float x, float y, float radius, float thickness)
|
||||
{
|
||||
|
||||
coord2D_ts point;
|
||||
if (radius<0) {
|
||||
radius *= -1;
|
||||
}
|
||||
if (radius < thickness/2) {
|
||||
Disc(x, y, thickness/2 + radius);
|
||||
}
|
||||
int32_t nbOcurence = radius*2;
|
||||
if (nbOcurence < 10)
|
||||
{
|
||||
nbOcurence = 10;
|
||||
}
|
||||
for (int32_t iii=0; iii<nbOcurence; iii++) {
|
||||
|
||||
double angleOne = 2*M_PI* iii / nbOcurence ;
|
||||
double offsetExty = sin(angleOne) * (radius+thickness/2);
|
||||
double offsetExtx = cos(angleOne) * (radius+thickness/2);
|
||||
double offsetInty = sin(angleOne) * (radius-thickness/2);
|
||||
double offsetIntx = cos(angleOne) * (radius-thickness/2);
|
||||
|
||||
double angleTwo = 2*M_PI* (iii+1) / nbOcurence ;
|
||||
double offsetExt2y = sin(angleTwo) * (radius+thickness/2);
|
||||
double offsetExt2x = cos(angleTwo) * (radius+thickness/2);
|
||||
double offsetInt2y = sin(angleTwo) * (radius-thickness/2);
|
||||
double offsetInt2x = cos(angleTwo) * (radius-thickness/2);
|
||||
|
||||
point.x = x + offsetIntx;
|
||||
point.y = y + offsetInty;
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(m_Color);
|
||||
|
||||
point.x = x + offsetExtx;
|
||||
point.y = y + offsetExty;
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(m_Color);
|
||||
|
||||
point.x = x + offsetExt2x;
|
||||
point.y = y + offsetExt2y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(m_Color);
|
||||
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(m_Color);
|
||||
|
||||
point.x = x + offsetInt2x;
|
||||
point.y = y + offsetInt2y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(m_Color);
|
||||
|
||||
point.x = x + offsetIntx;
|
||||
point.y = y + offsetInty;
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(m_Color);
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::OObject2DColored::Disc(float x, float y, float radius)
|
||||
@ -194,7 +247,11 @@ void ewol::OObject2DColored::Disc(float x, float y, float radius)
|
||||
if (radius<0) {
|
||||
radius *= -1;
|
||||
}
|
||||
int32_t nbOcurence = radius*5;
|
||||
int32_t nbOcurence = radius*2;
|
||||
if (nbOcurence < 10)
|
||||
{
|
||||
nbOcurence = 10;
|
||||
}
|
||||
|
||||
for (int32_t iii=0; iii<nbOcurence; iii++) {
|
||||
point.x = x;
|
||||
|
@ -109,6 +109,25 @@ void ewol::Test::OnRegenerateDisplay(void)
|
||||
tmpOObjects->SetColor(0.0, 1.0, 0.0, 0.5);
|
||||
tmpOObjects->Disc(200, 100, 300);
|
||||
}
|
||||
tmpOObjects->SetColor(0.0, 0.0, 0.0, 1.0);
|
||||
if (0 == m_elementID) {
|
||||
tmpOObjects->Circle(100, 100, 10, 3);
|
||||
} else if (1 == m_elementID) {
|
||||
tmpOObjects->Circle(100, 100, 20, 3);
|
||||
} else if (2 == m_elementID) {
|
||||
tmpOObjects->Circle(100, 100, 30, 2);
|
||||
} else if (3 == m_elementID) {
|
||||
tmpOObjects->Circle(100, 100, 40, 1);
|
||||
} else if (4 == m_elementID) {
|
||||
tmpOObjects->Circle(100, 100, 50, 0.5);
|
||||
} else if (5 == m_elementID) {
|
||||
tmpOObjects->Circle(100, 100, 100, 25);
|
||||
} else if (6 == m_elementID) {
|
||||
tmpOObjects->Circle(100, 100, 100, 35);
|
||||
} else {
|
||||
tmpOObjects->Circle(100, 100, 100, 50);
|
||||
}
|
||||
|
||||
|
||||
AddOObject(tmpOObjects, "BouttonDecoration");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user