-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
55 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,40 @@ | ||
class Font::FreeType::BBox { | ||
class Font::FreeType::BBox | ||
is Array { | ||
|
||
use Font::FreeType::Raw; | ||
use Font::FreeType::Raw::Defs; | ||
|
||
constant Dot6 = Font::FreeType::Raw::Defs::Dot6; | ||
|
||
has Numeric ($.x-min, $.y-min); | ||
has Numeric ($.x-max, $.y-max); | ||
method x-min is rw { self[0] } | ||
method y-min is rw { self[1] } | ||
method x-max is rw { self[2] } | ||
method y-max is rw { self[3] } | ||
method width { self[2] - self[0] } | ||
method height { self[3] - self[1] } | ||
|
||
submethod TWEAK(FT_BBox :$bbox!) { | ||
with $bbox { | ||
$!x-min = .x-min / Dot6; | ||
$!x-max = .x-max / Dot6; | ||
$!y-min = .y-min / Dot6; | ||
$!y-max = .y-max / Dot6; | ||
} | ||
multi method new(FT_BBox:D :bbox($_)!) { | ||
my ::?CLASS:D \bbox = self.bless; | ||
bbox.x-min = .x-min / Dot6; | ||
bbox.y-min = .y-min / Dot6; | ||
bbox.x-max = .x-max / Dot6; | ||
bbox.y-max = .y-max / Dot6; | ||
bbox; | ||
} | ||
|
||
method Array { | ||
[$!x-min, $!y-min, $!x-max, $!y-max]; | ||
multi method new(Array:D :bbox($_)! where .elems == 4) { | ||
my ::?CLASS:D \bbox = self.bless; | ||
bbox.x-min = .[0]; | ||
bbox.y-min = .[1]; | ||
bbox.x-max = .[2]; | ||
bbox.y-max = .[3]; | ||
bbox; | ||
} | ||
|
||
multi method new(|) { fail } | ||
|
||
method bounding-box { | ||
[floor(self.x-min), floor(self.y-min), | ||
ceiling(self.x-max), ceiling(self.y-max)] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters