Skip to content

Commit 3d79639

Browse files
committed
Merge remote-tracking branch 'origin/main' into style
2 parents 6db68ec + dc990fe commit 3d79639

28 files changed

Lines changed: 885 additions & 551 deletions

File tree

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
pub const CORNER: &str = "corner";
2+
pub const CORNERS: &str = "corners";
3+
pub const RADIUS: &str = "radius";
4+
pub const CENTER: &str = "center"; // also the middle mouse button
5+
6+
pub const ROUND: &str = "round"; // caps and joins
7+
pub const SQUARE: &str = "square";
8+
pub const PROJECT: &str = "project";
9+
pub const MITER: &str = "miter";
10+
pub const BEVEL: &str = "bevel";
11+
12+
pub const POLYGON: &str = "polygon";
13+
pub const POINTS: &str = "points";
14+
pub const LINES: &str = "lines";
15+
pub const TRIANGLES: &str = "triangles";
16+
pub const TRIANGLE_FAN: &str = "triangle_fan";
17+
pub const TRIANGLE_STRIP: &str = "triangle_strip";
18+
pub const QUADS: &str = "quads";
19+
pub const QUAD_STRIP: &str = "quad_strip";
20+
pub const LINE_STRIP: &str = "line_strip"; // geometry topology; no begin_shape equivalent
21+
22+
pub const OPEN: &str = "open";
23+
pub const CHORD: &str = "chord";
24+
pub const PIE: &str = "pie";
25+
pub const CLOSE: bool = true;
26+
27+
pub const LEFT: &str = "left";
28+
pub const RIGHT: &str = "right";
29+
30+
pub const NEAREST: &str = "nearest";
31+
pub const CLAMP: &str = "clamp";
32+
pub const REPEAT: &str = "repeat";
33+
pub const MIRROR: &str = "mirror";
34+
35+
pub const SRGB: &str = "srgb";
36+
pub const LINEAR: &str = "linear"; // also the Sampler filter
37+
pub const HSL: &str = "hsl";
38+
pub const HSV: &str = "hsv";
39+
pub const HWB: &str = "hwb";
40+
pub const OKLAB: &str = "oklab";
41+
pub const OKLCH: &str = "oklch";
42+
pub const LAB: &str = "lab";
43+
pub const LCH: &str = "lch";
44+
pub const XYZ: &str = "xyz";
45+
46+
pub const PI: f32 = std::f32::consts::PI;
47+
pub const TWO_PI: f32 = std::f32::consts::TAU;
48+
pub const HALF_PI: f32 = std::f32::consts::FRAC_PI_2;
49+
pub const QUARTER_PI: f32 = std::f32::consts::FRAC_PI_4;
50+
pub const TAU: f32 = std::f32::consts::TAU;
51+
pub const DEG_TO_RAD: f32 = std::f32::consts::PI / 180.0;
52+
pub const RAD_TO_DEG: f32 = 180.0 / std::f32::consts::PI;
53+
54+
// Key codes stay numeric (compared against `key_code`); values must match `key_code_to_u32`.
55+
56+
pub const KEY_A: u32 = 65;
57+
pub const KEY_B: u32 = 66;
58+
pub const KEY_C: u32 = 67;
59+
pub const KEY_D: u32 = 68;
60+
pub const KEY_E: u32 = 69;
61+
pub const KEY_F: u32 = 70;
62+
pub const KEY_G: u32 = 71;
63+
pub const KEY_H: u32 = 72;
64+
pub const KEY_I: u32 = 73;
65+
pub const KEY_J: u32 = 74;
66+
pub const KEY_K: u32 = 75;
67+
pub const KEY_L: u32 = 76;
68+
pub const KEY_M: u32 = 77;
69+
pub const KEY_N: u32 = 78;
70+
pub const KEY_O: u32 = 79;
71+
pub const KEY_P: u32 = 80;
72+
pub const KEY_Q: u32 = 81;
73+
pub const KEY_R: u32 = 82;
74+
pub const KEY_S: u32 = 83;
75+
pub const KEY_T: u32 = 84;
76+
pub const KEY_U: u32 = 85;
77+
pub const KEY_V: u32 = 86;
78+
pub const KEY_W: u32 = 87;
79+
pub const KEY_X: u32 = 88;
80+
pub const KEY_Y: u32 = 89;
81+
pub const KEY_Z: u32 = 90;
82+
83+
pub const KEY_0: u32 = 48;
84+
pub const KEY_1: u32 = 49;
85+
pub const KEY_2: u32 = 50;
86+
pub const KEY_3: u32 = 51;
87+
pub const KEY_4: u32 = 52;
88+
pub const KEY_5: u32 = 53;
89+
pub const KEY_6: u32 = 54;
90+
pub const KEY_7: u32 = 55;
91+
pub const KEY_8: u32 = 56;
92+
pub const KEY_9: u32 = 57;
93+
94+
pub const SPACE: u32 = 32;
95+
pub const QUOTE: u32 = 39;
96+
pub const COMMA: u32 = 44;
97+
pub const MINUS: u32 = 45;
98+
pub const PERIOD: u32 = 46;
99+
pub const SLASH: u32 = 47;
100+
pub const SEMICOLON: u32 = 59;
101+
pub const EQUAL: u32 = 61;
102+
pub const BRACKET_LEFT: u32 = 91;
103+
pub const BACKSLASH: u32 = 92;
104+
pub const BRACKET_RIGHT: u32 = 93;
105+
pub const BACKQUOTE: u32 = 96;
106+
107+
pub const ESCAPE: u32 = 256;
108+
pub const ENTER: u32 = 257;
109+
pub const TAB: u32 = 258;
110+
pub const BACKSPACE: u32 = 259;
111+
pub const INSERT: u32 = 260;
112+
pub const DELETE: u32 = 261;
113+
pub const UP: u32 = 265;
114+
pub const DOWN: u32 = 264;
115+
pub const LEFT_ARROW: u32 = 263;
116+
pub const RIGHT_ARROW: u32 = 262;
117+
pub const PAGE_UP: u32 = 266;
118+
pub const PAGE_DOWN: u32 = 267;
119+
pub const HOME: u32 = 268;
120+
pub const END: u32 = 269;
121+
122+
pub const SHIFT: u32 = 340;
123+
pub const CONTROL: u32 = 341;
124+
pub const ALT: u32 = 342;
125+
pub const SUPER: u32 = 343;
126+
127+
pub const F1: u32 = 290;
128+
pub const F2: u32 = 291;
129+
pub const F3: u32 = 292;
130+
pub const F4: u32 = 293;
131+
pub const F5: u32 = 294;
132+
pub const F6: u32 = 295;
133+
pub const F7: u32 = 296;
134+
pub const F8: u32 = 297;
135+
pub const F9: u32 = 298;
136+
pub const F10: u32 = 299;
137+
pub const F11: u32 = 300;
138+
pub const F12: u32 = 301;

