Reputation: 149
I am unable to find alternative to Transform Method of graphics class in CodenameOne. I have tried using Graphics setTransform Method but am unable to get that desired functionality. Can you please help with this. Thank you
AffineTransform saveAT = g2d.getTransform();
g2d.transform(getmyTranslation());
g2d.transform(getmyRotation());
g2d.fillRect((int)(0-getSize()/2), (int)(0-getSize()/2), getSize(), getSize());
for (Object f : obj)
{
f.draw(g2d);
}
g2d.setTransform(saveAT);
We do not have g2d.transform in CodenameOne
Upvotes: 0
Views: 60
Reputation: 52760
The affine transform is built directly into graphics so you don't need the first few lines at all:
AffineTransform saveAT = g2d.getTransform();
g2d.transform(getmyTranslation());
g2d.transform(getmyRotation());
You can just do:
g2d.rotate(degrees, pivotX, pivotY);
The fill rect should be practically identical:
g2d.fillRect((int)(0-getSize()/2), (int)(0-getSize()/2), getSize(), getSize());
Draw should also work nicely for Shape
objects:
for (Object f : feet)
{
f.draw(g2d);
}
Restoring the affine like this isn't necessary:
g2d.setTransform(saveAT);
Just do this instead:
g2d.resetAffine();
Upvotes: 1