1use std::sync::{
2 Arc,
3 atomic::{AtomicU64, Ordering},
4};
5
6use argui_core::{Affine2D, Color, Rect, Size};
7
8use crate::{ClipChain, ImageFit};
9
10#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
11pub struct VectorId(pub u64);
12
13static NEXT_VECTOR_ID: AtomicU64 = AtomicU64::new(1);
14
15impl VectorId {
16 #[must_use]
17 pub fn fresh() -> Self {
18 let id = NEXT_VECTOR_ID.fetch_add(1, Ordering::Relaxed);
19 assert_ne!(id, u64::MAX, "vector handle space exhausted");
20 Self(id)
21 }
22}
23
24#[derive(Clone, Debug, PartialEq)]
26pub struct VectorAsset {
27 pub id: VectorId,
28 pub size: Size,
29 pub svg: Arc<[u8]>,
30 pub tintable: bool,
31}
32
33#[derive(Clone, Debug, PartialEq)]
34pub struct VectorPrimitive {
35 pub vector: VectorId,
36 pub bounds: Rect,
37 pub fit: ImageFit,
38 pub color: Color,
39 pub opacity: f32,
40 pub transform: Affine2D,
41 pub clips: ClipChain,
42}