Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "shape.hpp"
- Shape::Shape(const Vector2D& location) :
- location_(location)
- {
- }
- void Shape::scale(float s)
- {
- for(Vector2D& vert : vertices_) {
- vert.i *= s;
- vert.j *= s;
- }
- }
- void Shape::render(prg::Canvas& canvas) const
- {
- std::vector<Vector2D>::const_iterator Shapet_iter =
- vertices_.begin();
- std::vector<Vector2D>::const_iterator end_iter =
- vertices_.begin() + (vertices_.size()-1);
- for(
- std::vector<Vector2D>::const_iterator iter = Shapet_iter,
- next = Shapet_iter+1;
- iter != end_iter;
- ++iter,
- ++next
- )
- {
- canvas.drawLine(
- location_.i + iter->i,//P1
- location_.j + iter->j,
- location_.i + next->i,//P2
- location_.j + next->j,
- prg::Colour::MAGENTA
- );
- }
- canvas.drawLine(
- location_.i + end_iter->i,//P1
- location_.j + end_iter->j,
- location_.i + Shapet_iter->i,//P2
- location_.j + Shapet_iter->j,
- prg::Colour::MAGENTA
- );
- }
- void Shape::update()
- {
- //TO BE COMPLETED LATER
- rotate_vectors(
- vertices_.data(),
- vertices_.size(),
- rotation_angle_
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment