Rotating an Image

  1. 2 weeks ago

    Jon O

    May 16 Pre-Release Testers, Xojo Pro Chicago Area USA

    Hey all,

    I recently started using Logoist (thanks Sasha - GREAT app!) to make a knob I am going to have in my app. I'm trying to make this a control that I can adapt for multiple numbers of stops, etc. as it rotates. Below is a picture of the knob:

    -image-

    I want to be able to rotate the knob around the axis. I've tried using Chrstian's Picture.RotateMBS method, but as the center of rotation that I want is not actually the center of the image, the rotation doesn't work correctly. Plus there is shadowing and "lighting" on the image which doesn't stay in the correct spot of I use his method to rotate the image.

    So my next brilliant idea is to generate 360 different images all rotated by a degree. I'm trying to figure out if there's a way in Logoist to automate something like this but so far no luck. Maybe I don't need 360 different possible stops - maybe just a stop every 10 degrees but that's still 36 different images. Seems like a lot of images to have to load into a control, etc.

    Is that the best way to do this though? Create an array of images in the control and then load the one for the particular stop position that you want to be at?

    Thanks!

    • normailze the size of the image, so that the actual center IS the rotation point
    • use PixMapShape... no plugins required

    I made a tank game using this method, and it worked out great

  2. Dave S

    May 16 Answer San Diego, California USA
    • normailze the size of the image, so that the actual center IS the rotation point
    • use PixMapShape... no plugins required

    I made a tank game using this method, and it worked out great

  3. Jeff T

    May 16 Midlands of England, Europe

    Its quite easy to rotate the image.
    Use the image as a PictureShape, displaying using the Object2D methods, and you can apply rotation to it for any angle.

    But

    Plus there is shadowing and "lighting" on the image which doesn't stay in the correct spot of I use his method to rotate the image.

    No rotation method is going to cater for shadows and highlights
    To do that, you need to be rendering a 3D object, where a light source and textures lead to shadows and highlights. Yes, you can create 360 images and display the right one.
    Maybe you can use OpenGL to render on the fly

    If I may: it would be simpler to use a simpler control.
    Consider this one:

    -image-

    Since the highlights don't need to move, all you need to do is place the DOT at the correct point around the perimeter...?

  4. Jon O

    May 16 Pre-Release Testers, Xojo Pro Chicago Area USA

    Thanks Dave. The way I have it drawn in Logoist, the center of rotation is set to the center of the picture which is why I am surprised that Christian’s method didn’t work.

    I see Jeff has replied as well. Thanks to you both. I’ve never PixMapShape or PictureShape so I’ll try that out. Sounds easy enough.

    As for the shading, yeah I get it. Maybe I’ll just ignore that.

    Thanks for the knob Jeff, maybe I’ll try that.

  5. Jeff T

    May 16 Midlands of England, Europe

    the center of rotation is set to the center of the picture which is why I am surprised that Christian’s method didn’t work.

    The centre of the picture isn't the point around which the dial rotates.
    There's a lump, which makes the centre of the picture about 5% too far to the right.

  6. Jon O

    May 16 Pre-Release Testers, Xojo Pro Chicago Area USA

    @Jeff T The centre of the picture isn't the point around which the dial rotates.
    There's a lump, which makes the centre of the picture about 5% too far to the right.

    Yes. I understand. It has to be the way the picture gets exported from Logoist as in Logoist the center of the knob is the rotational axis.

  7. last week

    Jon O

    May 17 Pre-Release Testers, Xojo Pro Chicago Area USA

    So as an update, I ended up creating a PixMapShape object and rotating that. Even though the image has highlighting on it would should technically not move as the "knob" is moved, I am just ignoring that and rotating things. So the "light" rotates with it - who cares.

    Thanks for the help guys.

    Jeff Tullin - do you have the image file for your knob?

  8. Jeff T

    May 17 Midlands of England, Europe

    Jeff Tullin - do you have the image file for your knob?

    (snicker)

    I just searched Google for 'Dial Images'
    Warning: Do NOT search for 'knob images' ;)

  9. Jon O

    May 17 Pre-Release Testers, Xojo Pro Chicago Area USA

    Oh. ok.

    Boy do I feel silly!

  10. Tim P

    May 18 Pre-Release Testers, XDC Speakers

    This is where you can license that knob for commercial use:
    https://graphicriver.net/item/royce-gui-graphical-user-interface/411333

  11. Jon O

    May 18 Pre-Release Testers, Xojo Pro Chicago Area USA

    Thanks, Tim.

    But I'm sticking with my original knob for now. I've actually developed quite a nice control around it.

or Sign Up to reply!