Skip to main content

DrawItem

Enum DrawItem 

Source
pub enum DrawItem {
    Text {
Show 14 fields x: f32, y: f32, font_id: u16, size: f32, width: f32, text: String, source: String, source_map: Vec<u32>, origin: Option<SourceRange>, pseudo_element: Option<NodeId>, features: Features, color: Color, glyphs: Vec<Glyph>, layer: i32,
}, Rect { x: f32, y: f32, w: f32, h: f32, color: Color, layer: i32, }, Image { x: f32, y: f32, w: f32, h: f32, asset: u32, alpha: u8, layer: i32, }, Background {
Show 13 fields x: f32, y: f32, w: f32, h: f32, radii: Corners, tile_x: f32, tile_y: f32, tile_w: f32, tile_h: f32, repeat: bool, asset: u32, alpha: u8, layer: i32,
}, Rounded { x: f32, y: f32, w: f32, h: f32, radii: Corners, ring: Edges, color: Color, layer: i32, }, }
Expand description

A single paint operation. Deliberately tiny: text, rules, images, and the rounded boxes a border radius draws.

Variants§

§

Text

A run of shaped glyphs sharing a font, size, and baseline.

Fields

§x: f32

Left edge of the run.

§y: f32

The run’s baseline.

§font_id: u16

Index into LayoutOutput::fonts.

§size: f32

Em size in points.

§width: f32

How far the run’s glyphs advance, in points: the run ends at x + width.

§text: String

The text the glyphs were shaped from, which the glyphs’ ranges index. A painter that draws characters rather than glyphs draws these.

§source: String

What the author wrote, where text-transform or small capitals made that differ from what was shaped, and empty where the two are the same. Text extraction and copy and paste return this rather than text: a title set in capitals is read back in the case it was written in.

§source_map: Vec<u32>

The offset in source of every byte boundary of text, so source_map[range.start]..source_map[range.end] is the source a glyph stands for. Empty alongside source.

§origin: Option<SourceRange>

Where the run was written: the content node it was shaped from and the bytes of that node’s own text it stands for. The runs that name one node tile it, so a cursor in the manuscript lands on a run and a run lands back on the manuscript. The text of ::before and ::after names the id of that pseudo-element. Absent on text the engine adds to the book: a folio, a running head, a scene break’s ornament, and a table’s header row set again on a later page.

§pseudo_element: Option<NodeId>

The pseudo-element the run was cut from: a drop cap, the line a paragraph opens on, or the text of ::before or ::after. origin still names the text it stands for.

§features: Features

The features the run was shaped with. A painter that draws characters asks the face for these; one that draws glyphs has the answer already.

§color: Color

What the glyphs are painted in.

§glyphs: Vec<Glyph>

The glyphs, in visual order.

§layer: i32

Which layer the run paints in.

§

Rect

Filled rectangle: rules, borders, backgrounds.

Fields

§x: f32

Left edge.

§y: f32

Top edge.

§w: f32

Width in points.

§h: f32

Height in points.

§color: Color

What the rectangle is filled with.

§layer: i32

Which layer the rectangle paints in.

§

Image

Placed image; asset indexes the asset table.

Fields

§x: f32

Left edge.

§y: f32

Top edge.

§w: f32

Width in points.

§h: f32

Height in points.

§asset: u32

Index into the asset table.

§alpha: u8

How much of the image shows, from 0 to 255, where 255 is all of it: opacity on the image and the blocks around it.

§layer: i32

Which layer the image paints in.

§

Background

An image painted behind a box: the page’s own, or a block’s border box.

The box is what the image is clipped to, and the tile is where one copy of it is drawn, which may reach outside the box. A painter clips to the box, draws the tile, and repeats the tile across and down the box where repeat asks for it.

Fields

§x: f32

Left edge of the box the image is painted behind.

§y: f32

Its top edge.

§w: f32

Its width in points.

§h: f32

Its height in points.

§radii: Corners

How far each corner of the box is rounded. The image is clipped to the rounded box.

§tile_x: f32

Left edge of the first tile.

§tile_y: f32

Its top edge.

§tile_w: f32

The width one copy of the image is drawn at.

§tile_h: f32

The height one copy is drawn at.

§repeat: bool

Whether the tile repeats to cover the box.

§asset: u32

Index into the asset table.

§alpha: u8

How much of the image shows, from 0 to 255, where 255 is all of it: opacity on the blocks the box belongs to.

§layer: i32

Which layer the image paints in.

§

Rounded

A filled box with rounded corners: a background, or a border drawn as a ring.

The outer shape is the box with its corners rounded by radii. Where ring is zero on all four edges, the whole shape is filled. Otherwise the fill is the band between the outer shape and an inner one: the box ring in from each edge, with the corners Corners::inside gives.

Fields

§x: f32

Left edge.

§y: f32

Top edge.

§w: f32

Width in points.

§h: f32

Height in points.

§radii: Corners

How far each corner is rounded.

§ring: Edges

How far in from each edge the fill reaches, in points. Zero on all four fills the whole shape.

§color: Color

What the shape is filled with.

§layer: i32

Which layer the shape paints in.

Implementations§

Source§

impl DrawItem

Source

pub const PAGE_BACKGROUND: i32 = i32::MIN

The layer a page’s own background paints in: under every layer a stylesheet can name. Where a stylesheet names no z-index, the text of a page still covers the background. A stylesheet that names this number paints over the background as well. The page puts its own background in first, and one layer keeps the order it arrived in.

Source

pub const PAGE_FURNITURE: i32 = i32::MAX

The layer a page’s margin boxes paint in: over every layer a stylesheet can name. A page number and a running head stay visible whatever layer the blocks of the book are raised to.

Source

pub fn layer(&self) -> i32

Which layer this item paints in. Higher paints later, over what a lower layer put down.

Trait Implementations§

Source§

impl Clone for DrawItem

Source§

fn clone(&self) -> DrawItem

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DrawItem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for DrawItem

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for DrawItem

Source§

fn eq(&self, other: &DrawItem) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for DrawItem

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for DrawItem

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Finish for T

§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

§

fn to_owned_table(&self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.