Can anyone point me to documentation or examples related to image rotation?
I've tried several approaches, but no luck so far. This is for an extension where I want to flip some images.
Thanks!
Printable View
Can anyone point me to documentation or examples related to image rotation?
I've tried several approaches, but no luck so far. This is for an extension where I want to flip some images.
Thanks!
There's an angle parameter as part of the layerdata table in Image.addLayer: https://fantasygroundsunity.atlassia...Image#addLayer But this is when you add a layer, not changing an existing layer - depending on what you have on the layer, you may be able to remove then add the layer to effectively change the rotation. I don't know if this can be changed via another (undocumented?) function.
I do quite a bit with tiles in the FVTT -> Fantasy Grounds extension, you could look at the code in that extension - the addTile function in manager_fvtt2fg.lua is a good place to start. Extension information here: https://www.fantasygrounds.com/forum...-export-import
Thanks for the response.
This is for a Tarot card extension (nothing related to the map), currently using a genericcontrol (I've tried tokens, and others) for the card.
Do your suggestions still apply, or are those more for map layers/tiles?
The quick way I would approach this is just making sideways images of the cards and set the asset to that card when turned.
Ah, OK - so you're not using an FG "image" control then, as you mentioned "image rotation" I assumed you were talking about an FG image control. The information I gage was for FG images, which aren't restricted to maps. As I'm not exactly sure how you're approaching this, the information I provided may not be of use to you.
That would work for sure. That's the approach I used for my Volvelle extension. But in this case, I have hundreds of card images, and I'm really hoping not to triple the storage needed (one for inverted, one for sideways).
I've tried some other controls, but not imagecontrol yet - I'll give that a try, thanks!
Just a question to help without any knowledge in coding:
Would it be possible to [with some sort of control] that one card image used for all rotations instead of using different card images for face up & sideways, etc?
Automating some function just like in the map making part of FGU?
Good to know. Seems like it's already progressing.
Right now I am running the deep research and in a few mins, after I check everything, I will make another post of my findings.
Can someone with actual knowledge check this So I can do corrections if necessary?
It's from a Deep Research of NotebookLM.
Sorry it took a while.
Ok, Im not 100% sure on what I've found but these are the ways to use one image per card face and one image for a card back with some controller combo.
Entire PDF is here.
Summary
1. Define the Container
The foundation of the card display is the genericcontrol, defined in XML. This control acts as a widgetcontainer, providing a base canvas and mounting point for dynamic graphical assets.
2. Instantiate the Asset
To display the card, use Lua to create a bitmapwidget within the genericcontrol by calling:
- addBitmapWidget(asset_name): This function instantiates a single asset (like a card face) as a widget object.
3. Apply Rotation and Orientation -- PROBLEMATIC PART!!! Check Carl's Post // It kinda worked.
Orientation is handled programmatically through the setRotation function, which supports floating-point degree values for free rotation.
- Face-Up (Standard): widget.setRotation(0). Degrees chart.
- Inverted: widget.setRotation(180).
- Sideways/Tapped: widget.setRotation(90) or (270).
- Note: The parent genericcontrol must have a bounding box large enough to accommodate the card’s dimensions when rotated (e.g., a 300x500 card needs a 500x300 footprint when sideways).
4. Manage Face-Down States
A single image widget can be manipulated to show different states, or a dual-widget system can be used:
- Asset Swapping: Call setBitmap("back_asset_name") on the existing widget to switch between the card face and back.
- Visibility Toggling: Create two widgets (one for the face, one for the back) and use setVisible(boolean) to toggle which is shown.
5. Handle Stacking and Z-Order
When arranging cards in spreads or piles, use procedural anchoring to manage overlap and depth:
- setAnchor(edge, parent, anchor, offset, relation): Defines the relative position of cards.
- Stacking Logic: Setting the relation parameter to "relative" allows cards to stack or fan out automatically based on the position of the previous card in the list.
- Z-Order: While XML order determines default drawing, dynamic reordering in a hand requires iterating through the card list and re-applying anchors to ensure the correct visual flow.
EDIT: RELATED WIKI PAGES FOR EASY ACCESS