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: i32the 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
impl Dc
Sourcepub fn new(w: i32, h: i32) -> Dc
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]
Sourcepub fn begin(&mut self, sf: &Surface)
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]
Sourcepub fn begin_rows(&mut self, sf: &Surface, row0: i32, h: i32)
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.
Sourcepub fn set_color(&mut self, argb: u32)
pub fn set_color(&mut self, argb: u32)
store the colour and its premultiplied forms [gfx_set_color]
pub fn get_color(&self) -> u32
Sourcepub fn set_opacity(&mut self, op: u32)
pub fn set_opacity(&mut self, op: u32)
global opacity 0..255 (multiplies every alpha)
pub fn origin(&mut self, x: i32, y: i32)
pub fn translate(&mut self, dx: i32, dy: i32)
Sourcepub fn clip_push(&mut self, x: i32, y: i32, w: i32, h: i32)
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)
pub fn clip_pop(&mut self)
Sourcepub fn clip_rect(&self, x: i32, y: i32, w: i32, h: i32) -> Option<[i32; 4]>
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
Sourcepub fn fill(&self, sf: &mut Surface, x: i32, y: i32, w: i32, h: i32)
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]
Sourcepub fn clear(&self, sf: &mut Surface, argb: u32)
pub fn clear(&self, sf: &mut Surface, argb: u32)
replace every pixel inside the clip by argb (premultiplied, no blending) [gfx_clear]
pub fn hline(&self, sf: &mut Surface, x: i32, y: i32, w: i32)
pub fn vline(&self, sf: &mut Surface, x: i32, y: i32, h: i32)
Sourcepub fn frame(&self, sf: &mut Surface, x: i32, y: i32, w: i32, h: i32)
pub fn frame(&self, sf: &mut Surface, x: i32, y: i32, w: i32, h: i32)
1-pixel outline inside the rectangle [gfx_frame]