Skip to content

GlyphMatrixObject.Builder()'s transformation functions behaving unhelpfully. #4

@PixHammer

Description

@PixHammer

While I am appreciating the extra utilities for rotating and scaling images, setOrientation is causing quite a bit of grief with non 100% scale, non 90 degree rotations.
At 100% scale it behaves as anticipated, rotating around the center of the image. However, for some reason, when using non 90 degree rotations and a non-100% scaling, the object is shifted partially to the right and down, and no longer rotates about the center of the object. (this is most likely due to the added canvas size to contain the bounds of the new rotated bitmap)

Attached is a video outlining my issue, this is a simple bitmap, rotating 5 degrees every frame.

val pixelSize:Int = (MATRIX_SIZE * currentScaleFactor).roundToInt(); // currentScaleFactor = 0.75
val imageObject = GlyphMatrixObject.Builder()
    .setImageSource(bitmap)
    .setScale((100.0 * currentScaleFactor).roundToInt())
    .setPosition(CENTER-(pixelSize/2),CENTER-(pixelSize/2))
    .setOrientation(currentRotation)
    .build()
VID20250723003916.mp4

It's likely that I could engineer a hack fix for this, by calculating the extra size that has been added by the rotation, and offsetting by half of that. However this is not a complete fix, as the problems only occurs at non-100% scales.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions