Skip to main content

Dc

Struct Dc 

Source
pub struct Dc {
    pub clip: [i32; 4],
    pub ox: i32,
    pub oy: i32,
    pub w: i32,
    pub h: i32,
    pub color: u32,
    pub opac: u32,
    pub pcol: [u32; 4],
    pub pcol32: u32,
    pub ia: u32,
    pub row0: i32,
    /* private fields */
}
Expand description

the draw context of a target: clip (x0, y0, x1, y1 exclusive, in target pixels), origin, colour (straight and premultiplied), opacity

Fields§

§clip: [i32; 4]§ox: i32§oy: i32§w: i32§h: i32§color: u32§opac: u32§pcol: [u32; 4]§pcol32: u32§ia: u32§row0: i32

the target row in the surface’s first row (begin_rows: a band of a taller target); 0 otherwise. The fills and blits here, the rasterizer (paths, shapes, panels) and the text engine’s glyph blits honour it; other row writers (tmask, gradient, flood) expect 0.

Implementations§

Source§

impl Dc

Source

pub fn new(w: i32, h: i32) -> Dc

a context for a w x h target: clip = the whole target, colour opaque black [gfx_init]

Source

pub fn begin(&mut self, sf: &Surface)

draw into another target: clip, origin and opacity of the current one are saved; the clip becomes the whole new target, the origin 0 [gfx_begin]

Source

pub fn begin_rows(&mut self, sf: &Surface, row0: i32, h: i32)

begin for a band: sf holds rows row0 .. row0 + sf.h of a target h rows high. Drawing keeps the target’s coordinates (clip, origin, paths, glyph positions), so a band gets the bytes the whole target would get there; the clip starts as the band’s rows.

Source

pub fn end(&mut self)

back to the previous target with its clip, origin and opacity [gfx_end]

Source

pub fn set_color(&mut self, argb: u32)

store the colour and its premultiplied forms [gfx_set_color]

Source

pub fn get_color(&self) -> u32

Source

pub fn set_opacity(&mut self, op: u32)

global opacity 0..255 (multiplies every alpha)

Source

pub fn origin(&mut self, x: i32, y: i32)

Source

pub fn translate(&mut self, dx: i32, dy: i32)

Source

pub fn clip_push(&mut self, x: i32, y: i32, w: i32, h: i32)

save the clip and intersect it with the rectangle (origin-relative)

Source

pub fn clip_pop(&mut self)

Source

pub fn clip_rect(&self, x: i32, y: i32, w: i32, h: i32) -> Option<[i32; 4]>

origin-relative rectangle -> clipped target rectangle (x0, y0, x1, y1), or None

Source

pub fn fill(&self, sf: &mut Surface, x: i32, y: i32, w: i32, h: i32)

blend the colour over a rectangle (A8 targets: store the alpha) [gfx_fill]

Source

pub fn clear(&self, sf: &mut Surface, argb: u32)

replace every pixel inside the clip by argb (premultiplied, no blending) [gfx_clear]

Source

pub fn hline(&self, sf: &mut Surface, x: i32, y: i32, w: i32)

Source

pub fn vline(&self, sf: &mut Surface, x: i32, y: i32, h: i32)

Source

pub fn frame(&self, sf: &mut Surface, x: i32, y: i32, w: i32, h: i32)

1-pixel outline inside the rectangle [gfx_frame]

Source

pub fn blit(&self, sf: &mut Surface, src: &Surface, x: i32, y: i32)

draw a surface at x, y: premultiplied over (x opacity), XRGB sources are copied (a large copy in row bands on the loop of set_parallel, COPY_PAR_MIN) [gfx_blit]

Source

pub fn blit_scaled( &self, sf: &mut Surface, src: &Surface, x: i32, y: i32, w: i32, h: i32, )

nearest-neighbour blit scaled to w x h (over) [gfx_blit_scaled]

Auto Trait Implementations§

§

impl Forget for Dc

§

impl Freeze for Dc

§

impl Move for Dc

§

impl RefUnwindSafe for Dc

§

impl Send for Dc

§

impl Sync for Dc

§

impl Unpin for Dc

§

impl UnsafeUnpin for Dc

§

impl UnwindSafe for Dc

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