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
use super::super::common::settings::*;
pub enum B2ParticleColor {}
extern {
fn b2ParticleColor_New(r: UInt8, g: UInt8, b: UInt8, a: UInt8) -> *mut B2ParticleColor;
fn b2ParticleColor_Delete(p: *mut B2ParticleColor);
fn b2ParticleColor_Set(p: *mut B2ParticleColor, r: UInt8, g: UInt8, b: UInt8, a: UInt8);
fn b2ParticleColor_IsZero(p: *mut B2ParticleColor) -> bool;
}
#[allow(raw_pointer_derive)]
#[derive(Clone)]
pub struct ParticleColor {
pub ptr: *mut B2ParticleColor
}
impl ParticleColor {
pub fn new(r: UInt8, g: UInt8, b: UInt8, a: UInt8) -> ParticleColor {
unsafe {
ParticleColor { ptr: b2ParticleColor_New(r, g, b, a) }
}
}
pub fn zero() -> ParticleColor {
ParticleColor::new(0, 0, 0, 0)
}
pub fn is_zero(&self) -> bool {
unsafe {
b2ParticleColor_IsZero(self.ptr)
}
}
pub fn ptr(&self) -> *mut B2ParticleColor {
self.ptr
}
pub fn set(&self, r: UInt8, g: UInt8, b: UInt8, a: UInt8) {
unsafe {
b2ParticleColor_Set(self.ptr, r, g, b, a);
}
}
}
impl Drop for ParticleColor {
fn drop(&mut self) {
unsafe {
b2ParticleColor_Delete(self.ptr);
}
}
}