indigo icon indicating copy to clipboard operation
indigo copied to clipboard

Cropped Graphics don't tile

Open hobnob opened this issue 2 years ago • 2 comments

When defining a Graphic and withCrop means you cannot tile a graphic. For example, for a 16x16 portion of an image the following should tile the entire area, but doesn't:

Graphic(128, 16, Material.Bitmap(AssetName("sprite")).tile)
  .withCrop(16, 0)

hobnob avatar Oct 04 '22 08:10 hobnob

The problem here is that in a Graphic, the size and the crop rectangles are the same thing. So when you set a crop on some sub-section of the graphic, you're actually setting the size of the graphic, and the tile works perfectly because there is only room for one iteration.

This is not the expected behaviour, but there are two ways forward:

  1. Find some way to express that size and crop are different, currently there is no way to represent this in the data.
  2. Simply say that it's a limitation: Tiling doesn't work on cropped graphics. Doesn't feel great though.

davesmith00000 avatar Oct 04 '22 21:10 davesmith00000

Interesting side note, in the current implementation, the crop size is the size of the space on the screen and the crop position becomes a tiling offset value! Bug or feature... bug or feature... :thinking:

davesmith00000 avatar Oct 04 '22 21:10 davesmith00000