Recently I was making a Maths Plotter on SFML, and I have done the basic core features like Drawing the animations and input.
But I wanted to know if I can change the color of a vertex array.
Here is the code for reference
void drawFunction(sf::RenderWindow &window)
{
while(x < 30 && drawing == true)
{
aq::sleep(0.01);
x += 0.1;
std::cout << x << std::endl;
window.clear();
curve.setPosition(sf::Vector2f(x*20.f + window.getSize().x/2,
-1*(sin(x))*20.f + window.getSize().y/2));
function.append(
sf::Vertex(curve.getPosition()));
window.draw(function);
window.draw(curve);
window.draw(sprite);
window.draw(x_axis);
window.draw(y_axis);
window.display();
}
if(x > 15 || drawing == false || (x > 15 && drawing == false))
{
drawing = false;
window.clear();
window.draw(function);
window.draw(sprite);
window.draw(x_axis);
window.draw(y_axis);
window.display();
}
}