-
Notifications
You must be signed in to change notification settings - Fork 1
Drawing images with transform
Ryan G edited this page Sep 18, 2017
·
1 revision
Now that we can draw images, we also might want to transform those images. Transformations take the form of things like color blending, scaling, rotating, or flipping our image.
import dgt;
void main()
{
Window window = Window("Your First Window", 800, 600, WindowConfig());
Texture ball = Texture("ball.png");
const x = 400;
const y = 300;
const width = ball.size.width;
const height = ball.size.height;
auto rotation = 0;
const originX = ball.size.width / 2;
const originY = ball.size.height / 2;
const scaleX = 1;
const scaleY = 1;
const flipX = false;
const flipY = false;
const color = Color.white;
while(window.isOpen)
{
window.begin(Color.white);
window.draw(ball, x, y, width, height, rotation, originX, originY, scaleX, scaleY, flipX, flipY, color);
rotation++;
window.end();
}
}
The ball should now be rotating near the center of the window. Feel free to play around with the constants and see the effect on the ball.
ball.size is a Rectangle that tells you the size of the Ball texture.