Skip to content

Commit b446746

Browse files
authored
Merge pull request #41 from Progi1984/fixPixelsSize
Fixed Drawing pixelsToPoints and twipsToPixels ratios
2 parents 1431994 + eca93ab commit b446746

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/Common/Drawing.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static function emuToPixels(int $pValue = 0): float
5858
*/
5959
public static function pixelsToPoints(int $pValue = 0): float
6060
{
61-
return $pValue * 0.67777777;
61+
return $pValue * 0.75;
6262
}
6363

6464
/**
@@ -74,7 +74,7 @@ public static function pointsToCentimeters(int $pValue = 0): float
7474
return 0;
7575
}
7676

77-
return (($pValue * 1.333333333) / self::DPI_96) * 2.54;
77+
return (($pValue / 0.75) / self::DPI_96) * 2.54;
7878
}
7979

8080
/**
@@ -90,7 +90,7 @@ public static function pointsToPixels(int $pValue = 0): float
9090
return 0;
9191
}
9292

93-
return $pValue * 1.333333333;
93+
return $pValue / 0.75;
9494
}
9595

9696
/**
@@ -227,7 +227,7 @@ public static function twipsToPixels(int $pValue = 0): float
227227
return 0;
228228
}
229229

230-
return round($pValue / 15.873984);
230+
return round($pValue / 15);
231231
}
232232

233233
/**

tests/Common/Tests/DrawingTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ public function testPixelsPoints(): void
6161
$value = rand(1, 100);
6262

6363
$this->assertEquals(0, Drawing::pixelsToPoints());
64-
$this->assertEquals($value * 0.67777777, Drawing::pixelsToPoints($value));
64+
$this->assertEquals($value * 0.75, Drawing::pixelsToPoints($value));
6565
$this->assertEquals(0, Drawing::pointsToPixels());
66-
$this->assertEquals($value * 1.333333333, Drawing::pointsToPixels($value));
66+
$this->assertEquals($value / 0.75, Drawing::pointsToPixels($value));
6767
}
6868

6969
public function testPointsCentimeters(): void
7070
{
7171
$value = rand(1, 100);
7272

7373
$this->assertEquals(0, Drawing::pointsToCentimeters());
74-
$this->assertEquals($value * 1.333333333 / Drawing::DPI_96 * 2.54, Drawing::pointsToCentimeters($value));
74+
$this->assertEquals($value / 0.75 / Drawing::DPI_96 * 2.54, Drawing::pointsToCentimeters($value));
7575
}
7676

7777
public function testTwips(): void
@@ -94,7 +94,7 @@ public function testTwips(): void
9494

9595
// Pixels
9696
$this->assertEquals(0, Drawing::twipsToPixels());
97-
$this->assertEquals(round($value / 15.873984), Drawing::twipsToPixels($value));
97+
$this->assertEquals(round($value / 15), Drawing::twipsToPixels($value));
9898
}
9999

100100
public function testHTML(): void

0 commit comments

Comments
 (0)