Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Graphics::drawImage(Graphics::Image i, float x, float y, float rot, float xScale, float yScale)
- {
- unsigned char r = 0, g = 0, b = 0;
- Vector<float> pos = Vector<float>::create(0, 0);
- i.setRotation(rot);
- i.setXScale(xScale);
- i.setYScale(yScale);
- for (int j = 0; j < i.getWidth() * i.getHeight(); j++)
- {
- i.getPixel((j % i.getWidth()), (j / i.getWidth()), r, g, b);
- SDL_SetRenderDrawColor(renderer, r, g, b, 255);
- pos.elements[0] = (j % i.getWidth());
- pos.elements[1] = (j / i.getWidth());
- Vector<float> transPos = pos - Vector<float>::create(i.getCenterX(), i.getCenterY());
- Matrix<float> trans = math::scale<float>(i.getXScale(), i.getYScale()) * math::rot<float>((double)i.getRot());
- transPos = math::mult<float, float>(trans, transPos);
- SDL_RenderDrawPoint(renderer, (int)x + transPos.elements[0] + (i.getCenterX() * i.getXScale()), (int)y + transPos.elements[1] + (i.getCenterY() * i.getYScale()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement