Skip to content

Commit 8267225

Browse files
committed
Preparing release
1 parent 4c4631f commit 8267225

9 files changed

Lines changed: 50 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,34 @@
33
All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

6+
## [Version 4.0.0] - 2025-12-22
7+
8+
### Changed
9+
10+
- Renamed `*-bounds` definitions to `*-size`.
11+
- Changed meaning of `rect` in the output description. It used to be the logical bounds of the sprite. Now it is the rectangle the sprite takes on the sheet (which can be bigger than `trimmedRect`, when the size is increased by `min-size`, `divisible-size`, `common-size`).
12+
- The logical bounds of a sprite can now be defined by a `margin`, which is added to `rect`.
13+
- Renamed `vertices` to `outline` in output description and made it relative to `rect` (it used to be relative to the `trimmedRect`).
14+
15+
### Added
16+
17+
- Added `margin` definition.
18+
- Added the sheets' `outputs` to description.
19+
20+
### Fixed
21+
22+
- Fixed `divisible-width`.
23+
- Fixed `trimmedSourceRect` in description when transforming.
24+
- Fixed `align-pivot` when anchor is not top/left.
25+
- Fixed alignment when sprite is rotated.
26+
- Fixed `extrude` and uncropped pivot-point.
27+
- Fixed `scale` when downsampling to nearest.
28+
- Improved `rotate` accuracy.
29+
- Fixed `trim convex`.
30+
- Fixed crash on `duplicate` before first sprite.
31+
- Prevent `grid`/`atlas` in input sequences.
32+
- Ensuring invalid definitions do not lead to invalid states.
33+
634
## [Version 3.8.0] - 2025-11-21
735

836
### Added
@@ -369,6 +397,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
369397
- Fixed -- commandline arguments.
370398
- Fixed sample cpp.template.
371399

400+
[version 4.0.0]: https://github.com/houmain/spright/compare/3.8.0...4.0.0
372401
[version 3.8.0]: https://github.com/houmain/spright/compare/3.7.0...3.8.0
373402
[version 3.7.0]: https://github.com/houmain/spright/compare/3.6.1...3.7.0
374403
[version 3.6.1]: https://github.com/houmain/spright/compare/3.5.4...3.6.1

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ if(ENABLE_TEST)
104104
test/test-main.cpp
105105
test/test-common.cpp
106106
test/test-scope.cpp
107-
test/test-autocompletion.cpp
107+
test/test-completion.cpp
108108
test/test-packing.cpp
109109
test/test-performance.cpp
110110
test/test-globbing.cpp

src/image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ namespace {
251251
return dest;
252252
}
253253

