mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
updated calculation of border-radius
This commit is contained in:
parent
667921d993
commit
f6c584adc2
@ -202,40 +202,32 @@ export const parseBoundCurves = (
|
|||||||
borders: Array<Border>,
|
borders: Array<Border>,
|
||||||
borderRadius: Array<BorderRadius>
|
borderRadius: Array<BorderRadius>
|
||||||
): BoundCurves => {
|
): BoundCurves => {
|
||||||
const HALF_WIDTH = bounds.width / 2;
|
let tlh = borderRadius[CORNER.TOP_LEFT][H].getAbsoluteValue(bounds.width);
|
||||||
const HALF_HEIGHT = bounds.height / 2;
|
let tlv = borderRadius[CORNER.TOP_LEFT][V].getAbsoluteValue(bounds.height);
|
||||||
const tlh =
|
let trh = borderRadius[CORNER.TOP_RIGHT][H].getAbsoluteValue(bounds.width);
|
||||||
borderRadius[CORNER.TOP_LEFT][H].getAbsoluteValue(bounds.width) < HALF_WIDTH
|
let trv = borderRadius[CORNER.TOP_RIGHT][V].getAbsoluteValue(bounds.height);
|
||||||
? borderRadius[CORNER.TOP_LEFT][H].getAbsoluteValue(bounds.width)
|
let brh = borderRadius[CORNER.BOTTOM_RIGHT][H].getAbsoluteValue(bounds.width);
|
||||||
: HALF_WIDTH;
|
let brv = borderRadius[CORNER.BOTTOM_RIGHT][V].getAbsoluteValue(bounds.height);
|
||||||
const tlv =
|
let blh = borderRadius[CORNER.BOTTOM_LEFT][H].getAbsoluteValue(bounds.width);
|
||||||
borderRadius[CORNER.TOP_LEFT][V].getAbsoluteValue(bounds.height) < HALF_HEIGHT
|
let blv = borderRadius[CORNER.BOTTOM_LEFT][V].getAbsoluteValue(bounds.height);
|
||||||
? borderRadius[CORNER.TOP_LEFT][V].getAbsoluteValue(bounds.height)
|
|
||||||
: HALF_HEIGHT;
|
const factors = [];
|
||||||
const trh =
|
factors.push((tlh + trh) / bounds.width);
|
||||||
borderRadius[CORNER.TOP_RIGHT][H].getAbsoluteValue(bounds.width) < HALF_WIDTH
|
factors.push((blh + brh) / bounds.width);
|
||||||
? borderRadius[CORNER.TOP_RIGHT][H].getAbsoluteValue(bounds.width)
|
factors.push((tlv + blv) / bounds.height);
|
||||||
: HALF_WIDTH;
|
factors.push((trv + brv) / bounds.height);
|
||||||
const trv =
|
let maxFactor = Math.max(...factors);
|
||||||
borderRadius[CORNER.TOP_RIGHT][V].getAbsoluteValue(bounds.height) < HALF_HEIGHT
|
|
||||||
? borderRadius[CORNER.TOP_RIGHT][V].getAbsoluteValue(bounds.height)
|
if (maxFactor > 1) {
|
||||||
: HALF_HEIGHT;
|
tlh = tlh / maxFactor;
|
||||||
const brh =
|
tlv = tlv / maxFactor;
|
||||||
borderRadius[CORNER.BOTTOM_RIGHT][H].getAbsoluteValue(bounds.width) < HALF_WIDTH
|
trh = trh / maxFactor;
|
||||||
? borderRadius[CORNER.BOTTOM_RIGHT][H].getAbsoluteValue(bounds.width)
|
trv = trv / maxFactor;
|
||||||
: HALF_WIDTH;
|
brh = brh / maxFactor;
|
||||||
const brv =
|
brv = brv / maxFactor;
|
||||||
borderRadius[CORNER.BOTTOM_RIGHT][V].getAbsoluteValue(bounds.height) < HALF_HEIGHT
|
blh = blh / maxFactor;
|
||||||
? borderRadius[CORNER.BOTTOM_RIGHT][V].getAbsoluteValue(bounds.height)
|
blv = blv / maxFactor;
|
||||||
: HALF_HEIGHT;
|
}
|
||||||
const blh =
|
|
||||||
borderRadius[CORNER.BOTTOM_LEFT][H].getAbsoluteValue(bounds.width) < HALF_WIDTH
|
|
||||||
? borderRadius[CORNER.BOTTOM_LEFT][H].getAbsoluteValue(bounds.width)
|
|
||||||
: HALF_WIDTH;
|
|
||||||
const blv =
|
|
||||||
borderRadius[CORNER.BOTTOM_LEFT][V].getAbsoluteValue(bounds.height) < HALF_HEIGHT
|
|
||||||
? borderRadius[CORNER.BOTTOM_LEFT][V].getAbsoluteValue(bounds.height)
|
|
||||||
: HALF_HEIGHT;
|
|
||||||
|
|
||||||
const topWidth = bounds.width - trh;
|
const topWidth = bounds.width - trh;
|
||||||
const rightHeight = bounds.height - brv;
|
const rightHeight = bounds.height - brv;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user