Skip to main content

VectorObject

Struct VectorObject 

Source
pub struct VectorObject {
    pub header: Vec<u8>,
    pub point_size: usize,
    pub points: Vec<Vec<u8>>,
}
Expand description

One stroke or shape. header and every point keep their raw bytes.

Fields§

§header: Vec<u8>

The header bytes (its size is the first u32).

§point_size: usize

Bytes per point (from the header).

§points: Vec<Vec<u8>>

Each point’s bytes.

Implementations§

Source§

impl VectorObject

Source

pub fn header_size(&self) -> usize

Header size in bytes (88, 92 or 96 in CSP files; 24 for some old objects).

Source

pub fn flags(&self) -> u32

Header flags (u32 at +20).

Source

pub fn is_closed(&self) -> bool

The shape is closed (FLAG_CLOSED).

Source

pub fn bbox(&self) -> [i32; 4]

Bounding box in layer pixels (x0, y0, x1, y1).

Source

pub fn set_bbox(&mut self, bbox: [i32; 4])

Sets the bounding box.

Source

pub fn main_color(&self) -> [u8; 3]

Main colour as 8-bit RGB (each channel is stored as 32 bits whose top byte is the 8-bit value).

Source

pub fn sub_color(&self) -> [u8; 3]

Sub colour as 8-bit RGB.

Source

pub fn opacity(&self) -> f64

Opacity 0.0–1.0 (f64 at +64).

Source

pub fn brush_size(&self) -> Option<f64>

Brush size in pixels (None for header layouts without one).

Source

pub fn set_brush_size(&mut self, size: f64)

Sets the brush size, for header layouts that have one.

Source

pub fn brush_styles(&self) -> Vec<u32>

Brush style ids (BrushStyle.MainId) the header refers to.

Source

pub fn shape_kind(&self) -> Option<u32>

The first settings word of a header-96 object (balloons and frames), which names the kind of shape: 0x130 a balloon, 0x111 or 0x311 a balloon’s tail, 0x410 a frame (values seen in the corpus).

Source

pub fn is_balloon_tail(&self) -> bool

A balloon’s tail (drawn with the line of the balloon before it).

Source

pub fn point(&self, index: usize) -> Option<Point>

The typed view of point index.

Source

pub fn coordinates(&self) -> Vec<(f64, f64)>

(x, y) of every point, in layer pixels.

Source

pub fn transform(&mut self, scale: f64, dx: f64, dy: f64)

Move and scale every coordinate (p * scale + offset), with the bounding boxes and brush size following.

Source§

impl VectorObject

Source

pub fn brush_style(&self) -> Option<u32>

The brush style id (BrushStyle.MainId) a new object copying this one should use: the only id of an 88-byte header, the one at +76 of larger headers (the second; the first of a 92-byte header can be 0).

Source

pub fn new_line(line: &NewVectorLine, brush_style: u32) -> Option<VectorObject>

A black line drawn with brush style brush_style. None for lines with fewer than two points.

Source

pub fn new_frame( frame: &NewFrame, template: &FrameTemplate, brush_style: u32, ) -> Option<VectorObject>

A closed frame border laid out like template, drawn with brush style brush_style. None for outlines with fewer than three points.

Trait Implementations§

Source§

impl Clone for VectorObject

Source§

fn clone(&self) -> Self

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 VectorObject

Source§

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

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

impl PartialEq for VectorObject

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for VectorObject

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> 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
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.