aboutsummaryrefslogtreecommitdiff
path: root/docs/posts/SDL2_devlog/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/posts/SDL2_devlog/index.html')
-rw-r--r--docs/posts/SDL2_devlog/index.html68
1 files changed, 34 insertions, 34 deletions
diff --git a/docs/posts/SDL2_devlog/index.html b/docs/posts/SDL2_devlog/index.html
index f5e631f..0e76515 100644
--- a/docs/posts/SDL2_devlog/index.html
+++ b/docs/posts/SDL2_devlog/index.html
@@ -60,48 +60,48 @@
60</figure> 60</figure>
61<h3 id="day-17">Day 17</h3> 61<h3 id="day-17">Day 17</h3>
62<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> 62<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>
63<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> 63<div class="sourceCode" id="cb1"><pre class="sourceCode rust"><code class="sourceCode rust"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co">// roughly something like this</span></span>
64<span id="cb1-2"><a href="#cb1-2" aria-hidden="true"></a><span class="kw">let</span> statusline <span class="op">=</span> </span> 64<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="kw">let</span> statusline <span class="op">=</span> </span>
65<span id="cb1-3"><a href="#cb1-3" aria-hidden="true"></a> <span class="pp">Container::</span>new(<span class="pp">Offset::</span>Left(<span class="dv">0</span>)<span class="op">,</span> <span class="pp">Offset::</span>Bottom(<span class="dv">40</span>))</span> 65<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> <span class="pp">Container::</span>new(<span class="pp">Offset::</span>Left(<span class="dv">0</span>)<span class="op">,</span> <span class="pp">Offset::</span>Bottom(<span class="dv">40</span>))</span>
66<span id="cb1-4"><a href="#cb1-4" aria-hidden="true"></a> <span class="op">.</span>width(<span class="pp">Size::</span>Max)</span> 66<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a> <span class="op">.</span>width(<span class="pp">Size::</span>Max)</span>
67<span id="cb1-5"><a href="#cb1-5" aria-hidden="true"></a> <span class="op">.</span>height(<span class="pp">Size::</span>Absolute(<span class="dv">20</span>))<span class="op">;</span></span> 67<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a> <span class="op">.</span>height(<span class="pp">Size::</span>Absolute(<span class="dv">20</span>))<span class="op">;</span></span>
68<span id="cb1-6"><a href="#cb1-6" aria-hidden="true"></a> </span> 68<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a> </span>
69<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> 69<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="kw">let</span> <span class="kw">mut</span> primary <span class="op">=</span> <span class="pp">Container::</span>uninit()</span>
70<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> 70<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a> <span class="op">.</span>width(<span class="pp">Size::</span>Absolute(<span class="dv">16</span>))</span>
71<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> 71<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a> <span class="op">.</span>height(<span class="pp">Size::</span>Absolute(<span class="dv">16</span>))<span class="op">;</span></span>
72<span id="cb1-10"><a href="#cb1-10" aria-hidden="true"></a> </span> 72<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a> </span>
73<span id="cb1-11"><a href="#cb1-11" aria-hidden="true"></a>container<span class="op">.</span>place(</span> 73<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a>container<span class="op">.</span>place(</span>
74<span id="cb1-12"><a href="#cb1-12" aria-hidden="true"></a> <span class="op">&amp;</span><span class="kw">mut</span> padding_box<span class="op">,</span></span> 74<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a> <span class="op">&amp;</span><span class="kw">mut</span> padding_box<span class="op">,</span></span>
75<span id="cb1-13"><a href="#cb1-13" aria-hidden="true"></a> <span class="pp">HorAlign::</span>Right<span class="op">,</span></span> 75<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a> <span class="pp">HorAlign::</span>Right<span class="op">,</span></span>
76<span id="cb1-14"><a href="#cb1-14" aria-hidden="true"></a> <span class="pp">VertAlign::</span>Center</span> 76<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a> <span class="pp">VertAlign::</span>Center</span>
77<span id="cb1-15"><a href="#cb1-15" aria-hidden="true"></a>)<span class="op">;</span></span></code></pre></div> 77<span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a>)<span class="op">;</span></span></code></pre></div>
78<p>The result (brush preview on the bottom right):</p> 78<p>The result (brush preview on the bottom right):</p>
79<figure> 79<figure>
80<video src="https://u.peppe.rs/OtU.mp4" controls=""><a href="https://u.peppe.rs/OtU.mp4">Day 17</a></video><figcaption aria-hidden="true">Day 17</figcaption> 80<video src="https://u.peppe.rs/OtU.mp4" controls=""><a href="https://u.peppe.rs/OtU.mp4">Day 17</a></video><figcaption aria-hidden="true">Day 17</figcaption>
81</figure> 81</figure>
82<h3 id="day-16">Day 16</h3> 82<h3 id="day-16">Day 16</h3>
83<p>The embedded lisp is coming along nicely, users can load a custom <code>rc.lisp</code>, which is evaluated on startup. To disable to grid on start, for example:</p> 83<p>The embedded lisp is coming along nicely, users can load a custom <code>rc.lisp</code>, which is evaluated on startup. To disable to grid on start, for example:</p>
84<div class="sourceCode" id="cb2"><pre class="sourceCode scheme"><code class="sourceCode scheme"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true"></a><span class="co">;;; rc.lisp</span></span> 84<div class="sourceCode" id="cb2"><pre class="sourceCode scheme"><code class="sourceCode scheme"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co">;;; rc.lisp</span></span>
85<span id="cb2-2"><a href="#cb2-2" aria-hidden="true"></a>(toggle-grid)</span></code></pre></div> 85<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>(toggle-grid)</span></code></pre></div>
86<p>Some aliases to switch between brushes:</p> 86<p>Some aliases to switch between brushes:</p>
87<div class="sourceCode" id="cb3"><pre class="sourceCode scheme"><code class="sourceCode scheme"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true"></a><span class="co">;;; rc.lisp</span></span> 87<div class="sourceCode" id="cb3"><pre class="sourceCode scheme"><code class="sourceCode scheme"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co">;;; rc.lisp</span></span>
88<span id="cb3-2"><a href="#cb3-2" aria-hidden="true"></a>(<span class="ex">define</span><span class="fu"> </span>(brush kind)</span> 88<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>(<span class="ex">define</span><span class="fu"> </span>(brush kind)</span>
89<span id="cb3-3"><a href="#cb3-3" aria-hidden="true"></a> (<span class="kw">cond</span></span> 89<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> (<span class="kw">cond</span></span>
90<span id="cb3-4"><a href="#cb3-4" aria-hidden="true"></a> ((<span class="kw">eq?</span> kind &#39;f) (brush-fill))</span> 90<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> ((<span class="kw">eq?</span> kind &#39;f) (brush-fill))</span>
91<span id="cb3-5"><a href="#cb3-5" aria-hidden="true"></a> ((<span class="kw">eq?</span> kind &#39;c) (brush-circle))</span> 91<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> ((<span class="kw">eq?</span> kind &#39;c) (brush-circle))</span>
92<span id="cb3-6"><a href="#cb3-6" aria-hidden="true"></a> ((<span class="kw">eq?</span> kind &#39;l) (brush-line))</span> 92<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> ((<span class="kw">eq?</span> kind &#39;l) (brush-line))</span>
93<span id="cb3-7"><a href="#cb3-7" aria-hidden="true"></a> ((<span class="kw">eq?</span> kind &#39;l+) (brush-line-extend))</span> 93<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> ((<span class="kw">eq?</span> kind &#39;l+) (brush-line-extend))</span>
94<span id="cb3-8"><a href="#cb3-8" aria-hidden="true"></a> (<span class="kw">else</span> (brush-circle))))</span></code></pre></div> 94<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a> (<span class="kw">else</span> (brush-circle))))</span></code></pre></div>
95<p>The following script draws a straight line along a given axis, at a given distance from the canvas boundary:</p> 95<p>The following script draws a straight line along a given axis, at a given distance from the canvas boundary:</p>
96<figure> 96<figure>
97<video src="https://u.peppe.rs/b3i.mp4" controls=""><a href="https://u.peppe.rs/b3i.mp4">Day 16</a></video><figcaption aria-hidden="true">Day 16</figcaption> 97<video src="https://u.peppe.rs/b3i.mp4" controls=""><a href="https://u.peppe.rs/b3i.mp4">Day 16</a></video><figcaption aria-hidden="true">Day 16</figcaption>
98</figure> 98</figure>
99<h3 id="day-15">Day 15</h3> 99<h3 id="day-15">Day 15</h3>
100<p>I began writing a standard library for the lisp, in lisp. It includes basic list operations: <code>car</code>, <code>cdr</code>, <code>null?</code>, <code>list</code>, higher order functions: <code>map</code>, <code>filter</code>, <code>fold</code>:</p> 100<p>I began writing a standard library for the lisp, in lisp. It includes basic list operations: <code>car</code>, <code>cdr</code>, <code>null?</code>, <code>list</code>, higher order functions: <code>map</code>, <code>filter</code>, <code>fold</code>:</p>
101<div class="sourceCode" id="cb4"><pre class="sourceCode lisp"><code class="sourceCode commonlisp"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true"></a>(define (member? item ls)</span> 101<div class="sourceCode" id="cb4"><pre class="sourceCode lisp"><code class="sourceCode commonlisp"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>(define (member? item ls)</span>
102<span id="cb4-2"><a href="#cb4-2" aria-hidden="true"></a> (fold <span class="dv">#f</span></span> 102<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> (fold <span class="dv">#f</span></span>
103<span id="cb4-3"><a href="#cb4-3" aria-hidden="true"></a> (<span class="kw">lambda</span> (acc x) (<span class="kw">or</span> acc (eq? item x)))</span> 103<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> (<span class="kw">lambda</span> (acc x) (<span class="kw">or</span> acc (eq? item x)))</span>
104<span id="cb4-4"><a href="#cb4-4" aria-hidden="true"></a> ls))</span></code></pre></div> 104<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> ls))</span></code></pre></div>
105<h3 id="day-14">Day 14</h3> 105<h3 id="day-14">Day 14</h3>
106<p>I attempted a <a href="https://peppe.rs/art/ramen_noodles.png">small art piece</a> using the editor, while it was largely usable, I felt a certain lack of feedback. The brushes just didn’t relay as much info as I’d have liked, for example, the approximate points of the line or the angle made by the line against the x-axis. Unfortunately, the existing infrastructure around brushes and line drawing didn’t easily allow for this either. I went ahead and reimplemented brushes, and added a new flood fill brush too:</p> 106<p>I attempted a <a href="https://peppe.rs/art/ramen_noodles.png">small art piece</a> using the editor, while it was largely usable, I felt a certain lack of feedback. The brushes just didn’t relay as much info as I’d have liked, for example, the approximate points of the line or the angle made by the line against the x-axis. Unfortunately, the existing infrastructure around brushes and line drawing didn’t easily allow for this either. I went ahead and reimplemented brushes, and added a new flood fill brush too:</p>
107<figure> 107<figure>
@@ -134,11 +134,11 @@
134</figure> 134</figure>
135<h3 id="day-8">Day 8</h3> 135<h3 id="day-8">Day 8</h3>
136<p>One of my favourite features of GIMP was symmetric editing. I added some coordinate geometry primitives to my pixmap abstraction, allowing for mirroring and reflecting figures about lines or points. The result was an ergonomic function that applies symmetry to any painting operation, (undo/redo works as expected):</p> 136<p>One of my favourite features of GIMP was symmetric editing. I added some coordinate geometry primitives to my pixmap abstraction, allowing for mirroring and reflecting figures about lines or points. The result was an ergonomic function that applies symmetry to any painting operation, (undo/redo works as expected):</p>
137<div class="sourceCode" id="cb5"><pre class="sourceCode rust"><code class="sourceCode rust"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true"></a><span class="kw">let</span> line <span class="op">=</span> <span class="kw">self</span><span class="op">.</span>pixmap<span class="op">.</span>get_line(start<span class="op">,</span> end)<span class="op">;</span></span> 137<div class="sourceCode" id="cb5"><pre class="sourceCode rust"><code class="sourceCode rust"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="kw">let</span> line <span class="op">=</span> <span class="kw">self</span><span class="op">.</span>pixmap<span class="op">.</span>get_line(start<span class="op">,</span> end)<span class="op">;</span></span>
138<span id="cb5-2"><a href="#cb5-2" aria-hidden="true"></a><span class="kw">let</span> sym_line <span class="op">=</span> <span class="kw">self</span><span class="op">.</span>symmetry<span class="op">.</span>apply(<span class="op">&amp;</span>line)<span class="op">;</span></span> 138<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="kw">let</span> sym_line <span class="op">=</span> <span class="kw">self</span><span class="op">.</span>symmetry<span class="op">.</span>apply(<span class="op">&amp;</span>line)<span class="op">;</span></span>
139<span id="cb5-3"><a href="#cb5-3" aria-hidden="true"></a><span class="kw">for</span> point on line<span class="op">.</span>extend(sym_line) <span class="op">{</span></span> 139<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="kw">for</span> point on line<span class="op">.</span>extend(sym_line) <span class="op">{</span></span>
140<span id="cb5-4"><a href="#cb5-4" aria-hidden="true"></a> <span class="co">// draw to window</span></span> 140<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="co">// draw to window</span></span>
141<span id="cb5-5"><a href="#cb5-5" aria-hidden="true"></a><span class="op">}</span></span></code></pre></div> 141<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
142<figure> 142<figure>
143<video src="https://u.peppe.rs/B1.mp4" controls=""><a href="https://u.peppe.rs/B1.mp4">Day 8</a></video><figcaption aria-hidden="true">Day 8</figcaption> 143<video src="https://u.peppe.rs/B1.mp4" controls=""><a href="https://u.peppe.rs/B1.mp4">Day 8</a></video><figcaption aria-hidden="true">Day 8</figcaption>
144</figure> 144</figure>