blob: 3debf516ae19d54690fbaeedf05c7e8b0ace8d01 (
plain)
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
|
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// external
use cairo;
use usvg;
pub trait ReCairoContextExt {
fn set_source_color(&self, color: &usvg::Color, opacity: usvg::Opacity);
fn reset_source_rgba(&self);
}
impl ReCairoContextExt for cairo::Context {
fn set_source_color(&self, color: &usvg::Color, opacity: usvg::Opacity) {
self.set_source_rgba(
color.red as f64 / 255.0,
color.green as f64 / 255.0,
color.blue as f64 / 255.0,
*opacity,
);
}
fn reset_source_rgba(&self) {
self.set_source_rgba(0.0, 0.0, 0.0, 0.0);
}
}
|