diff options
Diffstat (limited to 'docs/posts/SDL2_devlog')
-rw-r--r-- | docs/posts/SDL2_devlog/index.html | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/docs/posts/SDL2_devlog/index.html b/docs/posts/SDL2_devlog/index.html index 6b5fd96..5bfbaf6 100644 --- a/docs/posts/SDL2_devlog/index.html +++ b/docs/posts/SDL2_devlog/index.html | |||
@@ -25,15 +25,15 @@ | |||
25 | ">View Raw</a> | 25 | ">View Raw</a> |
26 | <div class="separator"></div> | 26 | <div class="separator"></div> |
27 | <div class="date"> | 27 | <div class="date"> |
28 | 02/04 — 2021 | 28 | 04/04 — 2021 |
29 | <div class="stats"> | 29 | <div class="stats"> |
30 | <span class="stats-number"> | 30 | <span class="stats-number"> |
31 | 105.89 | 31 | 114.29 |
32 | </span> | 32 | </span> |
33 | <span class="stats-unit">cm</span> | 33 | <span class="stats-unit">cm</span> |
34 |   | 34 |   |
35 | <span class="stats-number"> | 35 | <span class="stats-number"> |
36 | 8.1 | 36 | 9.1 |
37 | </span> | 37 | </span> |
38 | <span class="stats-unit">min</span> | 38 | <span class="stats-unit">min</span> |
39 | </div> | 39 | </div> |
@@ -43,6 +43,11 @@ | |||
43 | </h1> | 43 | </h1> |
44 | <div class="post-text"> | 44 | <div class="post-text"> |
45 | <p>I have been working on an editor for the <a href="https://git.peppe.rs/graphics/obi/about">One Bit Image</a> file format in Rust and SDL2. This entry in my blog follows my progress on the editor. The days are listed in reverse chronological order, begin from the bottom, if this is your first time on this page.</p> | 45 | <p>I have been working on an editor for the <a href="https://git.peppe.rs/graphics/obi/about">One Bit Image</a> file format in Rust and SDL2. This entry in my blog follows my progress on the editor. The days are listed in reverse chronological order, begin from the bottom, if this is your first time on this page.</p> |
46 | <h3 id="day-18">Day 18</h3> | ||
47 | <p>I added basic support for guides, they can be added and activated from the <code>lisp</code> REPL. Another long standing improvement I wanted to make was reworking the pixmap drawing procedure. The old procedure draws a square for each pixel in the pixmap, coloured according to its value in the pixmap. Naturally, this means, for an <strong>NxN</strong> pixmap, there are <strong>N²</strong> calls to SDL! I reworked this procedure to compress each line of the pixmap using RLE (run length encoding), and call out to SDL for each run in the line. This drastically improved drawing speeds on larger grids. The following is a comparison between the two procedures, the leftmost picture is the rendered image, the middle picture is the optimized drawing procedure (draws each run instead of pixel), and the right most picture is the primitive drawing procedure (draws each pixel):</p> | ||
48 | <figure> | ||
49 | <img src="https://u.peppe.rs/U4B.png" alt="Day 18" /><figcaption aria-hidden="true">Day 18</figcaption> | ||
50 | </figure> | ||
46 | <h3 id="day-17">Day 17</h3> | 51 | <h3 id="day-17">Day 17</h3> |
47 | <p>I decided to give the text-only statusline a touch up, by adding a active color and dither level preview. Aligning the “widget” to the right of statusline involved a lot more than I thought, so I created a ghetto CSS-like rectangle placement system to position containers inside containers:</p> | 52 | <p>I decided to give the text-only statusline a touch up, by adding a active color and dither level preview. Aligning the “widget” to the right of statusline involved a lot more than I thought, so I created a ghetto CSS-like rectangle placement system to position containers inside containers:</p> |
48 | <div class="sourceCode" id="cb1"><pre class="sourceCode rust"><code class="sourceCode rust"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true"></a><span class="co">// roughly something like this</span></span> | 53 | <div class="sourceCode" id="cb1"><pre class="sourceCode rust"><code class="sourceCode rust"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true"></a><span class="co">// roughly something like this</span></span> |
@@ -54,7 +59,7 @@ | |||
54 | <span id="cb1-7"><a href="#cb1-7" aria-hidden="true"></a><span class="kw">let</span> <span class="kw">mut</span> primary <span class="op">=</span> <span class="pp">Container::</span>uninit()</span> | 59 | <span id="cb1-7"><a href="#cb1-7" aria-hidden="true"></a><span class="kw">let</span> <span class="kw">mut</span> primary <span class="op">=</span> <span class="pp">Container::</span>uninit()</span> |
55 | <span id="cb1-8"><a href="#cb1-8" aria-hidden="true"></a> <span class="op">.</span>width(<span class="pp">Size::</span>Absolute(<span class="dv">16</span>))</span> | 60 | <span id="cb1-8"><a href="#cb1-8" aria-hidden="true"></a> <span class="op">.</span>width(<span class="pp">Size::</span>Absolute(<span class="dv">16</span>))</span> |
56 | <span id="cb1-9"><a href="#cb1-9" aria-hidden="true"></a> <span class="op">.</span>height(<span class="pp">Size::</span>Absolute(<span class="dv">16</span>))<span class="op">;</span></span> | 61 | <span id="cb1-9"><a href="#cb1-9" aria-hidden="true"></a> <span class="op">.</span>height(<span class="pp">Size::</span>Absolute(<span class="dv">16</span>))<span class="op">;</span></span> |
57 | <span id="cb1-10"><a href="#cb1-10" aria-hidden="true"></a></span> | 62 | <span id="cb1-10"><a href="#cb1-10" aria-hidden="true"></a> </span> |
58 | <span id="cb1-11"><a href="#cb1-11" aria-hidden="true"></a>container<span class="op">.</span>place(</span> | 63 | <span id="cb1-11"><a href="#cb1-11" aria-hidden="true"></a>container<span class="op">.</span>place(</span> |
59 | <span id="cb1-12"><a href="#cb1-12" aria-hidden="true"></a> <span class="op">&</span><span class="kw">mut</span> padding_box<span class="op">,</span></span> | 64 | <span id="cb1-12"><a href="#cb1-12" aria-hidden="true"></a> <span class="op">&</span><span class="kw">mut</span> padding_box<span class="op">,</span></span> |
60 | <span id="cb1-13"><a href="#cb1-13" aria-hidden="true"></a> <span class="pp">HorAlign::</span>Right<span class="op">,</span></span> | 65 | <span id="cb1-13"><a href="#cb1-13" aria-hidden="true"></a> <span class="pp">HorAlign::</span>Right<span class="op">,</span></span> |