Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 0 additions & 7 deletions .changeset/fix-direction-constants.md

This file was deleted.

9 changes: 0 additions & 9 deletions .changeset/fix-operators-and-color.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/friendly-map-object-property-errors.md

This file was deleted.

21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
---
name: Changelog
index: 4
index: 59
lang: en
---

## 4.28.1



Fix incorrect math in `Operators` and `Color`, found while adding a unit test suite for the library's pure-logic classes (`Operators`, `extensions/math`, `extensions/shape`, `extensions/hitbox`, `extensions/color`).

- **`Operators.asinOf`, `Operators.acosOf`, `Operators.atanOf`**: these applied the degrees conversion to the input before taking the inverse trig function, and never converted the result back to degrees, so `asinOf`/`acosOf` returned `NaN` for almost any real input, and `atanOf` returned radians instead of degrees. They now correctly return the degree-valued inverse of `sinOf`/`cosOf`/`tanOf` (e.g. `asinOf(1.0) == 90.0`).
- **`Operators.max(double...)`**: seeded its accumulator with `Double.MIN_VALUE` (the smallest *positive* double) instead of `Double.NEGATIVE_INFINITY`, so it returned the wrong result whenever every input was negative. Fixed to seed with `Double.NEGATIVE_INFINITY`.
- **`Color(double r, double g, double b)`**: passed `g` twice to `setRGB`, silently dropping the blue channel and replacing it with the green value. Fixed to pass `r, g, b`. This also corrects `GifRecorder.transparent`, which is constructed with this constructor.


Fix `Sprite.DIRECTION_RIGHT`/`DIRECTION_UP`/`DIRECTION_LEFT`/`DIRECTION_DOWN` (introduced in the previous release) having their degree values swapped relative to how `Sprite.move()` and `setDirection()` actually behave. A sprite's default direction is `90`, which moves it along +x ("right"), and `move()`'s trig confirms the real convention — matching real Scratch — is `0 = up, 90 = right, 180 = down, 270 = left`. The constants previously claimed `0 = right, 90 = up, 180 = left, 270 = down`, the opposite of reality. Also corrected the matching descriptions in `setDirection()`'s and `pointInDirection()`'s Javadoc, which had the same swap.

No shipped example or demo used these constants, so this only affects code written against the just-released values.


`MapObject.getProperty()` now throws a helpful error message naming the missing property and, when available, the properties that do exist on that map object — instead of a bare `NoSuchElementException` with no context. It also now gives a clear message when the map object has no custom properties at all, rather than a raw `NullPointerException`. This matches the library's existing beginner-friendly error reporting for missing assets.


## 4.28.0

Improve beginner-friendliness of the library.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.openpatch</groupId>
<artifactId>scratch</artifactId>
<version>4.28.0</version>
<version>4.28.1</version>
<packaging>jar</packaging>

<name>Scratch for Java</name>
Expand Down
Loading