Compare commits

..

2 Commits

2 changed files with 13 additions and 9 deletions

View File

@ -265,8 +265,6 @@ void Display::update ()
m_points.erase(m_points.begin() + i);
}
}
//setCurrentLine(); // set current line in next step
}
else
{
@ -309,10 +307,6 @@ void Display::update ()
m_lines.push_back(Line(Point(left.x, left.y), Point(right.x, right.y)));
m_lines.push_back(Line(Point(right.x, right.y), Point(left.x, left.y))); // add first line in both directions to work with "right side"
// set current line just by taking the only one (in one direction)
m_curLineIdx = 1;
m_curLine = m_lines[1];
}
}
else if (curStep == 2)
@ -457,10 +451,11 @@ void Display::render (sf::RenderWindow &window)
// draw already calculated hull points
std::sort(m_hullPoints.begin(), m_hullPoints.end(), less); // sort clockwise
size_t points = m_points.size();
size_t elements = m_hullPoints.size();
for (size_t i = 0; i < elements; ++i)
{
window.draw(m_hullPoints[i]);
if (points > 0 || m_curLineIdx != -1) window.draw(m_hullPoints[i]);
sf::Vertex ptTo;
if (i < elements - 1) ptTo = sf::Vertex(m_hullPoints[i + 1].getPosition(), sf::Color::Blue);

View File

@ -94,6 +94,15 @@ public:
{
x = (i%2 == 0) ? OFFSET : WIDTH - OFFSET;
y = diff/2 + (i/2) * diff;
/*if (i % 4 == 0)
{
x = OFFSET;
}
else
{
x = (i % 4) * WIDTH / 4;
}
y = diff / 4 + (i / 4) * diff;*/
points.push_back(Point(x, y));
}
@ -129,8 +138,8 @@ public:
for (int i = 0; i < valCount; ++i)
{
x = OFFSET + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / (std::min(WIDTH, HEIGHT) - 2 * OFFSET)));
points.push_back(Point(x, HEIGHT - x)); // /
//points.push_back(Point(x, HEIGHT - x)); // \
points.push_back(Point(x, HEIGHT - x)); // ascending
//points.push_back(Point(x, HEIGHT - x)); // descending
}
return points;
}