edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! Where a title card sits over the preview's picture, how much of it shows at |
| 2 | //! a frame, and which titles are up. Pure geometry, so the preview |
| 3 | //! ([`crate::ui::preview`]) draws what this says and the tests pin it without a |
| 4 | //! window. The numbers are the engine's ([`engine::text`]): the same margins, |
| 5 | //! the same size as a share of the picture height, the same box padding and |
| 6 | //! outline weights, so a title reads where the export burns it. |
| 7 | |
| 8 | use Title; |
| 9 | use ; |
| 10 | |
| 11 | /// The title-safe margin, as a share of the picture height, on all four sides. |
| 12 | pub const MARGIN: f32 = 0.05; |
| 13 | |
| 14 | /// The engine's line pitch in em: Archivo's ascent plus descent and line gap |
| 15 | /// (878 + 210 + 0 over 1000 units), times the engine's 1.1 leading. |
| 16 | pub const LINE_EM: f32 = * 1.1; |
| 17 | |
| 18 | /// The box behind the words, in em: the horizontal and vertical padding. |
| 19 | pub const BOX_PAD_X_EM: f32 = 0.3; |
| 20 | pub const BOX_PAD_Y_EM: f32 = 0.15; |
| 21 | |
| 22 | /// The smallest em the engine draws at, in px. |
| 23 | const MIN_EM_PX: f32 = 6.0; |
| 24 | |
| 25 | /// A rectangle in window pixels, or in the region's own local pixels: the |
| 26 | /// caller says which. |
| 27 | |
| 28 | pub |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | /// The rectangle a `frame_w` x `frame_h` picture takes when it is fitted inside |
| 36 | /// `region` and centred, the way the picture itself is drawn |
| 37 | /// ([`crate::render::letterboxed_image`], `ObjectFit::Contain`). An empty |
| 38 | /// picture or region has no picture to fit: the region comes back as it is. |
| 39 | pub |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | /// The em size in px for a style: its size in permille of the picture's |
| 54 | /// displayed height, as the engine reads it (`size / 1000 * frame height`), |
| 55 | /// with the engine's six-pixel floor. |
| 56 | pub |
| 57 | |
| 58 | |
| 59 | |
| 60 | /// The pitch of one line of a title at `em`. |
| 61 | pub |
| 62 | |
| 63 | |
| 64 | |
| 65 | /// The area a title's words are set in over `picture`: the picture inset by |
| 66 | /// the title-safe margin on all four sides. Words wrap to its width, and sit |
| 67 | /// at the top, the middle or the bottom of its height as the style's place |
| 68 | /// says: the drawn block's own height depends on how the words wrap, so the |
| 69 | /// vertical placement is the caller's to make inside this rectangle. |
| 70 | pub |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | /// The copies that draw the outline, in px offsets off the text, the engine's |
| 81 | /// stroke radius for the style's em: a radius of em/24 (thin) or em/12 (thick), |
| 82 | /// at least one and two px. Four diagonals for thin, eight around for thick. |
| 83 | pub |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | /// The opacity of a title at its frame: its 0 to 255 alpha as a fraction. |
| 105 | pub |
| 106 | |
| 107 | |
| 108 | |
| 109 | /// The titles up at timeline `frame`, in list order (a later one draws over an |
| 110 | /// earlier one), each with its alpha. A title whose fade has it at nothing is |
| 111 | /// not up. |
| 112 | pub |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 |