Enum FitMode
- All Implemented Interfaces:
Serializable,Comparable<FitMode>
These modes control how source frames of different dimensions are scaled and positioned onto a uniform canvas size, similar to CSS object-fit behavior.
- Since:
- 2026/1/13 19:45
- Author:
- MrNanko
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionContain mode: Scale the frame to fit entirely within the canvas while preserving aspect ratio.Cover mode: Scale the frame to completely fill the canvas while preserving aspect ratio.Stretch mode: Stretch the frame to exactly match the canvas dimensions. -
Method Summary
-
Enum Constant Details
-
CONTAIN
Contain mode: Scale the frame to fit entirely within the canvas while preserving aspect ratio.The entire source frame will be visible on the canvas. If the aspect ratios don't match, letterboxing (black bars or transparent areas) will appear on the sides or top/bottom.
Behavior:
- Scales down to fit if source is larger than canvas
- Does not scale up by default unless allowUpscale is true
- Centers the frame on the canvas
- Preserves aspect ratio - no distortion
Use case: When you want to ensure the entire frame is visible without cropping.
Similar to CSS:
object-fit: contain -
COVER
Cover mode: Scale the frame to completely fill the canvas while preserving aspect ratio.The canvas will be entirely covered by the frame. If the aspect ratios don't match, parts of the source frame will be cropped off.
Behavior:
- Scales to cover the entire canvas
- May crop parts of the frame that extend beyond the canvas
- Centers the frame on the canvas
- Preserves aspect ratio - no distortion
Use case: When you want to fill the entire canvas without empty space, accepting potential cropping.
Similar to CSS:
object-fit: cover -
STRETCH
Stretch mode: Stretch the frame to exactly match the canvas dimensions.The frame will be stretched or compressed to fill the entire canvas, potentially distorting the aspect ratio.
Behavior:
- Stretches to fill canvas width and height exactly
- If allowUpscale is false, limits to source size and centers
- Does NOT preserve aspect ratio - may cause distortion
- No cropping, no letterboxing
Use case: When exact canvas coverage is more important than aspect ratio preservation.
Similar to CSS:
object-fit: fill
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-