Skip to content

Commit

Permalink
fix: remove rounding of units during conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
privateOmega committed Mar 19, 2023
1 parent 85801af commit e997641
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/utils/unit-conversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ export const pointRegex = /([\d.]+)pt/i;
export const cmRegex = /([\d.]+)cm/i;
export const inchRegex = /([\d.]+)in/i;

export const pixelToEMU = (pixelValue) => Math.round(pixelValue * 9525);
export const pixelToEMU = (pixelValue) => pixelValue * 9525;

export const EMUToPixel = (EMUValue) => Math.round(EMUValue / 9525);
export const EMUToPixel = (EMUValue) => EMUValue / 9525;

export const TWIPToEMU = (TWIPValue) => Math.round(TWIPValue * 635);
export const TWIPToEMU = (TWIPValue) => TWIPValue * 635;

export const EMUToTWIP = (EMUValue) => Math.round(EMUValue / 635);
export const EMUToTWIP = (EMUValue) => EMUValue / 635;

export const pointToTWIP = (pointValue) => Math.round(pointValue * 20);
export const pointToTWIP = (pointValue) => pointValue * 20;

export const TWIPToPoint = (TWIPValue) => Math.round(TWIPValue / 20);
export const TWIPToPoint = (TWIPValue) => TWIPValue / 20;

export const pointToHIP = (pointValue) => Math.round(pointValue * 2);
export const pointToHIP = (pointValue) => pointValue * 2;

export const HIPToPoint = (HIPValue) => Math.round(HIPValue / 2);
export const HIPToPoint = (HIPValue) => HIPValue / 2;

export const HIPToTWIP = (HIPValue) => Math.round(HIPValue * 10);
export const HIPToTWIP = (HIPValue) => HIPValue * 10;

export const TWIPToHIP = (TWIPValue) => Math.round(TWIPValue / 10);
export const TWIPToHIP = (TWIPValue) => TWIPValue / 10;

export const pixelToTWIP = (pixelValue) => EMUToTWIP(pixelToEMU(pixelValue));

Expand All @@ -32,7 +32,7 @@ export const pixelToHIP = (pixelValue) => TWIPToHIP(EMUToTWIP(pixelToEMU(pixelVa

export const HIPToPixel = (HIPValue) => EMUToPixel(TWIPToEMU(HIPToTWIP(HIPValue)));

export const inchToPoint = (inchValue) => Math.round(inchValue * 72);
export const inchToPoint = (inchValue) => inchValue * 72;

export const inchToTWIP = (inchValue) => pointToTWIP(inchToPoint(inchValue));

Expand All @@ -44,9 +44,9 @@ export const pixelToPoint = (pixelValue) => HIPToPoint(pixelToHIP(pixelValue));

export const pointToPixel = (pointValue) => HIPToPixel(pointToHIP(pointValue));

export const EIPToPoint = (EIPValue) => Math.round(EIPValue / 8);
export const EIPToPoint = (EIPValue) => EIPValue / 8;

export const pointToEIP = (PointValue) => Math.round(PointValue * 8);
export const pointToEIP = (PointValue) => PointValue * 8;

export const pixelToEIP = (pixelValue) => pointToEIP(pixelToPoint(pixelValue));

Expand Down

0 comments on commit e997641

Please sign in to comment.