LiveCode refuses to scale rotated images if the angle is set and lockloc is false but if you set lockloc to true you can scale the rotated image. If you just rotate an image with lockloc set (to true) it will always keep the image inside the original bounding box which is normally not what you want. But if you want to rotate and keep the same scale you need to calculate the new width and height of the image based on the scale factor. But if you have the scale factor nd the wanted angle we can, with some trigonometry, calculate the new width and height and thus create a function:
constant deg2Rad = pi/180 on rotateAndScaleImage pImgID pDeg pScale if pScale is empty then put 1 into pScale put the loc of pImgID into tLoc put the formattedwidth of pImgID * pScale into tWidth put the formattedheight of pImgID * pScale into tHeight put pDeg * deg2Rad into tRad put abs(sin(tRad)) into tSin put abs(cos(tRad)) into tCos put tWidth * tCos + tHeight * tSin into tNewWidth put tWidth * tSin + tHeight * tCos into tNewHeight lock screen set the angle of pImgID to pDeg set the width of pImgID to tNewWidth set the height of pImgID to tNewHeight set the loc of pImgID to tLoc end rotateAndScaleImage pImgID is the reference to the image, pDeg is the rotation angle in degrees and pScale is the scale factor for the image. E.g. rotateAndScaleImage the long id of image “MyImage”, 22, 0.5 Will rotate image “MyImage” by 22 degrees at half the original size NOTE! The function above rotates the image around it’s center and to get the function to work the lockloc needs to be set to true Happy coding! :-Håkan > 1 juni 2024 kl. 13:18 skrev Niggemann, Bernd via use-livecode > <use-livecode@lists.runrev.com>: > > Neville wrote >> Now while referenced images such as png’s can be >> rotated (more precisely, have their angle set) they lose their scaling, >> reverting to their native size; and rotated images cannot be scaled (why?? > > set the resizeQuality of the image to good or best depending on your image > (images get a bit fuzzy when rotated) > > you can resize a rotated image if you set the imageData of the rotated image > to the imageData of the rotated image > > set the angle of image 1 to 15 > set the imageData of image 1 to the imageData of image 1 > > As soon as you set the imageData of the image it is not referenced anymore. > But it can be resized. > > I do not know your requirements exactly but if you want to set the angle > repeatedly then it is best to store the original (non-rotated) text of the > image and do your rotation every time from that starting point. > > i.e. > store original > set angle > restore to origina > set next angle > > Examples of rotating and resizing of image can be found in this topic of the > Forum (old stuff but still working) > > https://forums.livecode.com/viewtopic.php?f=27&t=8042 > > Kind regards > Bernd > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode