Skip to content

Add image crop - #658

Open
luckydu-henry wants to merge 1 commit into
nicbarker:mainfrom
luckydu-henry:main
Open

luckydu-henry wants to merge 1 commit into
nicbarker:mainfrom
luckydu-henry:main

Conversation

@luckydu-henry

Copy link
Copy Markdown

Hello, I've been using Clay for UI layout in my own game project, and recently I discovered a frequently encountered area where Clay's support is "quite incomplete."

Clay's current ImageElementConfig and ImageRenderData structures do not store image "cropping" information. This means that when laying out a large number of small icons (such as a row of notification icons), you either have to create a complete image for each icon, or pass atlas data and cropping information through imageData.

The first approach causes a lot of unnecessary bandwidth waste, while the second approach requires manual pointer casting and, more dangerously, requires the lifetime of the cropping information to last through the entire Clay layout cycle. But the cropping information is basically just a Clay_BoundingBox, 4 float s, and having to separately manage the lifetime of such small and plain old data creates a lot of taxing extra work.

Therefore, I modified clay.h by adding a Clay_BoundingBox crop field to both Clay_ImageElementConfig and Clay_ImageRenderData , to describe the image's cropping range, so that Clay can support atlases more elegantly, with almost no performance overhead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant