Skip to main content

RenderOptions

Struct RenderOptions 

Source
pub struct RenderOptions {
    pub width: f32,
    pub padding: Insets,
    pub scale: f32,
    pub theme: Theme,
    pub fonts: FontHandle,
    pub format: OutputFormat,
    pub images: HashMap<String, Vec<u8>>,
}
Expand description

渲染入参。链式覆写;default() = 720 逻辑宽、亮色、scale 2、PNG、默认字体句柄。

Fields§

§width: f32

逻辑内容宽(含左右内边距),默认 720。

§padding: Insets

页边距(逻辑像素)。

§scale: f32

超采样系数(输出 = 逻辑尺寸 × scale),默认 2.0。越大越清晰也越慢 / 越大。

§theme: Theme

视觉主题。

§fonts: FontHandle

字体栈句柄。

§format: OutputFormat

输出格式,默认 PNG。

§images: HashMap<String, Vec<u8>>

标记文本里 @名字 图片 → 字节。

Implementations§

Source§

impl RenderOptions

Source

pub fn with_width(self, w: f32) -> Self

设逻辑内容宽。

Source

pub fn with_padding(self, p: Insets) -> Self

设页边距(逻辑像素)。

Source

pub fn with_theme(self, t: Theme) -> Self

设主题。

Source

pub fn with_fonts(self, f: FontHandle) -> Self

设字体句柄。

Source

pub fn with_scale(self, s: f32) -> Self

设超采样系数(清晰度档位,见 fast/sharp/ultra 预设)。

Source

pub fn fast(self) -> Self

清晰度预设:快(scale 1)——最省、体积小,清晰度一般。

Source

pub fn standard(self) -> Self

清晰度预设:标准(scale 1.5)。

Source

pub fn sharp(self) -> Self

清晰度预设:清晰(scale 2,默认)。

Source

pub fn ultra(self) -> Self

清晰度预设:超清(scale 3)——最清晰也最慢 / 最大。

Source

pub fn with_format(self, f: OutputFormat) -> Self

设输出格式。

Source

pub fn png(self) -> Self

输出 PNG(无损,平衡压缩)。

Source

pub fn png_fast(self) -> Self

输出 PNG(无损,快压缩——更快但更大)。

Source

pub fn webp(self) -> Self

输出 WebP(无损,文字图首选)。画布单边 > 16383px 时编码报错。

Source

pub fn webp_or_png(self) -> Self

输出 WebP,但画布单边 > 16383px(WebP 上限)时自动落 PNG。

Trait Implementations§

Source§

impl Clone for RenderOptions

Source§

fn clone(&self) -> RenderOptions

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 Default for RenderOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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 = 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.