Buryat i couldn't find an easy way through Godot, but if you're looking for a batch script and you're cool with the icons being stored on disk rather than generated and stored in memory during runtime, there's other options:
- if you're a linux enthusiast, and your system has
imagemagick
, you could always use the convert
command.
- there's python and the
Image
class from the PIL
module. the documentation implies you can crop a square from any 4 points of the image.
https://pillow.readthedocs.io/en/stable/reference/Image.html
if you desperately need to go the live generated route, there's a pretty hacky way (or not considering the node's name) to do it with Control
:
- create a
Control
node
- add a
TextureRect
as child of Control
- apply texture to
TextureRect
- check the
clip contents
boolean of the parent Control
node
- the
Control
node should now be "cropping" your image. all you need to do is resize the Control
and and move the TextureRect
around.
two immediate downsides to this solution:
- node paths are a little more obfuscated in code.
- transform operations such as sizing and container behavior are now more complicated, or not, depending on how good you are at math.
besides that, the performance cost is nil.