Fix size of portrait images with the SIZE_NORMAL setting. (#7188)

This commit is contained in:
Timo 2021-11-29 15:01:54 +01:00 committed by GitHub
parent 9db0ebb7f5
commit 8860916225
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 15 deletions

View file

@ -14,20 +14,25 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// For Large the image gets drawn as big as possible.
// constraint by: timeline width, manual heigh overrides, SIZE_LARGE.h
const SIZE_LARGE = { w: 800, h: 600 };
const SIZE_NORMAL = { w: 324, h: 220 };
// For Normal the image gets drawn to never exceed SIZE_NORMAL.w, SIZE_NORMAL.h
// constraint by: timeline width, manual heigh overrides
const SIZE_NORMAL_LANDSCAPE = { w: 324, h: 324 }; // for w > h
const SIZE_NORMAL_PORTRAIT = { w: 324 * (9/16), h: 324 }; // for h > w
export enum ImageSize {
Normal = "normal",
Large = "large",
}
export function suggestedSize(size: ImageSize): { w: number, h: number } {
export function suggestedSize(size: ImageSize, portrait = false): { w: number, h: number} {
switch (size) {
case ImageSize.Large:
return SIZE_LARGE;
case ImageSize.Normal:
default:
return SIZE_NORMAL;
return portrait ? SIZE_NORMAL_PORTRAIT : SIZE_NORMAL_LANDSCAPE;
}
}