I'm attempting to create a drawing surface with y increasing upwards, the origin at the centre, and scaled so that the unit circle just fits within the window.
float w = getWidth(), h = getHeight(); g.addTransform(AffineTransform::verticalFlip(h)); g.addTransform(AffineTransform::translation(w/2, h/2)); float s = 1.f / std::min(w/2, h/2); g.addTransform(AffineTransform::scale(s)); g.setColour(Colours::white);
I test it with:
{
Path p;
p.addEllipse(-1, -1, 1, 1);
// unit circle p.closeSubPath();
g.strokePath(p, PathStrokeType(0.1f));
}
{
Path p;
p.addRectangle(0, 0, .5f, .5f);
p.closeSubPath();
g.fillPath(p);
}
Everything works up to the scaling.
Now I have tested scaling by 0.5, and setting appropriate values for my circle and square. That works! But for a very small value of s, it fails!
I haven't dug into the framework yet, my guess is at some point it is converting to integer and rounding to 0.
But its unexpected behaviour!
π