crates/processing_core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pub mod config;
2+
pub mod constants;
23
pub mod error;
34

45
use std::cell::RefCell;

crates/processing_ffi/src/lib.rs

Lines changed: 164 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -520,24 +520,32 @@ pub extern "C" fn processing_reset_matrix(graphics_id: u64) {
520520
/// - graphics_id is a valid ID returned from graphics_create.
521521
/// - This is called from the same thread as init.
522522
#[unsafe(no_mangle)]
523-
pub extern "C" fn processing_translate(graphics_id: u64, x: f32, y: f32) {
523+
pub extern "C" fn processing_translate(graphics_id: u64, x: f32, y: f32, z: f32) {
524524
error::clear_error();
525525
let graphics_entity = Entity::from_bits(graphics_id);
526526
error::check(|| {
527-
graphics_record_command(graphics_entity, DrawCommand::Translate(Vec2::new(x, y)))
527+
graphics_record_command(graphics_entity, DrawCommand::Translate(Vec3::new(x, y, z)))
528528
});
529529
}
530530

531-
/// Rotate the coordinate system.
531+
/// Rotate the coordinate system by `angle` about the axis (x, y, z).
532532
///
533533
/// SAFETY:
534534
/// - graphics_id is a valid ID returned from graphics_create.
535535
/// - This is called from the same thread as init.
536536
#[unsafe(no_mangle)]
537-
pub extern "C" fn processing_rotate(graphics_id: u64, angle: f32) {
537+
pub extern "C" fn processing_rotate(graphics_id: u64, angle: f32, x: f32, y: f32, z: f32) {
538538
error::clear_error();
539539
let graphics_entity = Entity::from_bits(graphics_id);
540-
error::check(|| graphics_record_command(graphics_entity, DrawCommand::Rotate { angle }));
540+
error::check(|| {
541+
graphics_record_command(
542+
graphics_entity,
543+
DrawCommand::Rotate {
544+
angle,
545+
axis: Vec3::new(x, y, z),
546+
},
547+
)
548+
});
541549
}
542550

543551
/// Scale the coordinate system.
@@ -546,10 +554,12 @@ pub extern "C" fn processing_rotate(graphics_id: u64, angle: f32) {
546554
/// - graphics_id is a valid ID returned from graphics_create.
547555
/// - This is called from the same thread as init.
548556
#[unsafe(no_mangle)]
549-
pub extern "C" fn processing_scale(graphics_id: u64, x: f32, y: f32) {
557+
pub extern "C" fn processing_scale(graphics_id: u64, x: f32, y: f32, z: f32) {
550558
error::clear_error();
551559
let graphics_entity = Entity::from_bits(graphics_id);
552-
error::check(|| graphics_record_command(graphics_entity, DrawCommand::Scale(Vec2::new(x, y))));
560+
error::check(|| {
561+
graphics_record_command(graphics_entity, DrawCommand::Scale(Vec3::new(x, y, z)))
562+
});
553563
}
554564

555565
/// Shear along the X axis.
@@ -1591,6 +1601,153 @@ pub unsafe extern "C" fn processing_image_readback(
15911601
});
15921602
}
15931603

1604+
/// Set the tint color applied to images.
1605+
///
1606+
/// SAFETY:
1607+
/// - graphics_id is a valid ID returned from graphics_create.
1608+
/// - This is called from the same thread as init.
1609+
#[unsafe(no_mangle)]
1610+
pub extern "C" fn processing_tint(graphics_id: u64, color: Color) {
1611+
error::clear_error();
1612+
let graphics_entity = Entity::from_bits(graphics_id);
1613+
error::check(|| {
1614+
let mode = graphics_get_color_mode(graphics_entity)?;
1615+
graphics_record_command(graphics_entity, DrawCommand::Tint(color.resolve(&mode)))
1616+
});
1617+
}
1618+
1619+
/// Remove the image tint.
1620+
///
1621+
/// SAFETY:
1622+
/// - graphics_id is a valid ID returned from graphics_create.
1623+
/// - This is called from the same thread as init.
1624+
#[unsafe(no_mangle)]
1625+
pub extern "C" fn processing_no_tint(graphics_id: u64) {
1626+
error::clear_error();
1627+
let graphics_entity = Entity::from_bits(graphics_id);
1628+
error::check(|| graphics_record_command(graphics_entity, DrawCommand::NoTint));
1629+
}
1630+
1631+
/// Set how image() interprets its coordinates (CORNER/CORNERS/CENTER/RADIUS).
1632+
///
1633+
/// SAFETY:
1634+
/// - graphics_id is a valid ID returned from graphics_create.
1635+
/// - This is called from the same thread as init.
1636+
#[unsafe(no_mangle)]
1637+
pub extern "C" fn processing_image_mode(graphics_id: u64, mode: u8) {
1638+
error::clear_error();
1639+
let graphics_entity = Entity::from_bits(graphics_id);
1640+
error::check(|| {
1641+
graphics_record_command(
1642+
graphics_entity,
1643+
DrawCommand::ImageMode(processing::prelude::ShapeMode::from(mode)),
1644+
)
1645+
});
1646+
}
1647+
1648+
/// Draw an image at (dx, dy) at its native size.
1649+
///
1650+
/// SAFETY:
1651+
/// - graphics_id and image_id are valid IDs from graphics_create/image_create.
1652+
/// - This is called from the same thread as init.
1653+
#[unsafe(no_mangle)]
1654+
pub extern "C" fn processing_image(graphics_id: u64, image_id: u64, dx: f32, dy: f32) {
1655+
error::clear_error();
1656+
let graphics_entity = Entity::from_bits(graphics_id);
1657+
let image_entity = Entity::from_bits(image_id);
1658+
error::check(|| {
1659+
graphics_record_command(
1660+
graphics_entity,
1661+
DrawCommand::Image {
1662+
entity: image_entity,
1663+
dx,
1664+
dy,
1665+
d_width: None,
1666+
d_height: None,
1667+
sx: None,
1668+
sy: None,
1669+
s_width: None,
1670+
s_height: None,
1671+
},
1672+
)
1673+
});
1674+
}
1675+
1676+
/// Draw an image at (dx, dy) scaled to (d_width, d_height).
1677+
///
1678+
/// SAFETY:
1679+
/// - graphics_id and image_id are valid IDs from graphics_create/image_create.
1680+
/// - This is called from the same thread as init.
1681+
#[unsafe(no_mangle)]
1682+
pub extern "C" fn processing_image_scaled(
1683+
graphics_id: u64,
1684+
image_id: u64,
1685+
dx: f32,
1686+
dy: f32,
1687+
d_width: f32,
1688+
d_height: f32,
1689+
) {
1690+
error::clear_error();
1691+
let graphics_entity = Entity::from_bits(graphics_id);
1692+
let image_entity = Entity::from_bits(image_id);
1693+
error::check(|| {
1694+
graphics_record_command(
1695+
graphics_entity,
1696+
DrawCommand::Image {
1697+
entity: image_entity,
1698+
dx,
1699+
dy,
1700+
d_width: Some(d_width),
1701+
d_height: Some(d_height),
1702+
sx: None,
1703+
sy: None,
1704+
s_width: None,
1705+
s_height: None,
1706+
},
1707+
)
1708+
});
1709+
}
1710+
1711+
/// Draw the (sx, sy, s_width, s_height) source region of an image into the
1712+
/// (dx, dy, d_width, d_height) destination rectangle.
1713+
///
1714+
/// SAFETY:
1715+
/// - graphics_id and image_id are valid IDs from graphics_create/image_create.
1716+
/// - This is called from the same thread as init.
1717+
#[unsafe(no_mangle)]
1718+
pub extern "C" fn processing_image_region(
1719+
graphics_id: u64,
1720+
image_id: u64,
1721+
dx: f32,
1722+
dy: f32,
1723+
d_width: f32,
1724+
d_height: f32,
1725+
sx: f32,
1726+
sy: f32,
1727+
s_width: f32,
1728+
s_height: f32,
1729+
) {
1730+
error::clear_error();
1731+
let graphics_entity = Entity::from_bits(graphics_id);
1732+
let image_entity = Entity::from_bits(image_id);
1733+
error::check(|| {
1734+
graphics_record_command(
1735+
graphics_entity,
1736+
DrawCommand::Image {
1737+
entity: image_entity,
1738+
dx,
1739+
dy,
1740+
d_width: Some(d_width),
1741+
d_height: Some(d_height),
1742+
sx: Some(sx),
1743+
sy: Some(sy),
1744+
s_width: Some(s_width),
1745+
s_height: Some(s_height),
1746+
},
1747+
)
1748+
});
1749+
}
1750+
15941751
#[unsafe(no_mangle)]
15951752
pub extern "C" fn processing_mode_3d(graphics_id: u64) {
15961753
error::clear_error();

crates/processing_glfw/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ workspace = true
88

99
[features]
1010
wayland = ["glfw/wayland"]
11-
x11 = []
11+
x11 = ["dep:x11"]
1212
static-link = ["glfw/static-link"]
1313

1414
[dependencies]
15+
x11 = { version = "2", features = ["xlib"], optional = true }
1516
bevy = { workspace = true }
1617
glfw = "0.60.0"
1718
processing_core = { workspace = true }

0 commit comments

Comments
 (0)