Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Pen pressure curve: Preferences › Tools shapes how pen pressure reaches every brush (#2195)

Tanish Manku8d23c62272aa
diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs
index 9e1ece118..880a21a45 100644
--- a/crates/engine/src/prefs.rs
+++ b/crates/engine/src/prefs.rs
@@ -314,6 +314,9 @@ pub struct Tools {
pub right_click_with_painting_tools: RightClickPaint,
/// Pen tablets: pressure, tilt and rotation reach the brush (off: a pen paints like a mouse).
pub use_tablet_pressure: bool,
+ /// Pen pressure response: `[input, output]` control points in 0..1 that the pen's pressure
+ /// passes through before it reaches any brush ([`PressureCurve`]). Linear by default.
+ pub pressure_curve: Vec<[f32; 2]>,
}
impl Default for Tools {
@@ -330,10 +333,106 @@ impl Default for Tools {
double_click_layer_mask_launches_select_and_mask: true,
right_click_with_painting_tools: RightClickPaint::BrushPicker,
use_tablet_pressure: true,
+ pressure_curve: vec![[0.0, 0.0], [1.0, 1.0]],
}
}
}
+/// Preferences › Tools › Pressure Curve, ready to evaluate: a monotone cubic (Fritsch–Carlson)
+/// through the control points, so a firmer press never gives less pressure. The points are
+/// sanitised here, not trusted: a whole-section update or a hand-edited preferences file can store
+/// anything. Non-finite points are dropped, the rest clamped to 0..1, sorted by input (one point
+/// per input), capped at [`Self::MAX_POINTS`], and their outputs made non-decreasing; before the
+/// first point and after the last the curve stays flat. Fewer than two usable points is linear.
+#[derive(Clone, Debug, PartialEq)]
+pub struct PressureCurve {
+ xs: Vec<f32>,
+ ys: Vec<f32>,
+ /// Tangents at the points.
+ ms: Vec<f32>,
+}
+
+impl PressureCurve {
+ pub const MAX_POINTS: usize = 16;
+
+ pub fn new(points: &[[f32; 2]]) -> Self {
+ let mut pts: Vec<[f32; 2]> =
+ points.iter().filter(|p| p[0].is_finite() && p[1].is_finite()).map(|p| [p[0].clamp(0.0, 1.0), p[1].clamp(0.0, 1.0)]).collect();
+ pts.sort_by(|a, b| a[0].total_cmp(&b[0]));
+ pts.dedup_by(|b, a| {
+ // Same input: keep the later point's output.
+ let same = (a[0] - b[0]).abs() < 1e-6;
+ if same {
+ a[1] = b[1];
+ }
+ same
+ });
+ pts.truncate(Self::MAX_POINTS);
+ if pts.len() < 2 {
+ pts = vec![[0.0, 0.0], [1.0, 1.0]];
+ }
+ let xs: Vec<f32> = pts.iter().map(|p| p[0]).collect();
+ let mut ys: Vec<f32> = pts.iter().map(|p| p[1]).collect();
+ for i in 1..ys.len() {
+ ys[i] = ys[i].max(ys[i - 1]);
+ }
+ // Fritsch–Carlson tangents: secant averages, zero at flat steps, limited so the cubic
+ // never overshoots (which keeps it monotone).
+ let n = xs.len();
+ let d: Vec<f32> = (0..n - 1).map(|k| (ys[k + 1] - ys[k]) / (xs[k + 1] - xs[k])).collect();
+ let mut ms = vec![0.0f32; n];
+ ms[0] = d[0];
+ ms[n - 1] = d[n - 2];
+ for k in 1..n - 1 {
+ ms[k] = if d[k - 1] * d[k] <= 0.0 { 0.0 } else { (d[k - 1] + d[k]) / 2.0 };
+ }
+ for k in 0..n - 1 {
+ if d[k] == 0.0 {
+ ms[k] = 0.0;
+ ms[k + 1] = 0.0;
+ continue;
+ }
+ let (a, b) = (ms[k] / d[k], ms[k + 1] / d[k]);
+ let s = a * a + b * b;
+ if s > 9.0 {
+ let t = 3.0 / s.sqrt();
+ ms[k] = t * a * d[k];
+ ms[k + 1] = t * b * d[k];
+ }
+ }
+ Self { xs, ys, ms }
+ }
+
+ /// The curve's output for pen pressure `x` (0..1; anything else is clamped, NaN reads as 0).
+ pub fn eval(&self, x: f32) -> f32 {
+ let x = if x.is_nan() { 0.0 } else { x.clamp(0.0, 1.0) };
+ let n = self.xs.len();
+ let (Some(&x0), Some(&xn)) = (self.xs.first(), self.xs.last()) else { return x };
+ if x <= x0 {
+ return self.ys.first().copied().unwrap_or(x);
+ }
+ if x >= xn {
+ return self.ys.last().copied().unwrap_or(x);
+ }
+ let k = self.xs.partition_point(|&v| v <= x).saturating_sub(1).min(n.saturating_sub(2));
+ let (Some(&xa), Some(&xb), Some(&ya), Some(&yb), Some(&ma), Some(&mb)) =
+ (self.xs.get(k), self.xs.get(k + 1), self.ys.get(k), self.ys.get(k + 1), self.ms.get(k), self.ms.get(k + 1))
+ else {
+ return x;
+ };
+ let h = xb - xa;
+ let t = (x - xa) / h;
+ let (t2, t3) = (t * t, t * t * t);
+ let y = (2.0 * t3 - 3.0 * t2 + 1.0) * ya + (t3 - 2.0 * t2 + t) * h * ma + (-2.0 * t3 + 3.0 * t2) * yb + (t3 - t2) * h * mb;
+ y.clamp(ya.min(yb), ya.max(yb))
+ }
+
+ /// The identity (the default curve): pressure passes through unchanged.
+ pub fn is_linear(&self) -> bool {
+ self.xs == [0.0, 1.0] && self.ys == [0.0, 1.0]
+ }
+}
+
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct HistoryLog {
@@ -1074,6 +1173,18 @@ fn check_value(path: &str, v: &Value) -> std::result::Result<(), String> {
if is_color(path) && v.as_str().and_then(parse_hex).is_none() {
return Err(format!("`{path}` must be a #rrggbb colour"));
}
+ if path == "tools.pressureCurve" {
+ let pts = v.as_array().ok_or("`tools.pressureCurve` must be a list of [input, output] points")?;
+ if !(2..=PressureCurve::MAX_POINTS).contains(&pts.len()) {
+ return Err(format!("`tools.pressureCurve` needs 2..={} points (got {})", PressureCurve::MAX_POINTS, pts.len()));
+ }
+ for p in pts {
+ let ok = p.as_array().is_some_and(|a| a.len() == 2 && a.iter().all(|x| x.as_f64().is_some_and(|x| (0.0..=1.0).contains(&x))));
+ if !ok {
+ return Err(format!("`tools.pressureCurve` points are [input, output] pairs within 0..1 (got {p})"));
+ }
+ }
+ }
if let Some(sc) = path.strip_prefix("shortcuts.") {
let s = v.as_str().ok_or_else(|| format!("shortcut for `{sc}` must be a string"))?;
if !s.is_empty() && normalize_shortcut(s).is_none() {
diff --git a/crates/engine/src/prefs/tests.rs b/crates/engine/src/prefs/tests.rs
index b4a02ea74..886bd8910 100644
--- a/crates/engine/src/prefs/tests.rs
+++ b/crates/engine/src/prefs/tests.rs
@@ -453,3 +453,71 @@ fn linux_only_preferences_show_only_on_linux() {
assert!(!is_hidden("performance.gpuBackend"));
assert!(LINUX_ONLY.iter().all(|p| choices(p).is_some()), "every Linux-only preference is a real one");
}
+
+#[test]
+fn the_default_pressure_curve_is_linear() {
+ let c = PressureCurve::new(&Preferences::default().tools.pressure_curve);
+ assert!(c.is_linear());
+ for x in [0.0, 0.1, 0.37, 0.5, 0.99, 1.0] {
+ assert!((c.eval(x) - x).abs() < 1e-6, "{x}");
+ }
+}
+
+#[test]
+fn a_pressure_curve_is_monotone_and_passes_through_its_points() {
+ // A soft curve: light pressure already gives a lot.
+ let pts = [[0.0, 0.0], [0.25, 0.5], [0.6, 0.8], [1.0, 1.0]];
+ let c = PressureCurve::new(&pts);
+ for p in pts {
+ assert!((c.eval(p[0]) - p[1]).abs() < 1e-5, "{p:?}");
+ }
+ let ys: Vec<f32> = (0..=200).map(|i| c.eval(i as f32 / 200.0)).collect();
+ assert!(ys.windows(2).all(|w| w[1] >= w[0] - 1e-6), "firmer never gives less: {ys:?}");
+ assert!(ys.iter().all(|y| (0.0..=1.0).contains(y)));
+ // Flat outside the points: a floor and a ceiling.
+ let c = PressureCurve::new(&[[0.2, 0.3], [0.8, 0.9]]);
+ assert_eq!((c.eval(0.0), c.eval(0.1), c.eval(0.95), c.eval(1.0)), (0.3, 0.3, 0.9, 0.9));
+}
+
+#[test]
+fn a_hostile_pressure_curve_still_evaluates_monotone_within_range() {
+ let many: Vec<[f32; 2]> = (0..100).map(|i| [((i * 37) % 100) as f32 / 99.0, ((i * 53) % 100) as f32 / 99.0]).collect();
+ for pts in [
+ vec![],
+ vec![[0.5, 0.5]],
+ vec![[f32::NAN, 0.5], [f32::INFINITY, 1.0], [0.3, f32::NEG_INFINITY]],
+ vec![[2.0, -1.0], [-3.0, 5.0], [0.5, 0.2]],
+ vec![[0.9, 0.1], [0.1, 0.9]],
+ vec![[0.5, 0.2], [0.5, 0.7], [1.0, 1.0], [0.0, 0.0]],
+ many,
+ ] {
+ let c = PressureCurve::new(&pts);
+ let ys: Vec<f32> = (0..=100).map(|i| c.eval(i as f32 / 100.0)).collect();
+ assert!(ys.iter().all(|y| y.is_finite() && (0.0..=1.0).contains(y)), "{pts:?}");
+ assert!(ys.windows(2).all(|w| w[1] >= w[0] - 1e-6), "{pts:?}: {ys:?}");
+ for x in [f32::NAN, -1.0, 2.0, f32::INFINITY] {
+ assert!((0.0..=1.0).contains(&c.eval(x)), "{pts:?} at {x}");
+ }
+ }
+ // Two points at the same input: the later one's output wins.
+ let c = PressureCurve::new(&[[0.0, 0.0], [0.5, 0.2], [0.5, 0.7], [1.0, 1.0]]);
+ assert!((c.eval(0.5) - 0.7).abs() < 1e-6);
+}
+
+#[test]
+fn prefs_set_validates_the_pressure_curve() {
+ let mut p = Preferences::default();
+ p.set("tools.pressureCurve", serde_json::json!([[0.0, 0.1], [0.5, 0.7], [1.0, 1.0]])).unwrap();
+ assert_eq!(p.tools.pressure_curve, vec![[0.0, 0.1], [0.5, 0.7], [1.0, 1.0]]);
+ for bad in [
+ serde_json::json!("linear"),
+ serde_json::json!([[0.0, 0.0]]),
+ serde_json::json!([[0.0, 0.0], [1.5, 1.0]]),
+ serde_json::json!([[0.0, 0.0], [1.0]]),
+ serde_json::json!([[0.0, 0.0], ["a", 1.0]]),
+ serde_json::json!(vec![[0.5, 0.5]; 17]),
+ ] {
+ assert!(p.set("tools.pressureCurve", bad.clone()).is_err(), "{bad}");
+ }
+ assert_eq!(p.tools.pressure_curve, vec![[0.0, 0.1], [0.5, 0.7], [1.0, 1.0]], "a refused value changes nothing");
+}
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs
index 77ff3188a..d436b2189 100644
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@ -2471,6 +2471,8 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect:
// Pen pressure/tilt for this frame's tool events (mouse = 1.0), unless Preferences › Tools ›
// Use Tablet Pressure is off; the pen's eraser end selects the Eraser.
app.stylus.use_pressure = app.session.prefs().tools.use_tablet_pressure;
+ let curve = app.session.prefs().tools.pressure_curve.clone();
+ app.stylus.set_pressure_curve(&curve);
app.stylus.update_for_frame(ui.ctx().cumulative_frame_nr(), &ui.input(|i| i.events.clone()));
crate::stylus::Stylus::sync_eraser_tool(app);
// A Magnetic Lasso border left behind by a tool or document switch is dropped.
diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv
index 3f8c01ff2..28b22ce72 100644
--- a/crates/ui-egui/src/i18n/cs.tsv
+++ b/crates/ui-egui/src/i18n/cs.tsv
@@ -2360,6 +2360,8 @@ fontWeight Italic Kurzíva
Create Ellipse Vytvořit elipsu
Create Triangle Vytvořit trojúhelník
Create Polygon Vytvořit mnohoúhelník
+ Pressure curve Křivka přítlaku
+ Click to add a point, right-click to remove Kliknutím přidáte bod, pravým tlačítkem bod odeberete
Some brush presets could not be loaded Některé předvolby štětců se nepodařilo načíst
Retry saving presets Zkusit znovu uložit předvolby
Brush preset changes are not saved: {error} Změny předvoleb štětců nejsou uloženy: {error}
diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv
index 9e3e905c6..354231229 100644
--- a/crates/ui-egui/src/i18n/de.tsv
+++ b/crates/ui-egui/src/i18n/de.tsv
@@ -2399,6 +2399,8 @@ fontWeight Italic Kursiv
Create Ellipse Ellipse erstellen
Create Triangle Dreieck erstellen
Create Polygon Polygon erstellen
+ Pressure curve Druckkurve
+ Click to add a point, right-click to remove Klicken fügt einen Punkt hinzu, Rechtsklick entfernt ihn
Some brush presets could not be loaded Einige Pinselvorgaben konnten nicht geladen werden
Retry saving presets Speichern der Vorgaben erneut versuchen
Brush preset changes are not saved: {error} Änderungen an Pinselvorgaben sind nicht gespeichert: {error}
diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv
index c1fcef292..203388365 100644
--- a/crates/ui-egui/src/i18n/el.tsv
+++ b/crates/ui-egui/src/i18n/el.tsv
@@ -3471,6 +3471,8 @@ fontWeight Thin Πολύ λεπτά
Create Ellipse Δημιουργία έλλειψης
Create Triangle Δημιουργία τριγώνου
Create Polygon Δημιουργία πολυγώνου
+ Pressure curve Καμπύλη πίεσης
+ Click to add a point, right-click to remove Κάντε κλικ για να προσθέσετε σημείο, δεξί κλικ για να το αφαιρέσετε
Some brush presets could not be loaded Ορισμένες προεπιλογές πινέλων δεν ήταν δυνατό να φορτωθούν
Retry saving presets Επανάληψη αποθήκευσης προεπιλογών
Brush preset changes are not saved: {error} Οι αλλαγές στις προεπιλογές πινέλων δεν αποθηκεύτηκαν: {error}
diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv
index 6b8727a64..aa84c2b47 100644
--- a/crates/ui-egui/src/i18n/es.tsv
+++ b/crates/ui-egui/src/i18n/es.tsv
@@ -2428,6 +2428,8 @@ fontWeight Italic Cursiva
Create Ellipse Crear elipse
Create Triangle Crear triángulo
Create Polygon Crear polígono
+ Pressure curve Curva de presión
+ Click to add a point, right-click to remove Haz clic para añadir un punto; clic derecho para quitarlo
Some brush presets could not be loaded No se pudieron cargar algunos ajustes preestablecidos de pincel
Retry saving presets Reintentar guardar los ajustes preestablecidos
Brush preset changes are not saved: {error} Los cambios en los ajustes preestablecidos de pincel no se han guardado: {error}
diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv
index 4358225b6..305920f82 100644
--- a/crates/ui-egui/src/i18n/fr.tsv
+++ b/crates/ui-egui/src/i18n/fr.tsv
@@ -2781,6 +2781,8 @@ fontWeight Italic Italique
Create Ellipse Créer une ellipse
Create Triangle Créer un triangle
Create Polygon Créer un polygone
+ Pressure curve Courbe de pression
+ Click to add a point, right-click to remove Cliquez pour ajouter un point, clic droit pour le supprimer
Some brush presets could not be loaded Certains paramètres prédéfinis de forme n'ont pas pu être chargés
Retry saving presets Réessayer d'enregistrer les paramètres prédéfinis
Brush preset changes are not saved: {error} Les modifications des paramètres prédéfinis de forme ne sont pas enregistrées : {error}
diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv
index ee411314e..8cd30fd3d 100644
--- a/crates/ui-egui/src/i18n/id.tsv
+++ b/crates/ui-egui/src/i18n/id.tsv
@@ -2768,6 +2768,8 @@ fontWeight Italic Miring
Create Ellipse Buat Elips
Create Triangle Buat Segitiga
Create Polygon Buat Poligon
+ Pressure curve Kurva tekanan
+ Click to add a point, right-click to remove Klik untuk menambah titik, klik kanan untuk menghapusnya
Some brush presets could not be loaded Beberapa preset kuas tidak dapat dimuat
Retry saving presets Coba simpan preset lagi
Brush preset changes are not saved: {error} Perubahan preset kuas belum disimpan: {error}
diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv
index b995e93a4..6c357abdf 100644
--- a/crates/ui-egui/src/i18n/it.tsv
+++ b/crates/ui-egui/src/i18n/it.tsv
@@ -2430,6 +2430,8 @@ fontWeight Italic Corsivo
Create Ellipse Crea ellisse
Create Triangle Crea triangolo
Create Polygon Crea poligono
+ Pressure curve Curva di pressione
+ Click to add a point, right-click to remove Fai clic per aggiungere un punto, clic destro per rimuoverlo
Some brush presets could not be loaded Impossibile caricare alcuni predefiniti pennello
Retry saving presets Riprova a salvare i predefiniti
Brush preset changes are not saved: {error} Le modifiche ai predefiniti pennello non sono salvate: {error}
diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv
index 2841b189a..407e27f8e 100644
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@ -3384,6 +3384,8 @@ fontWeight Italic 斜体
Create Ellipse 楕円を作成
Create Triangle 三角形を作成
Create Polygon 多角形を作成
+ Pressure curve 筆圧カーブ
+ Click to add a point, right-click to remove クリックでポイントを追加、右クリックで削除
Some brush presets could not be loaded 一部のブラシプリセットを読み込めませんでした
Retry saving presets プリセットの保存を再試行
Brush preset changes are not saved: {error} ブラシプリセットの変更は保存されていません:{error}
diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv
index 629737410..5d047df99 100644
--- a/crates/ui-egui/src/i18n/ko.tsv
+++ b/crates/ui-egui/src/i18n/ko.tsv
@@ -2939,6 +2939,8 @@ fontWeight Italic 기울임
Create Ellipse 타원 만들기
Create Triangle 삼각형 만들기
Create Polygon 다각형 만들기
+ Pressure curve 필압 곡선
+ Click to add a point, right-click to remove 클릭하여 점 추가, 마우스 오른쪽 클릭으로 제거
Some brush presets could not be loaded 일부 브러시 사전 설정을 불러오지 못했습니다
Retry saving presets 사전 설정 저장 다시 시도
Brush preset changes are not saved: {error} 브러시 사전 설정 변경 내용이 저장되지 않았습니다: {error}
diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv
index f2d430bca..011e7c1e7 100644
--- a/crates/ui-egui/src/i18n/nl.tsv
+++ b/crates/ui-egui/src/i18n/nl.tsv
@@ -3541,6 +3541,8 @@ cameraRaw Whites Witten
Create Ellipse Ellips maken
Create Triangle Driehoek maken
Create Polygon Veelhoek maken
+ Pressure curve Drukcurve
+ Click to add a point, right-click to remove Klik om een punt toe te voegen, rechtsklik om het te verwijderen
Some brush presets could not be loaded Sommige penseelvoorinstellingen konden niet worden geladen
Retry saving presets Opslaan van voorinstellingen opnieuw proberen
Brush preset changes are not saved: {error} Wijzigingen in penseelvoorinstellingen zijn niet opgeslagen: {error}
diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv
index 4599d382b..f030df93d 100644
--- a/crates/ui-egui/src/i18n/pl.tsv
+++ b/crates/ui-egui/src/i18n/pl.tsv
@@ -3383,6 +3383,8 @@ cameraRaw Roughness Chropowatość
Create Ellipse Utwórz elipsę
Create Triangle Utwórz trójkąt
Create Polygon Utwórz wielokąt
+ Pressure curve Krzywa nacisku
+ Click to add a point, right-click to remove Kliknij, aby dodać punkt; kliknij prawym przyciskiem, aby go usunąć
Some brush presets could not be loaded Nie udało się wczytać niektórych ustawień predefiniowanych pędzli
Retry saving presets Ponów zapisywanie ustawień predefiniowanych
Brush preset changes are not saved: {error} Zmiany w ustawieniach predefiniowanych pędzli nie zostały zapisane: {error}
diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv
index 6e15c30fd..f8b53367f 100644
--- a/crates/ui-egui/src/i18n/pt-br.tsv
+++ b/crates/ui-egui/src/i18n/pt-br.tsv
@@ -2789,6 +2789,8 @@ fontWeight Italic Itálico
Create Ellipse Criar elipse
Create Triangle Criar triângulo
Create Polygon Criar polígono
+ Pressure curve Curva de pressão
+ Click to add a point, right-click to remove Clique para adicionar um ponto; clique com o botão direito para removê-lo
Some brush presets could not be loaded Não foi possível carregar algumas predefinições de pincel
Retry saving presets Tentar salvar as predefinições novamente
Brush preset changes are not saved: {error} As alterações nas predefinições de pincel não foram salvas: {error}
diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv
index 5eea2a9fe..c67a85a7f 100644
--- a/crates/ui-egui/src/i18n/ru.tsv
+++ b/crates/ui-egui/src/i18n/ru.tsv
@@ -2634,6 +2634,10 @@ fontWeight Italic Курсив
Create Ellipse Создать эллипс
Create Triangle Создать треугольник
Create Polygon Создать многоугольник
+ Pressure curve Кривая нажима
+ Click to add a point, right-click to remove Щёлкните, чтобы добавить точку; щелчок правой кнопкой удаляет её
+ Soft Мягкая
+ Hard Жёсткая
Some brush presets could not be loaded Не удалось загрузить некоторые наборы кистей
Retry saving presets Повторить сохранение наборов
Brush preset changes are not saved: {error} Изменения наборов кистей не сохранены: {error}
diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv
index b4eb14201..d20554d38 100644
--- a/crates/ui-egui/src/i18n/uk.tsv
+++ b/crates/ui-egui/src/i18n/uk.tsv
@@ -3468,6 +3468,8 @@ cameraRaw Masking Маскування
Create Ellipse Створити еліпс
Create Triangle Створити трикутник
Create Polygon Створити багатокутник
+ Pressure curve Крива натиску
+ Click to add a point, right-click to remove Клацніть, щоб додати точку; клацання правою кнопкою вилучає її
Some brush presets could not be loaded Не вдалося завантажити деякі набори пензлів
Retry saving presets Повторити збереження наборів
Brush preset changes are not saved: {error} Зміни наборів пензлів не збережено: {error}
diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv
index f6b06c8f1..8b742eb8e 100644
--- a/crates/ui-egui/src/i18n/zh-hans.tsv
+++ b/crates/ui-egui/src/i18n/zh-hans.tsv
@@ -2368,6 +2368,8 @@ fontWeight Italic 斜体
Create Ellipse 创建椭圆
Create Triangle 创建三角形
Create Polygon 创建多边形
+ Pressure curve 压感曲线
+ Click to add a point, right-click to remove 单击添加点,右键单击删除点
Some brush presets could not be loaded 部分画笔预设无法加载
Retry saving presets 重试保存预设
Brush preset changes are not saved: {error} 画笔预设的更改未保存:{error}
diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv
index 7668470a0..0e8be787f 100644
--- a/crates/ui-egui/src/i18n/zh-hant.tsv
+++ b/crates/ui-egui/src/i18n/zh-hant.tsv
@@ -2337,6 +2337,8 @@ fontWeight Italic 斜體
Create Ellipse 建立橢圓
Create Triangle 建立三角形
Create Polygon 建立多邊形
+ Pressure curve 壓力曲線
+ Click to add a point, right-click to remove 按一下新增點,按右鍵移除點
Some brush presets could not be loaded 部分筆刷預設集無法載入
Retry saving presets 重試儲存預設集
Brush preset changes are not saved: {error} 筆刷預設集的變更尚未儲存:{error}
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index 440da4852..7c7534d35 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -119,6 +119,7 @@ pub mod prefs_ui;
pub mod preset_files_ui;
pub mod preset_panels;
pub mod press_menu;
+mod pressure_curve_ui;
pub mod props_layout;
pub mod proxy;
pub mod puppet_ui;
diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs
index 58d69adad..791a6b4a2 100644
--- a/crates/ui-egui/src/prefs_ui.rs
+++ b/crates/ui-egui/src/prefs_ui.rs
@@ -1316,6 +1316,12 @@ fn section_fields(ui: &mut egui::Ui, section: &str, obj: &mut Map<String, Value>
obj.insert(k, json!(x));
}
}
+ Value::Array(_) if path == "tools.pressureCurve" => {
+ ui.label(RichText::new(tl!(&label)).color(t.text_dim));
+ if let Some(next) = crate::pressure_curve_ui::editor(ui, &v) {
+ obj.insert(k, next);
+ }
+ }
Value::Array(items) if k == "disks" => {
ui.label(RichText::new(tl!("Scratch disks")).color(t.text_dim));
let mut items = items.clone();
diff --git a/crates/ui-egui/src/pressure_curve_ui.rs b/crates/ui-egui/src/pressure_curve_ui.rs
new file mode 100644
index 000000000..cb9880733
--- /dev/null
+++ b/crates/ui-egui/src/pressure_curve_ui.rs
@@ -0,0 +1,212 @@
+//! Preferences › Tools › Pressure Curve: the pen's pressure response, edited as points on a curve
+//! (`tools.pressureCurve`, read by the stylus through `photocraft_engine::prefs::PressureCurve`).
+//! Drag a point to move it, click empty space to add one, right-click a point to remove it.
+
+use egui::{Pos2, Sense, Stroke, Vec2, pos2};
+use photocraft_engine::prefs::PressureCurve;
+use serde_json::{Value, json};
+
+use crate::theme::Tokens;
+
+/// Side of the editing square, in points.
+const SIZE: f32 = 140.0;
+/// egui memory key holding the editing square's rectangle.
+pub(crate) const RECT_KEY: &str = "pressure-curve-rect";
+/// How close (in points) a press must land to grab a point.
+const GRAB: f32 = 8.0;
+
+/// Preset curves: Linear, Soft (light pressure already gives a lot) and Hard (it takes a firm
+/// press to reach full pressure).
+const PRESETS: [(&str, &[[f32; 2]]); 3] =
+ [("Linear", &[[0.0, 0.0], [1.0, 1.0]]), ("Soft", &[[0.0, 0.0], [0.3, 0.6], [1.0, 1.0]]), ("Hard", &[[0.0, 0.0], [0.6, 0.3], [1.0, 1.0]])];
+
+/// The points a preferences value holds (anything malformed is skipped; `PressureCurve` sanitises
+/// the rest).
+pub(crate) fn points_of(v: &Value) -> Vec<[f32; 2]> {
+ v.as_array()
+ .map(|a| {
+ a.iter()
+ .filter_map(|p| {
+ let p = p.as_array()?;
+ Some([p.first()?.as_f64()? as f32, p.get(1)?.as_f64()? as f32])
+ })
+ .collect()
+ })
+ .unwrap_or_default()
+}
+
+fn value_of(points: &[[f32; 2]]) -> Value {
+ // Two decimals: the stored file stays readable and a drag doesn't write float noise.
+ json!(points.iter().map(|p| [round2(p[0]), round2(p[1])]).collect::<Vec<_>>())
+}
+
+fn round2(x: f32) -> f64 {
+ (f64::from(x.clamp(0.0, 1.0)) * 100.0).round() / 100.0
+}
+
+/// The editor. Returns the new value when the curve changed.
+pub(crate) fn editor(ui: &mut egui::Ui, value: &Value) -> Option<Value> {
+ let t = Tokens::get(ui.ctx());
+ let mut points = points_of(value);
+ if points.len() < 2 {
+ points = vec![[0.0, 0.0], [1.0, 1.0]];
+ }
+ let mut changed = false;
+ // The square with the presets beside it, so the control fits the preferences page's height.
+ ui.horizontal_top(|ui| {
+ let (rect, resp) = ui.allocate_exact_size(Vec2::splat(SIZE), Sense::click_and_drag());
+ // Where the square is this frame (tests and automation point at curve coordinates).
+ ui.data_mut(|d| d.insert_temp(egui::Id::new(RECT_KEY), rect));
+ let to_screen = |p: [f32; 2]| pos2(rect.left() + p[0] * rect.width(), rect.bottom() - p[1] * rect.height());
+ let to_curve = |s: Pos2| [((s.x - rect.left()) / rect.width()).clamp(0.0, 1.0), ((rect.bottom() - s.y) / rect.height()).clamp(0.0, 1.0)];
+ let painter = ui.painter_at(rect.expand(4.0));
+ painter.rect_filled(rect, 2.0, t.field);
+ for i in 1..4 {
+ let f = i as f32 / 4.0;
+ let grid = Stroke::new(1.0, t.field_border);
+ painter.line_segment([pos2(rect.left() + f * rect.width(), rect.top()), pos2(rect.left() + f * rect.width(), rect.bottom())], grid);
+ painter.line_segment([pos2(rect.left(), rect.top() + f * rect.height()), pos2(rect.right(), rect.top() + f * rect.height())], grid);
+ }
+ painter.rect_stroke(rect, 2.0, Stroke::new(1.0, t.field_border), egui::StrokeKind::Inside);
+ painter.line_segment([rect.left_bottom(), rect.right_top()], Stroke::new(1.0, t.text_dim.gamma_multiply(0.35)));
+
+ // The point under a press is dragged until release (kept in the egui memory).
+ let drag_id = resp.id.with("dragging");
+ let nearest = |at: Pos2, pts: &[[f32; 2]]| {
+ pts.iter().enumerate().map(|(i, p)| (i, to_screen(*p).distance(at))).filter(|(_, d)| *d <= GRAB).min_by(|a, b| a.1.total_cmp(&b.1)).map(|(i, _)| i)
+ };
+ // The point under the press, not under the pointer when the drag is recognised (by then
+ // it has moved past egui's drag threshold, off the point).
+ if resp.drag_started()
+ && let Some(at) = ui.input(|i| i.pointer.press_origin()).or(resp.interact_pointer_pos())
+ {
+ let grabbed = nearest(at, &points);
+ ui.data_mut(|d| d.insert_temp(drag_id, grabbed));
+ }
+ let dragging: Option<usize> = ui.data(|d| d.get_temp(drag_id)).flatten();
+ if let (Some(i), Some(at)) = (dragging, resp.interact_pointer_pos().filter(|_| resp.dragged()))
+ && let Some(p) = points.get_mut(i)
+ {
+ *p = to_curve(at);
+ changed = true;
+ }
+ if resp.drag_stopped() {
+ ui.data_mut(|d| d.insert_temp::<Option<usize>>(drag_id, None));
+ }
+ if resp.clicked()
+ && let Some(at) = resp.interact_pointer_pos()
+ && nearest(at, &points).is_none()
+ && points.len() < PressureCurve::MAX_POINTS
+ {
+ points.push(to_curve(at));
+ changed = true;
+ }
+ if resp.secondary_clicked()
+ && let Some(at) = resp.interact_pointer_pos()
+ && let Some(i) = nearest(at, &points)
+ && points.len() > 2
+ {
+ points.remove(i);
+ changed = true;
+ }
+
+ let curve = PressureCurve::new(&points);
+ let line: Vec<Pos2> = (0..=64).map(|i| i as f32 / 64.0).map(|x| to_screen([x, curve.eval(x)])).collect();
+ painter.add(egui::Shape::line(line, Stroke::new(2.0, t.accent)));
+ for (i, p) in points.iter().enumerate() {
+ let active = dragging == Some(i);
+ painter.circle(to_screen(*p), if active { 5.0 } else { 4.0 }, if active { t.accent } else { t.field }, Stroke::new(1.5, t.accent));
+ }
+ resp.on_hover_text(tl!("Click to add a point, right-click to remove"));
+
+ ui.vertical(|ui| {
+ for (name, preset) in PRESETS {
+ if ui.small_button(tl!(name)).clicked() {
+ points = preset.to_vec();
+ changed = true;
+ }
+ }
+ });
+ });
+ changed.then(|| value_of(&points))
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use egui_kittest::Harness;
+ use egui_kittest::kittest::Queryable;
+
+ fn harness(start: Value) -> Harness<'static, Value> {
+ let mut h = Harness::builder().with_size(egui::vec2(300.0, 260.0)).build_ui_state(
+ |ui, v: &mut Value| {
+ if let Some(next) = editor(ui, v) {
+ *v = next;
+ }
+ },
+ start,
+ );
+ h.run_steps(2);
+ h
+ }
+
+ /// The screen position of curve point `p` (the editor's square starts at the panel's origin).
+ fn at(h: &Harness<'static, Value>, p: [f32; 2]) -> Pos2 {
+ let r: egui::Rect = h.ctx.data(|d| d.get_temp(egui::Id::new(RECT_KEY))).expect("the editor ran");
+ pos2(r.left() + p[0] * r.width(), r.bottom() - p[1] * r.height())
+ }
+
+ fn press(h: &mut Harness<'static, Value>, p: Pos2, button: egui::PointerButton, release: Pos2) {
+ h.event(egui::Event::PointerMoved(p));
+ h.run_steps(1);
+ h.event(egui::Event::PointerButton { pos: p, button, pressed: true, modifiers: Default::default() });
+ h.run_steps(1);
+ if release != p {
+ h.event(egui::Event::PointerMoved(pos2((p.x + release.x) / 2.0, (p.y + release.y) / 2.0)));
+ h.run_steps(1);
+ h.event(egui::Event::PointerMoved(release));
+ h.run_steps(1);
+ }
+ h.event(egui::Event::PointerButton { pos: release, button, pressed: false, modifiers: Default::default() });
+ h.run_steps(2);
+ }
+
+ #[test]
+ fn click_adds_right_click_removes_drag_moves_and_presets_replace() {
+ let mut h = harness(json!([[0.0, 0.0], [1.0, 1.0]]));
+ // A click on empty space adds a point there.
+ let p = at(&h, [0.5, 0.2]);
+ press(&mut h, p, egui::PointerButton::Primary, p);
+ let pts = points_of(h.state());
+ assert_eq!(pts.len(), 3, "{pts:?}");
+ assert!(pts.iter().any(|q| (q[0] - 0.5).abs() < 0.03 && (q[1] - 0.2).abs() < 0.03), "{pts:?}");
+ // Dragging it moves it.
+ let (from, to) = (at(&h, [0.5, 0.2]), at(&h, [0.4, 0.7]));
+ press(&mut h, from, egui::PointerButton::Primary, to);
+ let pts = points_of(h.state());
+ assert!(pts.iter().any(|q| (q[0] - 0.4).abs() < 0.03 && (q[1] - 0.7).abs() < 0.03), "{pts:?}");
+ // A right-click on it removes it; the last two points can't be removed.
+ let p = at(&h, [0.4, 0.7]);
+ press(&mut h, p, egui::PointerButton::Secondary, p);
+ assert_eq!(points_of(h.state()).len(), 2);
+ let p = at(&h, [1.0, 1.0]);
+ press(&mut h, p, egui::PointerButton::Secondary, p);
+ assert_eq!(points_of(h.state()).len(), 2, "a curve keeps at least two points");
+ // A preset replaces the curve.
+ h.get_by_label("Soft").click();
+ h.run_steps(2);
+ assert_eq!(points_of(h.state()), vec![[0.0, 0.0], [0.3, 0.6], [1.0, 1.0]]);
+ h.get_by_label("Linear").click();
+ h.run_steps(2);
+ assert_eq!(points_of(h.state()), vec![[0.0, 0.0], [1.0, 1.0]]);
+ }
+
+ #[test]
+ fn malformed_stored_values_still_edit() {
+ let mut h = harness(json!([[0.5], "x", [2.0, -1.0]]));
+ h.get_by_label("Hard").click();
+ h.run_steps(2);
+ assert_eq!(points_of(h.state()), vec![[0.0, 0.0], [0.6, 0.3], [1.0, 1.0]]);
+ assert!(points_of(&json!("nope")).is_empty());
+ }
+}
diff --git a/crates/ui-egui/src/stroke_timing_tests.rs b/crates/ui-egui/src/stroke_timing_tests.rs
index 276c35e59..94dfe9f1c 100644
--- a/crates/ui-egui/src/stroke_timing_tests.rs
+++ b/crates/ui-egui/src/stroke_timing_tests.rs
@@ -163,3 +163,21 @@ fn moves_in_one_frame_take_the_pressures_the_pen_reported_between_them() {
let tail: Vec<f64> = pts.iter().filter(|p| p[0] >= 29.0).map(|p| (p[2] * 100.0).round() / 100.0).collect();
assert_eq!(tail.get(..3), Some(&[0.4, 0.6, 0.8][..]), "each move keeps its own pressure: {pts:?}");
}
+
+#[test]
+fn the_pressure_curve_shapes_the_committed_stroke() {
+ use crate::stylus::PenSample;
+ let mut h = harness();
+ h.state_mut().run("prefs.set", json!({"path": "tools.pressureCurve", "value": [[0.0, 0.0], [0.3, 0.6], [1.0, 1.0]]})).unwrap();
+ h.state().stylus.feed.set(Some(PenSample { pressure: 0.3, ..Default::default() }));
+ move_to(&mut h, 20.0, 50.0);
+ button(&mut h, 20.0, 50.0, true);
+ for x in [40.0, 60.0] {
+ h.state().stylus.feed.set(Some(PenSample { pressure: 0.3, ..Default::default() }));
+ move_to(&mut h, x, 50.0);
+ }
+ button(&mut h, 60.0, 50.0, false);
+ h.run_steps(2);
+ let pts = committed_points(&h);
+ assert!(pts.iter().all(|p| (p[2] - 0.6).abs() < 1e-3), "pen 0.3 through the curve is 0.6: {pts:?}");
+}
diff --git a/crates/ui-egui/src/stylus.rs b/crates/ui-egui/src/stylus.rs
index f4398af76..f30141470 100644
--- a/crates/ui-egui/src/stylus.rs
+++ b/crates/ui-egui/src/stylus.rs
@@ -111,6 +111,9 @@ pub struct Stylus {
pub feed: StylusFeed,
/// Preferences › Tools › Use Tablet Pressure: off, a pen paints like a mouse.
pub use_pressure: bool,
+ /// Preferences › Tools › Pressure Curve (`None`: linear), with the points it was built from.
+ pressure_curve: Option<photocraft_engine::prefs::PressureCurve>,
+ curve_points: Vec<[f32; 2]>,
/// The pen end last seen (`Some(true)` = eraser), for the eraser tool switch.
end: Option<bool>,
/// The tool to restore when the pen tip comes back after the eraser end switched tools.
@@ -142,6 +145,8 @@ impl Default for Stylus {
Self {
feed: StylusFeed::default(),
use_pressure: true,
+ pressure_curve: None,
+ curve_points: Vec::new(),
end: None,
tool_before_eraser: None,
touch: None,
@@ -198,7 +203,21 @@ impl Stylus {
if !self.use_pressure {
return None;
}
- self.current.or_else(|| self.feed.get()).or(self.touch.map(|pressure| PenSample { pressure, ..Default::default() }))
+ let s = self.current.or_else(|| self.feed.get()).or(self.touch.map(|pressure| PenSample { pressure, ..Default::default() }))?;
+ // The pen's pressure through Preferences › Tools › Pressure Curve, before any brush sees it.
+ Some(match &self.pressure_curve {
+ Some(c) => PenSample { pressure: c.eval(s.pressure), ..s },
+ None => s,
+ })
+ }
+
+ /// Preferences › Tools › Pressure Curve (rebuilt only when the points change).
+ pub fn set_pressure_curve(&mut self, points: &[[f32; 2]]) {
+ if self.curve_points != points {
+ self.curve_points = points.to_vec();
+ let c = photocraft_engine::prefs::PressureCurve::new(points);
+ self.pressure_curve = (!c.is_linear()).then_some(c);
+ }
}
/// Choose the pen sample for move `k` of the `n` pointer moves this frame delivered: the pen
@@ -380,6 +399,22 @@ mod tests {
assert_eq!(s.pressure(), 0.8, "back to the current sample");
}
+ #[test]
+ fn the_pressure_curve_reshapes_pen_pressure_but_not_the_mouse() {
+ let mut s = Stylus::default();
+ s.set_pressure_curve(&[[0.0, 0.0], [0.3, 0.6], [1.0, 1.0]]);
+ s.feed.set(Some(pen(0.3)));
+ s.update(&[]);
+ assert!((s.pressure() - 0.6).abs() < 1e-5, "{}", s.pressure());
+ s.set_pressure_curve(&[[0.0, 0.0], [1.0, 1.0]]);
+ assert!((s.pressure() - 0.3).abs() < 1e-6, "linear again");
+ // A mouse is full pressure whatever the curve.
+ let mut m = Stylus::default();
+ m.set_pressure_curve(&[[0.0, 0.0], [1.0, 0.2]]);
+ m.update(&[egui::Event::PointerMoved(egui::pos2(1.0, 1.0))]);
+ assert_eq!(m.pressure(), 1.0);
+ }
+
#[test]
fn a_second_update_in_the_same_frame_keeps_its_samples() {
// The canvas runs once per view, and egui may run a frame in several passes.
diff --git a/docs/scorecard.md b/docs/scorecard.md
index 173cdc78e..f747a39b0 100644
--- a/docs/scorecard.md
+++ b/docs/scorecard.md
@@ -8,8 +8,8 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js
|---|---:|---:|---:|---|
| [Performance](#performance) | 3 | 22 | 22 | 56 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 15 not run, 7 not measurable yet (baseline 2026-10-05) |
| [File compatibility](#file-compatibility) | 4 | 12 | 11 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 307/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 |
-| [Tools](#tools) | 19 | 13 | 7 | |
-| [Workspace and UI](#workspace-and-ui) | 5 | 7 | 11 | settings that do nothing: 46 of 147 (target 0) |
+| [Tools](#tools) | 19 | 14 | 6 | |
+| [Workspace and UI](#workspace-and-ui) | 5 | 7 | 11 | settings that do nothing: 46 of 148 (target 0) |
| [Type](#type) | 0 | 3 | 6 | |
| [Automation](#automation) | 3 | 2 | 6 | 627 of 627 menu items live (100.0%) |
| [Reliability](#reliability) | 5 | 0 | 2 | never-crash lints on 28 of 28 crates; panic_hunt present |
@@ -140,7 +140,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t
| TOOL-213-8 | Clone Source: W/H link, drawn overlay (opacity/blend/clip/auto-hide), Alt target cursor | partial | [#213](https://github.com/storytold/photocraft/issues/213) | Clone Source overlay drawn with opacity, inversion, circular clipping and auto-hide; W/H link, custom-tip clipping and overlay blend modes remain missing |
| TOOL-213-9 | Eyedropper comparison ring (new colour above, current below) while sampling | done | [#213](https://github.com/storytold/photocraft/issues/213) | eyedropper_ring (canvas.rs): the sampled colour on the upper arc, the foreground below, drawn for the Eyedropper and Alt-sampling while the button is held; the Precise-cursor preference keeps the crosshair |
| TOOL-213-10 | Ctrl+Alt drag resizes brush size/hardness with an on-canvas readout | done | [#213](https://github.com/storytold/photocraft/issues/213) | brush_resize.rs (#297, #370): Alt+right-drag, or Control+Option-drag on macOS (Control+Alt everywhere), sets diameter horizontally and hardness vertically, circle plus Diameter/Hardness readout, one coalesced tools.setBrush, no paint or history; 9 tests there |
-| TOOL-213-11 | Editable pressure curve, global and per control | missing | [#213](https://github.com/storytold/photocraft/issues/213) | No pressure curve in engine, paint or ui-egui |
+| TOOL-213-11 | Editable pressure curve, global and per control | partial | [#213](https://github.com/storytold/photocraft/issues/213) | Global: Preferences › Tools › Pressure Curve (prefs tools.pressureCurve; monotone cubic, engine prefs::PressureCurve; applied to every pen sample in ui-egui stylus.rs before any brush; editor pressure_curve_ui.rs with Linear/Soft/Hard presets). Missing: per-control curves (each brush dynamic's own response to pressure, tilt, rotation) |
| TOOL-213-12 | Import an image file as a brush tip | missing | [#213](https://github.com/storytold/photocraft/issues/213) | Only brush.defineFromSelection and brush.presets.importAbr |
| TOOL-213-13 | Brush regression tests: no seams, hard edge, zero-scatter defaults, ABR never black | done | [#213](https://github.com/storytold/photocraft/issues/213) | Seam, hard-edge and zero-scatter tests in brush_tests.rs; ABR tip colour test in abr_map/tests.rs |
| TOOL-213-14 | Tablet: no OS arrow cursor over the canvas on macOS, Windows and Linux | partial | [#213](https://github.com/storytold/photocraft/issues/213) | Brush tools set CursorIcon::None (canvas.rs:1259-1275); not verified per OS |
@@ -172,7 +172,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t
## Workspace and UI
-**Settings that do nothing: 46 of 147** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.
+**Settings that do nothing: 46 of 148** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.
Unread: `general.color_picker`, `general.beep_when_done`, `general.resize_image_during_place`, `general.always_create_smart_objects_when_placing`, `general.animated_zoom`, `general.zoom_resizes_windows`, `interface.dynamic_color_sliders`, `workspace.auto_collapse_icon_panels`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `workspace.enable_narrow_options_bar`, `tools.enable_flick_panning`, `tools.vary_round_brush_hardness_on_hud`, `tools.show_transformation_values`, `file_handling.image_previews`, `file_handling.save_in_background`, `file_handling.ignore_exif_profile_tag`, `file_handling.maximize_psd_compatibility`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `cursors.brush_preview_color`, `units_and_rulers.type_units`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `units_and_rulers.print_resolution`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.smart_quotes`, `type_.missing_glyph_protection`, `type_.show_font_names_in_english`, `type_.text_engine`, `type_.font_preview`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `enhanced_controls.zoom_with_trackpad_pinch`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.
diff --git a/scorecard/tools.toml b/scorecard/tools.toml
index ffe365f9c..07153ac67 100644
--- a/scorecard/tools.toml
+++ b/scorecard/tools.toml
@@ -78,9 +78,9 @@ note = "brush_resize.rs (#297, #370): Alt+right-drag, or Control+Option-drag on
[[item]]
id = "TOOL-213-11"
target = "Editable pressure curve, global and per control"
-status = "missing"
+status = "partial"
issue = 213
-note = "No pressure curve in engine, paint or ui-egui"
+note = "Global: Preferences › Tools › Pressure Curve (prefs tools.pressureCurve; monotone cubic, engine prefs::PressureCurve; applied to every pen sample in ui-egui stylus.rs before any brush; editor pressure_curve_ui.rs with Linear/Soft/Hard presets). Missing: per-control curves (each brush dynamic's own response to pressure, tilt, rotation)"
[[item]]
id = "TOOL-213-12"