SetScale
This function sets a context's drawing scale.
Syntax
- void SetScale(float x, float y)
Parameters
- x: the x component of the scale to set.
- y: the y component of the scale to set.
Example
#include "Leadwerks.h"
using namespace Leadwerks;
int main(int argc, const char *argv[])
{
Leadwerks::Window* window = Leadwerks::Window::Create();
Context* context = Context::Create(window);
Font* font = Font::Load("Fonts/Arial.ttf",48);
context->SetFont(font);
while (true)
{
if (window->Closed() || window->KeyHit(Key::Escape)) break;
Leadwerks::Leadwerks::Time::Update();
float a = Leadwerks::Time::GetCurrent() * 0.1;
context->SetColor(0.0, 0.0, 1.0);
context->Clear();
//Draw some text centered on the screen
std::string text = "Hello!";
float x = context->GetWidth() / 2;
float y = context->GetHeight() / 2;
float w = font->GetTextWidth(text);
float h = font->GetHeight();
float scale = Math::Sin(a)*0.5 + 1.0;
context->SetRotation(a);
context->SetScale(scale, scale);
context->SetTranslation(-(Math::Cos(a)*w - Math::Sin(a)*h) / 2.0 * scale, (-Math::Sin(a)*w - Math::Cos(a)*h) / 2.0 * scale);
context->SetBlendMode(Blend::Alpha);
context->SetColor(1.0, 1.0, 1.0);
context->DrawText(text, x, y);
context->SetBlendMode(Blend::Solid);
context->Sync();
}
return 0;
}