edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! The colour card's numbers and its histogram. |
| 2 | |
| 3 | use crate::*; |
| 4 | use crate; |
| 5 | use ; |
| 6 | |
| 7 | /// The colour card's four controls, in the order it lists them: what each is |
| 8 | /// called and the range it moves in. The order is `ColorParams`' own, which is |
| 9 | /// what [`color_band`] indexes. |
| 10 | pub const COLOR_BANDS: = |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | ; |
| 16 | |
| 17 | /// A press of a nudge key: a fortieth of a band's range, so a slider crosses it |
| 18 | /// in forty presses and every stop is a number the file can write. A drag lands |
| 19 | /// on the same grid ([`Player::drag_color`]), so the pointer and the keyboard |
| 20 | /// cannot reach two different sets of values. |
| 21 | pub const COLOR_STEP: f32 = 0.05; |
| 22 | |
| 23 | /// The card's width: the longest label has to fit on its line beside the value |
| 24 | /// without truncating (measured against "Tint (cool–warm)"). |
| 25 | pub const COLOR_W: f32 = 460.; |
| 26 | /// A bar's width for the pointer tests to drive. The card's bars fill the row |
| 27 | /// now, so nothing in the app reads this. |
| 28 | |
| 29 | pub const COLOR_BAR_W: f32 = 240.; |
| 30 | |
| 31 | /// The histogram's bins. 64 is four codes of an 8-bit ramp per bin: fine enough |
| 32 | /// to see a grade tilt, coarse enough that a subsampled count is not noise. |
| 33 | pub const HIST_BINS: usize = 64; |
| 34 | |
| 35 | /// How many pixels of a frame the histogram reads. The stride is |
| 36 | /// `pixels / HIST_SAMPLES` (1920x1080 -> every 253rd pixel), which is a |
| 37 | /// thousandth of the frame and walks across columns rather than down one. |
| 38 | pub const HIST_SAMPLES: usize = 8_192; |
| 39 | |
| 40 | /// The histogram box. Shorter than the equalizer's curve because the slider |
| 41 | /// rows stand under it and the card still has to fit a 360 px window. |
| 42 | pub const HIST_H: f32 = 96.; |
| 43 | |
| 44 | /// A slider value on the [`COLOR_STEP`] grid: what a drag rounds to, so the |
| 45 | /// pointer stops where the arrow keys do and "0.35" on screen is the number the |
| 46 | /// file writes rather than a rounding of one. |
| 47 | pub |
| 48 | |
| 49 | |
| 50 | |
| 51 | /// How the frame on screen is spread across the tone range: `HIST_BINS` counts |
| 52 | /// of its luma, read off the BGRA the decoder handed over -- which is the |
| 53 | /// *graded* picture, because the grade is folded into the conversion |
| 54 | /// (`engine::convert::i420_to_bgra_with`). So what this counts is what the eye |
| 55 | /// is looking at, and moving a slider moves it. |
| 56 | /// |
| 57 | /// Every [`HIST_SAMPLES`]th-of-a-frame pixel, not every pixel: a shape drawn |
| 58 | /// from eight thousand samples is the same shape, at a thousandth of the reads. |
| 59 | pub |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | /// The luma counts drawn as one line across the box, tallest bin to the top. |
| 74 | /// |
| 75 | /// Square root, not linear: a shot with a big flat area (a night sky, a title |
| 76 | /// card) puts one bin so far above the rest that a linear graph is a single |
| 77 | /// spike beside a flat line, and the tilt a grade puts in the rest is exactly |
| 78 | /// what the card is for. |
| 79 | pub |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | // -- the look: wheels, curves and a LUT, and the scopes ------------------------ |
| 108 | |
| 109 | /// The colour card's sections, one shown at a time so the card stays the height |
| 110 | /// it was: the four sliders, the wheels, the curves, the LUT. The order is the |
| 111 | /// order the grade runs in, bar the sliders, which are what a grade starts with. |
| 112 | |
| 113 | pub |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | pub const COLOR_SECTIONS: = |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | ; |
| 126 | |
| 127 | /// What the graph over the controls shows. |
| 128 | |
| 129 | pub |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | pub const SCOPE_VIEWS: = |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | ; |
| 142 | |
| 143 | /// Columns the waveform and parade are counted into. |
| 144 | pub const SCOPE_COLS: usize = 48; |
| 145 | |
| 146 | /// The wheels the Wheels section picks between, in `engine::color::Wheels`' order. |
| 147 | pub const WHEEL_NAMES: = ; |
| 148 | /// What each wheel does, for its tooltip. |
| 149 | pub const WHEEL_WHY: = |
| 150 | |
| 151 | |
| 152 | |
| 153 | ; |
| 154 | /// The channel rows of a wheel and the curves' channel picker, in |
| 155 | /// `engine::color::CHANNELS`' order. |
| 156 | pub const CHANNEL_NAMES: = ; |
| 157 | /// The five points of a curve the Curves section edits: their inputs and names. |
| 158 | pub const CURVE_GRID: = |
| 159 | ; |
| 160 | |
| 161 | /// Slider slots: the four basic bands, then a wheel's four channels, the five |
| 162 | /// curve points and the LUT's intensity. One recorded bar box each. |
| 163 | pub const WHEEL_BAND: usize = 4; |
| 164 | pub const CURVE_BAND: usize = WHEEL_BAND + 4; |
| 165 | pub const LUT_BAND: usize = CURVE_BAND + CURVE_GRID.len; |
| 166 | pub const COLOR_SLOTS: usize = LUT_BAND + 1; |
| 167 | |
| 168 | /// The bands a section's arrows walk. |
| 169 | pub |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | /// A band's name, range and keyboard step. |
| 179 | pub |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | /// The value of `band` in `params`, with `wheel` and `curve` the Wheels and |
| 192 | /// Curves sections' picks. A curve point reads the curve's output at that input, |
| 193 | /// whatever points the curve was made of. |
| 194 | pub |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | /// [`band_value`]'s writer. Moving a curve point rebuilds that curve on the |
| 205 | /// five-point grid (each point at the output the curve had there), so an |
| 206 | /// all-diagonal grid is the straight curve again. |
| 207 | pub |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | /// A band's neutral value: what Reset puts back. |
| 235 | pub |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | /// A curve's output at input `x`. |
| 253 | pub |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | /// `color` at `alpha` (0..255) as a gpui colour. |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | /// Count to alpha: square root, so a sparse trace still shows beside a dense one |
| 267 | /// (the histogram's own reason). |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | /// The scopes drawn in the graph box: the waveform, the vectorscope or the RGB |
| 276 | /// parade of the frame on screen, counted at low resolution |
| 277 | /// ([`engine::scopes::compute`]). Theme inks: the histogram's three. Each one |
| 278 | /// carries a faint graticule and its labels in the caption ink, so a reading |
| 279 | /// can be taken off it: 0 to 100 percent lines on the two level scopes, and a |
| 280 | /// centre cross, a ring and the six colour targets on the vectorscope. |
| 281 | pub |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | /// The strip above and below a parade's traces: the R/G/B names sit in the top one, and the |
| 397 | /// bottom one gives the 0% label room below its line. Other scopes use the whole box. |
| 398 | const PARADE_HEAD: f32 = 16.; |
| 399 | const PARADE_FOOT: f32 = 20.; |
| 400 | |
| 401 | /// The (top, bottom) inset of a scope's traces inside the graph box. |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | /// The left strip that holds a level scope's percent labels, clear of its traces. |
| 410 | /// Other scopes have no labels down the side, so they keep the whole box. |
| 411 | /// Sized for the widest percent label, "100%", at the caption size with room to spare for the |
| 412 | /// glyphs' real width, so a label is never cut at the box's left edge. |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 | |
| 420 | |
| 421 | |
| 422 | |
| 423 | |
| 424 | /// The graticule's level lines, as fractions of the scope's height: 0 to 100 percent. |
| 425 | const GRATICULE_LEVELS: = ; |
| 426 | |
| 427 | /// The graticule's line strength: the caption ink at a low alpha, so it reads as a guide. |
| 428 | const GRATICULE_ALPHA: u8 = 0x38; |
| 429 | |
| 430 | /// How far the vectorscope's ring sits in from the box's edge, so the target |
| 431 | /// letters have room outside it. |
| 432 | const VECTOR_RING_INSET: f32 = 14.; |
| 433 | |
| 434 | /// The six colour targets on a vectorscope, each as the Cb and Cr its full-scale |
| 435 | /// colour lands on in the engine's own units ([`engine::scopes::compute`]). |
| 436 | const VECTOR_TARGETS: = |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | |
| 442 | |
| 443 | ; |
| 444 | |
| 445 | /// A target's direction on the ring, unit length, with Cr up (screen y is down, so |
| 446 | /// the caller flips the sign for the screen). |
| 447 | |
| 448 | |
| 449 | |
| 450 | |
| 451 | |
| 452 | /// The labels over a scope's graticule, in the caption ink. The canvas paints the |
| 453 | /// lines; the words are plain text laid over it. |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | |
| 469 | |
| 470 | |
| 471 | |
| 472 | |
| 473 | |
| 474 | |
| 475 | |
| 476 | |
| 477 | |
| 478 | |
| 479 | |
| 480 | |
| 481 | |
| 482 | |
| 483 | |
| 484 | |
| 485 | |
| 486 | |
| 487 | |
| 488 | |
| 489 | |
| 490 | |
| 491 | |
| 492 | |
| 493 | |
| 494 | |
| 495 | |
| 496 | |
| 497 | |
| 498 | |
| 499 | |
| 500 | |
| 501 | |
| 502 | |
| 503 | |
| 504 | |
| 505 | |
| 506 | |
| 507 | |
| 508 | |
| 509 | |
| 510 | |
| 511 | |
| 512 | |
| 513 | |
| 514 | |
| 515 | |
| 516 | |
| 517 | |
| 518 | |
| 519 | |
| 520 | |
| 521 | |
| 522 | |
| 523 | |
| 524 | |
| 525 | |
| 526 | |
| 527 | |
| 528 | |
| 529 | |
| 530 | /// The picked curve drawn over the graph: the line, and the five grid points as |
| 531 | /// small squares, in the channel's ink (master in the light ink). |
| 532 | pub |
| 533 | |
| 534 | |
| 535 | |
| 536 | |
| 537 | |
| 538 | |
| 539 | |
| 540 | |
| 541 | |
| 542 | |
| 543 | |
| 544 | |
| 545 | |
| 546 | |
| 547 | |
| 548 | |
| 549 | |
| 550 | |
| 551 | |
| 552 | |
| 553 | |
| 554 | |
| 555 | |
| 556 | |
| 557 | |
| 558 | |
| 559 | |
| 560 | |
| 561 | |
| 562 | // -- the colour wheels ---------------------------------------------------------- |
| 563 | |
| 564 | /// How far a puck at the rim of a wheel pushes a channel: the wheel's R, G and B |
| 565 | /// offsets are `WHEEL_REACH` times the puck's position, so the rim is a strong |
| 566 | /// but usable tint and the sliders' -1..1 range stays far beyond it. |
| 567 | pub const WHEEL_REACH: f32 = 0.5; |
| 568 | |
| 569 | /// The R, G, B offsets a puck at `(x, y)` (right and up, the unit disc) stands |
| 570 | /// for: the hue is the angle (red at 3 o'clock, green at 7, blue at 11) and the |
| 571 | /// saturation the distance, so the three offsets always sum to zero and the |
| 572 | /// wheel tints without moving the master. |
| 573 | pub |
| 574 | |
| 575 | |
| 576 | |
| 577 | |
| 578 | |
| 579 | |
| 580 | |
| 581 | /// [`wheel_offsets`]' inverse: where the puck sits for an RGB offset (any mean the |
| 582 | /// three share is the master's business, not the pad's, and is dropped). |
| 583 | pub |
| 584 | |
| 585 | |
| 586 | |
| 587 | |
| 588 | |
| 589 | |
| 590 | /// A wheel's RGB offsets snapped to the hundredth the sliders land on. |
| 591 | pub |
| 592 | |
| 593 | |
| 594 | |
| 595 | /// A wheel's pad: the hue/saturation disc, a cross through the centre and the |
| 596 | /// puck at `(x, y)` (the unit disc, up positive). |
| 597 | pub |
| 598 | |
| 599 | |
| 600 | |
| 601 | |
| 602 | |
| 603 | |
| 604 | |
| 605 | |
| 606 | |
| 607 | |
| 608 | |
| 609 | |
| 610 | |
| 611 | |
| 612 | |
| 613 | |
| 614 | |
| 615 | |
| 616 | |
| 617 | |
| 618 | |
| 619 | |
| 620 | |
| 621 | |
| 622 | |
| 623 | |
| 624 | |
| 625 | |
| 626 | |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 | |
| 632 | |
| 633 | |
| 634 | |
| 635 | |
| 636 | |
| 637 | |
| 638 | |
| 639 | |
| 640 | |
| 641 | |
| 642 | |
| 643 | |
| 644 | |
| 645 |