254-
Image downsample_image_nearest(ImageView<const RGBAF> image_rgbaf, const SizeF& scale) {
254+
[[maybe_unused]] Image downsample_image_nearest(ImageView<const RGBAF> image_rgbaf, const SizeF& scale) {
255255
return downsample_image_sample(image_rgbaf, scale,
256256
[&](const RectF& rect) {
257257
const auto point = Point(round_to_int(rect.x + rect.w / 2), round_to_int(rect.y + rect.h / 2));

src/image_io.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace {
109109
const auto b = to_int(palette[i].b) - to_int(color.b);
110110
const auto distance = (r * r + g * g + b * b);
111111
if (distance < min_distance) {
112-
min_index = to_int(i);
112+
min_index = i;
113113
min_distance = distance;
114114
}
115115
}

src/pack_compact.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ namespace {
2020
const auto border = to_real(border_padding) - padding;
2121
const auto x0 = border;
2222
const auto y0 = border;
23-
const auto x1 = to_real(slice.width) - border - 0.5;
24-
const auto y1 = to_real(slice.height) - border - 0.5;
23+
const auto x1 = to_real(slice.width) - border;
24+
const auto y1 = to_real(slice.height) - border;
2525

2626
auto shapes = std::vector<ShapePtr>();
2727
shapes.emplace_back(cpSpaceAddShape(space, cpSegmentShapeNew(cpSpaceGetStaticBody(space), cpv(x0, y0), cpv(x1, y0), 0)));
@@ -74,10 +74,10 @@ void pack_compact(const SheetPtr& sheet, SpriteSpan sprites,
7474
std::vector<Slice>& slices) {
7575
const auto fast = (sheet->allow_rotate == false);
7676
pack_binpack(sheet, sprites, slices, fast);
77-
for (auto& slice : slices) {
77+
scheduler.for_each_parallel(slices, [&](Slice& slice) {
7878
recompute_slice_size(slice);
7979
compact_sprites(slice, sheet->border_padding, sheet->shape_padding);
80-
}
80+
});
8181
}
8282

8383
} // namespace

src/trimming.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ namespace {
6969
reinterpret_cast<cpMarchSegmentFunc>(cpPolylineSetCollectSegment), outlines,
7070
sample, &image_mono);
7171

72-
assert(outlines->count > 0);
72+
if (outlines->count == 0)
73+
return { };
74+
7375
const auto right = cpFloat(image_mono.width());
7476
const auto bottom = cpFloat(image_mono.height());
7577
for (auto i = 0; i < outlines->count; ++i) {
@@ -163,13 +165,14 @@ namespace {
163165
get_gray_levels(sprite.source->image(), sprite.trimmed_source_rect) :
164166
get_alpha_levels(sprite.source->image(), sprite.trimmed_source_rect));
165167

166-
auto outline = get_polygon_outline(
167-
levels.view<RGBA::Channel>(), sprite.trim_threshold);
168-
outline = to_convex_polygon(*outline, 0);
169-
outline = simplify_polygon(*outline, 0.25);
170-
remove_end_point(*outline);
171-
expand_polygon(*outline, sprite.trim_margin.x0);
172-
sprite.outline = to_point_list(*outline);
168+
if (auto outline = get_polygon_outline(
169+
levels.view<RGBA::Channel>(), sprite.trim_threshold)) {
170+
outline = to_convex_polygon(*outline, 0);
171+
outline = simplify_polygon(*outline, 0.25);
172+
remove_end_point(*outline);
173+
expand_polygon(*outline, sprite.trim_margin.x0);
174+
sprite.outline = to_point_list(*outline);
175+
}
173176
}
174177

175178
if (sprite.outline.empty()) {

templates/phaser.inja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
{ {% set sprite=at(sprites, index) %}
1818
"filename": "{{ sprite.id }}",
1919
"rotated": {{ sprite.rotated }},
20-
"trimmed": {% if sprite.rect.w == sprite.trimmedRect.w and sprite.rect.h == sprite.trimmedRect.h %}false{% else %}true{% endif %},
20+
"trimmed": {% if sprite.sourceRect.w == sprite.trimmedSourceRect.w and sprite.sourceRect.h == sprite.trimmedSourceRect.h %}false{% else %}true{% endif %},
2121
"sourceSize": {
2222
"w": {{ round(sprite.sourceRect.w * scale, 0) }},
2323
"h": {{ round(sprite.sourceRect.h * scale, 0) }}

templates/phaser2.inja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
"filename": "{{ sprite.id }}",
1212
"rotated": {{ sprite.rotated }},
13-
"trimmed": {% if sprite.rect.w == sprite.trimmedRect.w and sprite.rect.h == sprite.trimmedRect.h %}false{% else %}true{% endif %},
13+
"trimmed": {% if sprite.sourceRect.w == sprite.trimmedSourceRect.w and sprite.sourceRect.h == sprite.trimmedSourceRect.h %}false{% else %}true{% endif %},
1414
"sourceSize": {
1515
"w": {{ round(sprite.sourceRect.w * scale, 0) }},
1616
"h": {{ round(sprite.sourceRect.h * scale, 0) }}

templates/pixijs.inja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"{{ sprite.id }}":
44
{
55
"rotated": {{ sprite.rotated }},
6-
"trimmed": {% if sprite.rect.w == sprite.trimmedRect.w and sprite.rect.h == sprite.trimmedRect.h %}false{% else %}true{% endif %},
6+
"trimmed": {% if sprite.sourceRect.w == sprite.trimmedSourceRect.w and sprite.sourceRect.h == sprite.trimmedSourceRect.h %}false{% else %}true{% endif %},
77
"sourceSize": {
88
"w": {{ round(sprite.sourceRect.w * scale, 0) }},
99
"h": {{ round(sprite.sourceRect.h * scale, 0) }}

0 commit comments

Comments
 (0)