abletk/abletk-common/src/brush.rs

44 lines
1.1 KiB
Rust
Executable File

/*
* Copyright (C) 2022 Umut İnan Erdoğan <umutinanerdogan@pm.me>
*
* 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 https://mozilla.org/MPL/2.0/.
*/
#[cfg(windows)]
use abletk_direct2d::brush::Brush as RawBrush;
#[cfg(target_os = "linux")]
use abletk_cairo::brush::Brush as RawBrush;
use crate::color::Color;
#[derive(Copy, Clone, Debug)]
pub enum Brush {
Solid(Color),
}
#[cfg(windows)]
impl From<Brush> for RawBrush {
fn from(brush: Brush) -> Self {
match brush {
Brush::Solid(color) => RawBrush::Solid(color.into()),
}
}
}
#[cfg(target_os = "linux")]
impl From<Brush> for RawBrush {
fn from(brush: Brush) -> Self {
match brush {
Brush::Solid(color) => RawBrush::Solid(
color.0.into(),
color.1.into(),
color.2.into(),
color.3.into(),
),
}
}
}