Hero-admin: schakelaar Actief, destructieve knoppen rood, slide-kopjes, juiste voorvertoning in het focusvenster, status per foto
- Schakelaar (role=switch) Actief / Niet actief bij de knoppen, gedimde rij; 'Verberg voor schermlezers'; veld 'Beschrijving' binnen een groep 'Slide N'
- Alle foto's zonder complete set tonen 'Wordt verwerkt' (voortgang bij de foto die bezig is, 'in de wachtrij' bij de rest); totaal bovenaan telt ook nog niet opgeslagen foto's
- Per foto 'Verwerking afgerond' (zelfde weergave voor een hergebruikte foto), foto direct bruikbaar; niet-opgeslagen foto's worden zelf ververst (GET /hero/images/{id}), ook in een achtergrondtab
- Focusvenster toont de hele foto (full-preview in elke set, achtergrond-aanvulling voor oude sets) in plaats van de uitgesneden wide-variant (vervorming)
- Prullenbak en 'Wijzigingen weggooien' in de destructieve stijl
- upload-respons: reused (intern)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -59,3 +59,49 @@ describe('normalizeFocus and roundHalfUp', () => {
|
||||
expect(roundHalfUp(2.4)).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('the crop of both shapes for every kind of picture', () => {
|
||||
// landscape 3:2, the two common cameras, portrait, square, a panorama and a very tall strip
|
||||
const sources: [string, number, number][] = [
|
||||
['landscape 3:2', 3000, 2000],
|
||||
['landscape 4:3', 2048, 1536],
|
||||
['portrait 2:3', 2000, 3000],
|
||||
['square', 1500, 1500],
|
||||
['panorama 3:1', 6000, 2000],
|
||||
['tall strip 1:3', 800, 2400],
|
||||
];
|
||||
const points = [CENTRE, { x: 0, y: 0, zoom: 1 }, { x: 1, y: 1, zoom: 1 }, { x: 0.2, y: 0.8, zoom: 2 }, { x: 0.5, y: 0.5, zoom: 4 }];
|
||||
|
||||
it.each(sources)('%s: both crops have exactly their shape (to the pixel), lie inside the picture and keep the point', (_name, width, height) => {
|
||||
for (const ratio of [WIDE, TALL]) {
|
||||
for (const focus of points) {
|
||||
const crop = cropFor(width, height, ratio, focus);
|
||||
// One pixel of rounding at most: the crop is never stretched to another shape.
|
||||
expect(Math.abs(crop.width * ratio.denominator - crop.height * ratio.numerator)).toBeLessThanOrEqual(Math.max(ratio.numerator, ratio.denominator));
|
||||
expect(crop.x).toBeGreaterThanOrEqual(0);
|
||||
expect(crop.y).toBeGreaterThanOrEqual(0);
|
||||
expect(crop.x + crop.width).toBeLessThanOrEqual(width);
|
||||
expect(crop.y + crop.height).toBeLessThanOrEqual(height);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it.each(sources)('%s: the preview box shows the crop at its own shape (no stretching)', (_name, width, height) => {
|
||||
// The preview places the WHOLE picture inside a box of the crop shape: scale = box width / crop width, so the
|
||||
// picture keeps its own shape when its height follows from its width.
|
||||
for (const ratio of [WIDE, TALL]) {
|
||||
const crop = cropFor(width, height, ratio, CENTRE);
|
||||
const boxWidth = 100;
|
||||
const scale = boxWidth / crop.width;
|
||||
const pictureWidth = width * scale;
|
||||
const pictureHeight = pictureWidth * (height / width);
|
||||
const boxHeight = (boxWidth * ratio.denominator) / ratio.numerator;
|
||||
// What is visible of the picture in the box is exactly the crop rectangle (same shape as the box).
|
||||
const visibleWidth = boxWidth / (pictureWidth / width);
|
||||
const visibleHeight = boxHeight / (pictureHeight / height);
|
||||
expect(visibleWidth).toBeCloseTo(crop.width, 6);
|
||||
expect(visibleHeight / visibleWidth).toBeCloseTo(ratio.denominator / ratio.numerator, 2);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user