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:
parent
28b86490cc
commit
4302fe2e70
|
@ -40,6 +40,15 @@ impl Twips {
|
||||||
/// ```
|
/// ```
|
||||||
pub const ONE: Self = Self(Self::TWIPS_PER_PIXEL);
|
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,
|
/// 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.
|
/// not pixels. Use the [`from_pixels`] method to convert from pixel units.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue