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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
use draw_state::DrawState;
use types::{ self, Matrix2d, Scalar };
use deform::DeformGrid;
use {
CircleArc,
Ellipse,
Image,
ImageSize,
Line,
Polygon,
Rectangle,
};
pub trait Graphics: Sized {
type Texture: ImageSize;
fn clear_color(&mut self, color: [f32; 4]);
fn clear_stencil(&mut self, value: u8);
fn tri_list<F>(&mut self, draw_state: &DrawState, color: &[f32; 4], f: F)
where F: FnMut(&mut FnMut(&[f32]));
fn tri_list_uv<F>(
&mut self,
draw_state: &DrawState,
color: &[f32; 4],
texture: &<Self as Graphics>::Texture,
f: F
) where F: FnMut(&mut FnMut(&[f32], &[f32]));
#[inline(always)]
fn rectangle<R: Into<types::Rectangle>>(
&mut self,
r: &Rectangle,
rectangle: R,
draw_state: &DrawState,
transform: Matrix2d
) {
r.draw_tri(rectangle, draw_state, transform, self);
}
#[inline(always)]
fn polygon(
&mut self,
p: &Polygon,
polygon: types::Polygon,
draw_state: &DrawState,
transform: Matrix2d
) {
p.draw_tri(polygon, draw_state, transform, self);
}
#[inline(always)]
fn polygon_tween_lerp(
&mut self,
p: &Polygon,
polygons: types::Polygons,
tween_factor: Scalar,
draw_state: &DrawState,
transform: Matrix2d
) {
p.draw_tween_lerp_tri(polygons, tween_factor,
draw_state, transform, self);
}
#[inline(always)]
fn image(
&mut self,
image: &Image,
texture: &Self::Texture,
draw_state: &DrawState,
transform: Matrix2d
) {
image.draw_tri(texture, draw_state, transform, self);
}
#[inline(always)]
fn ellipse<R: Into<types::Rectangle>>(
&mut self,
e: &Ellipse,
rectangle: R,
draw_state: &DrawState,
transform: Matrix2d
) {
e.draw_tri(rectangle, draw_state, transform, self);
}
#[inline(always)]
fn line<L: Into<types::Line>>(
&mut self,
l: &Line,
line: L,
draw_state: &DrawState,
transform: Matrix2d
) {
l.draw_tri(line, draw_state, transform, self);
}
#[inline(always)]
fn circle_arc<R: Into<types::Rectangle>>(
&mut self,
c: &CircleArc,
rectangle: R,
draw_state: &DrawState,
transform: Matrix2d
) {
c.draw_tri(rectangle, draw_state, transform, self);
}
#[inline(always)]
fn deform_image(
&mut self,
d: &DeformGrid,
texture: &Self::Texture,
draw_state: &DrawState,
transform: Matrix2d
) {
d.draw_image_tri(texture, draw_state, transform, self);
}
}