1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use draw::{Brush, Path, StrokeParams, Transform};
use ui::UI;
use ui_sys::{self, uiDrawContext};
pub struct DrawContext {
ui_draw_context: *mut uiDrawContext,
}
impl DrawContext {
pub unsafe fn from_ui_draw_context(ui_draw_context: *mut uiDrawContext) -> DrawContext {
DrawContext {
ui_draw_context: ui_draw_context,
}
}
pub fn stroke(&self, ctx: &UI, path: &Path, brush: &Brush, stroke_params: &StrokeParams) {
unsafe {
let brush = brush.as_ui_draw_brush_ref(ctx);
let stroke_params = stroke_params.as_stroke_params_ref(ctx);
ui_sys::uiDrawStroke(
self.ui_draw_context,
path.ptr(),
brush.ptr(),
stroke_params.ptr(),
)
}
}
pub fn fill(&self, ctx: &UI, path: &Path, brush: &Brush) {
unsafe {
let brush = brush.as_ui_draw_brush_ref(ctx);
ui_sys::uiDrawFill(self.ui_draw_context, path.ptr(), brush.ptr())
}
}
pub fn transform(&self, _ctx: &UI, txform: &Transform) {
unsafe { ui_sys::uiDrawTransform(self.ui_draw_context, txform.ptr()) }
}
pub fn save(&self, _ctx: &UI) {
unsafe { ui_sys::uiDrawSave(self.ui_draw_context) }
}
pub fn restore(&self, _ctx: &UI) {
unsafe { ui_sys::uiDrawRestore(self.ui_draw_context) }
}
}