swf: Add Twips::HALF

Twips::HALF represents 10 twips, i.e. 0.5 pixels.
This constant is useful when calculating exact positions of lines
to be drawn, as they are often drawn on whole pixels.
This commit is contained in:
Kamil Jarosz 2024-05-28 02:20:24 +02:00
parent 28b86490cc
commit 4302fe2e70
1 changed files with 9 additions and 0 deletions

View File

@ -40,6 +40,15 @@ impl Twips {
/// ```
pub const ONE: Self = Self(Self::TWIPS_PER_PIXEL);
/// The `Twips` object with a value of `0.5` pixels.
///
/// # Examples
///
/// ```rust
/// assert_eq!(swf::Twips::HALF.to_pixels(), 0.5);
/// ```
pub const HALF: Self = Self(Self::TWIPS_PER_PIXEL / 2);
/// Creates a new `Twips` object. Note that the `twips` value is in twips,
/// not pixels. Use the [`from_pixels`] method to convert from pixel units.
///