Struct sciter::graphics::Graphics [−][src]
pub struct Graphics(_);
Graphics object. Represents graphic surface of the element.
Methods
impl Graphics
[src]
impl Graphics
Save/restore graphics state.
pub fn save_state(&mut self) -> Result<State>
[src]
pub fn save_state(&mut self) -> Result<State>
Save the current graphics attributes on top of the internal state stack.
It will be restored automatically.
Example:
use sciter::graphics::{Image, rgb}; let mut image = Image::new((100, 100), false).unwrap(); image.paint(|gfx, size| { let mut gfx = gfx.save_state()?; gfx .line_width(6.0)? .line_color(rgb(0xD4, 0, 0))? .fill_color(rgb(0xD4, 0, 0))? .line((-30., 0.), (83., 0.))? ; Ok(()) }).unwrap();
impl Graphics
[src]
impl Graphics
Primitives drawing operations.
All operations use the current fill and stroke brushes.
pub fn line(&mut self, start: Pos, end: Pos) -> Result<&mut Self>
[src]
pub fn line(&mut self, start: Pos, end: Pos) -> Result<&mut Self>
Draw a line from the start
to the end
.
pub fn rectangle(
&mut self,
left_top: Pos,
right_bottom: Pos
) -> Result<&mut Self>
[src]
pub fn rectangle(
&mut self,
left_top: Pos,
right_bottom: Pos
) -> Result<&mut Self>
Draw a rectangle.
pub fn round_rect(
&mut self,
left_top: Pos,
right_bottom: Pos,
radius: Dim
) -> Result<&mut Self>
[src]
pub fn round_rect(
&mut self,
left_top: Pos,
right_bottom: Pos,
radius: Dim
) -> Result<&mut Self>
Draw a rounded rectangle with the same corners.
pub fn round_rect4(
&mut self,
left_top: Pos,
right_bottom: Pos,
radius: (Dim, Dim, Dim, Dim)
) -> Result<&mut Self>
[src]
pub fn round_rect4(
&mut self,
left_top: Pos,
right_bottom: Pos,
radius: (Dim, Dim, Dim, Dim)
) -> Result<&mut Self>
Draw a rounded rectangle with different corners.
pub fn ellipse(&mut self, xy: Pos, radii: Pos) -> Result<&mut Self>
[src]
pub fn ellipse(&mut self, xy: Pos, radii: Pos) -> Result<&mut Self>
Draw an ellipse.
pub fn circle(&mut self, xy: Pos, radius: Dim) -> Result<&mut Self>
[src]
pub fn circle(&mut self, xy: Pos, radius: Dim) -> Result<&mut Self>
Draw a circle.
pub fn arc(
&mut self,
xy: Pos,
rxy: Pos,
start: Angle,
sweep: Angle
) -> Result<&mut Self>
[src]
pub fn arc(
&mut self,
xy: Pos,
rxy: Pos,
start: Angle,
sweep: Angle
) -> Result<&mut Self>
Draw a closed arc.
pub fn star(
&mut self,
xy: Pos,
r1: Dim,
r2: Dim,
start: Angle,
rays: usize
) -> Result<&mut Self>
[src]
pub fn star(
&mut self,
xy: Pos,
r1: Dim,
r2: Dim,
start: Angle,
rays: usize
) -> Result<&mut Self>
Draw a star.
pub fn polygon(&mut self, points: &[Pos]) -> Result<&mut Self>
[src]
pub fn polygon(&mut self, points: &[Pos]) -> Result<&mut Self>
Draw a closed polygon.
pub fn polyline(&mut self, points: &[Pos]) -> Result<&mut Self>
[src]
pub fn polyline(&mut self, points: &[Pos]) -> Result<&mut Self>
Draw a polyline.
impl Graphics
[src]
impl Graphics
Drawing attributes.
pub fn fill_color(&mut self, color: Color) -> Result<&mut Self>
[src]
pub fn fill_color(&mut self, color: Color) -> Result<&mut Self>
Set the color for solid fills for subsequent drawings.
pub fn fill_mode(&mut self, is_even: bool) -> Result<&mut Self>
[src]
pub fn fill_mode(&mut self, is_even: bool) -> Result<&mut Self>
Set the even/odd rule of solid fills for subsequent drawings.
false
means "fill non zero".
pub fn no_fill(&mut self) -> Result<&mut Self>
[src]
pub fn no_fill(&mut self) -> Result<&mut Self>
Disables fills for subsequent drawing operations.
pub fn line_color(&mut self, color: Color) -> Result<&mut Self>
[src]
pub fn line_color(&mut self, color: Color) -> Result<&mut Self>
Set the line color for subsequent drawings.
pub fn line_width(&mut self, width: Dim) -> Result<&mut Self>
[src]
pub fn line_width(&mut self, width: Dim) -> Result<&mut Self>
Set the line width for subsequent drawings.
pub fn line_cap(&mut self, style: LINE_CAP) -> Result<&mut Self>
[src]
pub fn line_cap(&mut self, style: LINE_CAP) -> Result<&mut Self>
Set the line cap mode (stroke dash ending style) for subsequent drawings.
It determines how the end points of every line are drawn.
There are three possible values for this property and those are: BUTT
, ROUND
and SQUARE
.
By default this property is set to BUTT
.
pub fn line_join(&mut self, style: LINE_JOIN) -> Result<&mut Self>
[src]
pub fn line_join(&mut self, style: LINE_JOIN) -> Result<&mut Self>
Set the line join mode for subsequent drawings.
It determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together (degenerate segments with zero lengths, whose specified endpoints and control points are exactly at the same position, are skipped).
pub fn no_line(&mut self) -> Result<&mut Self>
[src]
pub fn no_line(&mut self) -> Result<&mut Self>
Disable outline drawing.
pub fn line_linear_gradient(
&mut self,
start: Pos,
end: Pos,
c1: Color,
c2: Color
) -> Result<&mut Self>
[src]
pub fn line_linear_gradient(
&mut self,
start: Pos,
end: Pos,
c1: Color,
c2: Color
) -> Result<&mut Self>
Setup parameters of a linear gradient of lines.
pub fn line_linear_gradients(
&mut self,
start: Pos,
end: Pos,
colors: &[(Color, Dim)]
) -> Result<&mut Self>
[src]
pub fn line_linear_gradients(
&mut self,
start: Pos,
end: Pos,
colors: &[(Color, Dim)]
) -> Result<&mut Self>
Setup parameters of a linear gradient of lines using multiple colors and color stop positions (0.0 ... 1.0)
.
pub fn fill_linear_gradient(
&mut self,
c1: Color,
c2: Color,
start: Pos,
end: Pos
) -> Result<&mut Self>
[src]
pub fn fill_linear_gradient(
&mut self,
c1: Color,
c2: Color,
start: Pos,
end: Pos
) -> Result<&mut Self>
Setup parameters of linear gradient fills.
pub fn fill_linear_gradients(
&mut self,
colors: &[(Color, Dim)],
start: Pos,
end: Pos
) -> Result<&mut Self>
[src]
pub fn fill_linear_gradients(
&mut self,
colors: &[(Color, Dim)],
start: Pos,
end: Pos
) -> Result<&mut Self>
Setup parameters of linear gradient fills using multiple colors and color stop positions (0.0 ... 1.0)
.
pub fn line_radial_gradient(
&mut self,
point: Pos,
radii: (Dim, Dim),
c1: Color,
c2: Color
) -> Result<&mut Self>
[src]
pub fn line_radial_gradient(
&mut self,
point: Pos,
radii: (Dim, Dim),
c1: Color,
c2: Color
) -> Result<&mut Self>
Setup parameters of a radial gradient of lines.
pub fn line_radial_gradients(
&mut self,
point: Pos,
radii: (Dim, Dim),
colors: &[(Color, Dim)]
) -> Result<&mut Self>
[src]
pub fn line_radial_gradients(
&mut self,
point: Pos,
radii: (Dim, Dim),
colors: &[(Color, Dim)]
) -> Result<&mut Self>
Setup parameters of a radial gradient of lines using multiple colors and color stop positions (0.0 ... 1.0)
.
pub fn fill_radial_gradient(
&mut self,
c1: Color,
c2: Color,
point: Pos,
radii: (Dim, Dim)
) -> Result<&mut Self>
[src]
pub fn fill_radial_gradient(
&mut self,
c1: Color,
c2: Color,
point: Pos,
radii: (Dim, Dim)
) -> Result<&mut Self>
Setup parameters of radial gradient of fills.
pub fn fill_radial_gradients(
&mut self,
colors: &[(Color, Dim)],
point: Pos,
radii: (Dim, Dim)
) -> Result<&mut Self>
[src]
pub fn fill_radial_gradients(
&mut self,
colors: &[(Color, Dim)],
point: Pos,
radii: (Dim, Dim)
) -> Result<&mut Self>
Setup parameters of radial gradient of fills using multiple colors and color stop positions (0.0 ... 1.0)
.
impl Graphics
[src]
impl Graphics
Affine transformations.
pub fn rotate(&mut self, radians: Angle) -> Result<&mut Self>
[src]
pub fn rotate(&mut self, radians: Angle) -> Result<&mut Self>
Rotate coordinate system on radians
angle.
pub fn rotate_around(
&mut self,
radians: Angle,
center: Pos
) -> Result<&mut Self>
[src]
pub fn rotate_around(
&mut self,
radians: Angle,
center: Pos
) -> Result<&mut Self>
Rotate coordinate system on radians
angle around the center
.
pub fn translate(&mut self, to_xy: Pos) -> Result<&mut Self>
[src]
pub fn translate(&mut self, to_xy: Pos) -> Result<&mut Self>
Move origin of coordinate system to the (to_x, to_y)
point.
pub fn scale(&mut self, sc_xy: Pos) -> Result<&mut Self>
[src]
pub fn scale(&mut self, sc_xy: Pos) -> Result<&mut Self>
Scale coordinate system.
(sc_x, sc_y)
are the scale factors in the horizontal and vertical directions respectively.
Both parameters must be positive numbers.
Values smaller than 1.0
reduce the unit size and values larger than 1.0
increase the unit size.
pub fn skew(&mut self, sh_xy: Pos) -> Result<&mut Self>
[src]
pub fn skew(&mut self, sh_xy: Pos) -> Result<&mut Self>
Setup a skewing (shearing) transformation.
pub fn transform(
&mut self,
scale_by: Pos,
skew_by: Pos,
move_to: Pos
) -> Result<&mut Self>
[src]
pub fn transform(
&mut self,
scale_by: Pos,
skew_by: Pos,
move_to: Pos
) -> Result<&mut Self>
Multiply the current transformation with the matrix described by the arguments.
It allows to scale, rotate, move and skew the context as described by:
scale_x skew_y move_x
[ skew_x scale_y move_y ]
0 0 1
where
scale_x
,scale_y
: horizontal and vertical scaling,skew_x
,skew_y
: horizontal and vertical shearing (skewing),move_x
,move_y
: horizontal and vertical moving.
pub fn transform_matrix(
&mut self,
m11: Dim,
m12: Dim,
m21: Dim,
m22: Dim,
dx: Dim,
dy: Dim
) -> Result<&mut Self>
[src]
pub fn transform_matrix(
&mut self,
m11: Dim,
m12: Dim,
m21: Dim,
m22: Dim,
dx: Dim,
dy: Dim
) -> Result<&mut Self>
Multiply the current transformation with the matrix described by the arguments.
It allows to scale, rotate, move and skew the context as described by:
m11 m21 dx
[ m12 m22 dy ]
0 0 1
m11
(scale_x
): horizontal scalingm12
(skew_x
): horizontal skewingm21
(skew_y
): vertical skewingm22
(scale_y
): vertical scalingdx
(move_x
): horizontal movingdy
(move_y
): vertical moving
impl Graphics
[src]
impl Graphics
Coordinate space.
pub fn world_to_screen(&self, xy: Pos) -> Result<Pos>
[src]
pub fn world_to_screen(&self, xy: Pos) -> Result<Pos>
Translate coordinates.
Translates coordinates from a coordinate system defined by rotate()
, scale()
, translate()
and/or skew()
to the screen coordinate system.
pub fn world_to_screen1(&self, length: Dim) -> Result<Dim>
[src]
pub fn world_to_screen1(&self, length: Dim) -> Result<Dim>
Translate coordinates.
Translates coordinates from a coordinate system defined by rotate()
, scale()
, translate()
and/or skew()
to the screen coordinate system.
pub fn screen_to_world(&self, xy: Pos) -> Result<Pos>
[src]
pub fn screen_to_world(&self, xy: Pos) -> Result<Pos>
Translate coordinates.
Translates coordinates from screen coordinate system to the one defined by rotate()
, scale()
, translate()
and/or skew()
.
pub fn screen_to_world1(&self, length: Dim) -> Result<Dim>
[src]
pub fn screen_to_world1(&self, length: Dim) -> Result<Dim>
Translate coordinates.
Translates coordinates from screen coordinate system to the one defined by rotate()
, scale()
, translate()
and/or skew()
.
impl Graphics
[src]
impl Graphics
Clipping.
pub fn push_clip_box(
&mut self,
left_top: Pos,
right_bottom: Pos,
opacity: Option<f32>
) -> Result<&mut Self>
[src]
pub fn push_clip_box(
&mut self,
left_top: Pos,
right_bottom: Pos,
opacity: Option<f32>
) -> Result<&mut Self>
Push a clip layer defined by the specified rectangle bounds.
pub fn push_clip_path(
&mut self,
path: &Path,
opacity: Option<f32>
) -> Result<&mut Self>
[src]
pub fn push_clip_path(
&mut self,
path: &Path,
opacity: Option<f32>
) -> Result<&mut Self>
Push a clip layer defined by the specified path
bounds.
pub fn pop_clip(&mut self) -> Result<&mut Self>
[src]
pub fn pop_clip(&mut self) -> Result<&mut Self>
Pop a clip layer set by previous push_clip_box()
or push_clip_path()
calls.
impl Graphics
[src]
impl Graphics
Image and path rendering.
pub fn draw_path(&mut self, path: &Path, mode: DRAW_PATH) -> Result<&mut Self>
[src]
pub fn draw_path(&mut self, path: &Path, mode: DRAW_PATH) -> Result<&mut Self>
Draw the path object using current fill and stroke brushes.
pub fn draw_image(&mut self, image: &Image, pos: Pos) -> Result<&mut Self>
[src]
pub fn draw_image(&mut self, image: &Image, pos: Pos) -> Result<&mut Self>
Draw the whole image onto the graphics surface.
With the current transformation applied (scale, rotation).
Performance: expensive.
pub fn draw_image_part(
&mut self,
image: &Image,
dst_pos: Pos,
dst_size: Size,
src_pos: POINT,
src_size: SIZE
) -> Result<&mut Self>
[src]
pub fn draw_image_part(
&mut self,
image: &Image,
dst_pos: Pos,
dst_size: Size,
src_pos: POINT,
src_size: SIZE
) -> Result<&mut Self>
Draw a part of the image onto the graphics surface.
With the current transformation applied (scale, rotation).
Performance: expensive.
pub fn blend_image(
&mut self,
image: &Image,
dst_pos: Pos,
opacity: f32
) -> Result<&mut Self>
[src]
pub fn blend_image(
&mut self,
image: &Image,
dst_pos: Pos,
opacity: f32
) -> Result<&mut Self>
Blend the image with the graphics surface.
No affine transformations.
Performance: less expensive.
pub fn blend_image_part(
&mut self,
image: &Image,
dst_pos: Pos,
opacity: f32,
src_pos: POINT,
src_size: SIZE
) -> Result<&mut Self>
[src]
pub fn blend_image_part(
&mut self,
image: &Image,
dst_pos: Pos,
opacity: f32,
src_pos: POINT,
src_size: SIZE
) -> Result<&mut Self>
Blend a part of the image with the graphics surface.
No affine transformations.
Performance: less expensive.
Trait Implementations
impl Drop for Graphics
[src]
impl Drop for Graphics
Destroy pointed graphics object.
impl Clone for Graphics
[src]
impl Clone for Graphics
Copies graphics object.
All allocated objects are reference counted so copying is just a matter of increasing reference counts.
fn clone(&self) -> Self
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl FromValue for Graphics
[src]
impl FromValue for Graphics
Get an Graphics
object contained in the Value
.
fn from_value(v: &Value) -> Option<Graphics>
[src]
fn from_value(v: &Value) -> Option<Graphics>
Converts value to specified type.
impl From<Graphics> for Value
[src]
impl From<Graphics> for Value
Store the Graphics
object as a Value
.
impl From<HGFX> for Graphics
[src]
impl From<HGFX> for Graphics
Construct Graphics object from HGFX
handle.