mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-28 19:57:05 -06:00
Fix #839: Save for Web accepts a typed width or height
The dialog's W and H fields send decimal numbers (300.0) and the settings wanted a whole u32, so the preview failed with "invalid type: floating point". Pixel sizes now take any number and round it to whole pixels; negative, huge and non-numeric sizes are still refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
021a9474f8
commit
5df4ddd4b6
@@ -285,9 +285,16 @@ fn image_size_region_and_metadata() {
|
||||
assert_eq!(size(&mut s, json!({"width": 80})), (80, 60));
|
||||
assert_eq!(size(&mut s, json!({"height": 15})), (20, 15));
|
||||
assert_eq!(size(&mut s, json!({"percent": 150})), (60, 45));
|
||||
// The dialog's fields send decimal numbers: rounded to whole pixels.
|
||||
assert_eq!(size(&mut s, json!({"width": 80.0})), (80, 60));
|
||||
assert_eq!(size(&mut s, json!({"height": 14.6})), (20, 15));
|
||||
for bad in [
|
||||
json!({"percent": 0}),
|
||||
json!({"width": 0}),
|
||||
json!({"width": 0.2}),
|
||||
json!({"width": -5}),
|
||||
json!({"height": 1e300}),
|
||||
json!({"height": "tall"}),
|
||||
json!({"format": "bmp"}),
|
||||
json!({"colors": "many"}),
|
||||
json!({"matte": "plaid"}),
|
||||
|
||||
Reference in New Issue
Block a user