Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add repeat fit mode to image decorator #493

Merged
merged 5 commits into from
Aug 7, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions Source/Core/DecoratorTiled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,31 @@ void DecoratorTiled::Tile::GenerateGeometry(Vector<Vertex>& vertices, Vector<int
break;
case REPEAT:
final_tile_dimensions = surface_dimensions;
repeat_factor = surface_dimensions / tile_dimensions;
if (scaled_texcoords[1].y - scaled_texcoords[0].y == 1.0 && scaled_texcoords[1].y - scaled_texcoords[0].y == 1.0) {
mikke89 marked this conversation as resolved.
Show resolved Hide resolved
repeat_factor = surface_dimensions / tile_dimensions;
} else {
Log::Message(Log::LT_WARNING, "Texture repeating is not supported for spritesheets.");
}
break;
case REPEAT_X:
final_tile_dimensions = Vector2f(surface_dimensions.x, tile_dimensions.y);
repeat_factor.x = surface_dimensions.x / tile_dimensions.x;
offset_and_clip_tile = true;

if (scaled_texcoords[1].x - scaled_texcoords[0].x == 1.0) {
repeat_factor.x = surface_dimensions.x / tile_dimensions.x;
} else {
Log::Message(Log::LT_WARNING, "Texture repeating (repeat-x) is not supported for spritesheets.");
}
break;
case REPEAT_Y:
final_tile_dimensions = Vector2f(tile_dimensions.x, surface_dimensions.y);
repeat_factor.y = surface_dimensions.y / tile_dimensions.y;
offset_and_clip_tile = true;

if (scaled_texcoords[1].y - scaled_texcoords[0].y == 1.0) {
repeat_factor.y = surface_dimensions.y / tile_dimensions.y;
} else {
Log::Message(Log::LT_WARNING, "Texture repeating (repeat-y) is not supported for spritesheets.");
}
break;
}

Expand Down