aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-04-02 06:41:44 +0100
committerAkshay <[email protected]>2021-04-02 06:41:44 +0100
commitc7a575d3fef907103a94ff444bb86c280e47148b (patch)
treee82b7fbebcb76002ac5122bc6e0d4092cf7eacd5
parentfe9b5edea79dfc508066efca2156aeb02cf16cde (diff)
add day 17 of devlog
-rw-r--r--docs/index.html4
-rw-r--r--docs/index.xml61
-rw-r--r--docs/posts/SDL2_devlog/index.html65
-rw-r--r--docs/posts/index.html4
-rw-r--r--posts/SDL2_devlog.md31
5 files changed, 119 insertions, 46 deletions
diff --git a/docs/index.html b/docs/index.html
index e151847..ef45474 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -42,7 +42,7 @@
42 <tr> 42 <tr>
43 <td class=table-post> 43 <td class=table-post>
44 <div class="date"> 44 <div class="date">
45 01/04 — 2021 45 02/04 — 2021
46 </div> 46 </div>
47 <a href="/posts/SDL2_devlog" class="post-link"> 47 <a href="/posts/SDL2_devlog" class="post-link">
48 <span class="post-link">SDL2 Devlog</span> 48 <span class="post-link">SDL2 Devlog</span>
@@ -50,7 +50,7 @@
50 </td> 50 </td>
51 <td class=table-stats> 51 <td class=table-stats>
52 <span class="stats-number"> 52 <span class="stats-number">
53 7.5 53 8.1
54 </span> 54 </span>
55 <span class=stats-unit>min</span> 55 <span class=stats-unit>min</span>
56 </td> 56 </td>
diff --git a/docs/index.xml b/docs/index.xml
index e13ccbb..8d876b6 100644
--- a/docs/index.xml
+++ b/docs/index.xml
@@ -14,29 +14,50 @@
14 <item> 14 <item>
15<title>SDL2 Devlog</title> 15<title>SDL2 Devlog</title>
16<description>&lt;p&gt;I have been working on an editor for the &lt;a href="https://git.peppe.rs/graphics/obi/about"&gt;One Bit Image&lt;/a&gt; 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.&lt;/p&gt; 16<description>&lt;p&gt;I have been working on an editor for the &lt;a href="https://git.peppe.rs/graphics/obi/about"&gt;One Bit Image&lt;/a&gt; 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.&lt;/p&gt;
17&lt;h3 id="day-17"&gt;Day 17&lt;/h3&gt;
18&lt;p&gt;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:&lt;/p&gt;
19&lt;div class="sourceCode" id="cb1"&gt;&lt;pre class="sourceCode rust"&gt;&lt;code class="sourceCode rust"&gt;&lt;span id="cb1-1"&gt;&lt;a href="#cb1-1" aria-hidden="true"&gt;&lt;/a&gt;&lt;span class="co"&gt;// roughly something like this&lt;/span&gt;&lt;/span&gt;
20&lt;span id="cb1-2"&gt;&lt;a href="#cb1-2" aria-hidden="true"&gt;&lt;/a&gt;&lt;span class="kw"&gt;let&lt;/span&gt; statusline &lt;span class="op"&gt;=&lt;/span&gt; &lt;/span&gt;
21&lt;span id="cb1-3"&gt;&lt;a href="#cb1-3" aria-hidden="true"&gt;&lt;/a&gt; &lt;span class="pp"&gt;Container::&lt;/span&gt;new(&lt;span class="pp"&gt;Offset::&lt;/span&gt;Left(&lt;span class="dv"&gt;0&lt;/span&gt;)&lt;span class="op"&gt;,&lt;/span&gt; &lt;span class="pp"&gt;Offset::&lt;/span&gt;Bottom(&lt;span class="dv"&gt;40&lt;/span&gt;))&lt;/span&gt;
22&lt;span id="cb1-4"&gt;&lt;a href="#cb1-4" aria-hidden="true"&gt;&lt;/a&gt; &lt;span class="op"&gt;.&lt;/span&gt;width(&lt;span class="pp"&gt;Size::&lt;/span&gt;Max)&lt;/span&gt;
23&lt;span id="cb1-5"&gt;&lt;a href="#cb1-5" aria-hidden="true"&gt;&lt;/a&gt; &lt;span class="op"&gt;.&lt;/span&gt;height(&lt;span class="pp"&gt;Size::&lt;/span&gt;Absolute(&lt;span class="dv"&gt;20&lt;/span&gt;))&lt;span class="op"&gt;;&lt;/span&gt;&lt;/span&gt;
24&lt;span id="cb1-6"&gt;&lt;a href="#cb1-6" aria-hidden="true"&gt;&lt;/a&gt; &lt;/span&gt;
25&lt;span id="cb1-7"&gt;&lt;a href="#cb1-7" aria-hidden="true"&gt;&lt;/a&gt;&lt;span class="kw"&gt;let&lt;/span&gt; &lt;span class="kw"&gt;mut&lt;/span&gt; primary &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="pp"&gt;Container::&lt;/span&gt;uninit()&lt;/span&gt;
26&lt;span id="cb1-8"&gt;&lt;a href="#cb1-8" aria-hidden="true"&gt;&lt;/a&gt; &lt;span class="op"&gt;.&lt;/span&gt;width(&lt;span class="pp"&gt;Size::&lt;/span&gt;Absolute(&lt;span class="dv"&gt;16&lt;/span&gt;))&lt;/span&gt;
27&lt;span id="cb1-9"&gt;&lt;a href="#cb1-9" aria-hidden="true"&gt;&lt;/a&gt; &lt;span class="op"&gt;.&lt;/span&gt;height(&lt;span class="pp"&gt;Size::&lt;/span&gt;Absolute(&lt;span class="dv"&gt;16&lt;/span&gt;))&lt;span class="op"&gt;;&lt;/span&gt;&lt;/span&gt;
28&lt;span id="cb1-10"&gt;&lt;a href="#cb1-10" aria-hidden="true"&gt;&lt;/a&gt;&lt;/span&gt;
29&lt;span id="cb1-11"&gt;&lt;a href="#cb1-11" aria-hidden="true"&gt;&lt;/a&gt;container&lt;span class="op"&gt;.&lt;/span&gt;place(&lt;/span&gt;
30&lt;span id="cb1-12"&gt;&lt;a href="#cb1-12" aria-hidden="true"&gt;&lt;/a&gt; &lt;span class="op"&gt;&amp;amp;&lt;/span&gt;&lt;span class="kw"&gt;mut&lt;/span&gt; padding_box&lt;span class="op"&gt;,&lt;/span&gt;&lt;/span&gt;
31&lt;span id="cb1-13"&gt;&lt;a href="#cb1-13" aria-hidden="true"&gt;&lt;/a&gt; &lt;span class="pp"&gt;HorAlign::&lt;/span&gt;Right&lt;span class="op"&gt;,&lt;/span&gt;&lt;/span&gt;
32&lt;span id="cb1-14"&gt;&lt;a href="#cb1-14" aria-hidden="true"&gt;&lt;/a&gt; &lt;span class="pp"&gt;VertAlign::&lt;/span&gt;Center&lt;/span&gt;
33&lt;span id="cb1-15"&gt;&lt;a href="#cb1-15" aria-hidden="true"&gt;&lt;/a&gt;)&lt;span class="op"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
34&lt;p&gt;The result (brush preview on the bottom right):&lt;/p&gt;
35&lt;figure&gt;
36&lt;video src="https://u.peppe.rs/OtU.mp4" controls=""&gt;&lt;a href="https://u.peppe.rs/OtU.mp4"&gt;Day 17&lt;/a&gt;&lt;/video&gt;&lt;figcaption aria-hidden="true"&gt;Day 17&lt;/figcaption&gt;
37&lt;/figure&gt;
17&lt;h3 id="day-16"&gt;Day 16&lt;/h3&gt; 38&lt;h3 id="day-16"&gt;Day 16&lt;/h3&gt;
18&lt;p&gt;The embedded lisp is coming along nicely, users can load a custom &lt;code&gt;rc.lisp&lt;/code&gt;, which is evaluated on startup. To disable to grid on start, for example:&lt;/p&gt; 39&lt;p&gt;The embedded lisp is coming along nicely, users can load a custom &lt;code&gt;rc.lisp&lt;/code&gt;, which is evaluated on startup. To disable to grid on start, for example:&lt;/p&gt;
19&lt;div class="sourceCode" id="cb1"&gt;&lt;pre class="sourceCode scheme"&gt;&lt;code class="sourceCode scheme"&gt;&lt;span id="cb1-1"&gt;&lt;a href="#cb1-1" aria-hidden="true"&gt;&lt;/a&gt;&lt;span class="co"&gt;;;; rc.lisp&lt;/span&gt;&lt;/span&gt;
20&lt;span id="cb1-2"&gt;&lt;a href="#cb1-2" aria-hidden="true"&gt;&lt;/a&gt;(toggle-grid)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
21&lt;p&gt;Some aliases to switch between brushes:&lt;/p&gt;
22&lt;div class="sourceCode" id="cb2"&gt;&lt;pre class="sourceCode scheme"&gt;&lt;code class="sourceCode scheme"&gt;&lt;span id="cb2-1"&gt;&lt;a href="#cb2-1" aria-hidden="true"&gt;&lt;/a&gt;&lt;span class="co"&gt;;;; rc.lisp&lt;/span&gt;&lt;/span&gt; 40&lt;div class="sourceCode" id="cb2"&gt;&lt;pre class="sourceCode scheme"&gt;&lt;code class="sourceCode scheme"&gt;&lt;span id="cb2-1"&gt;&lt;a href="#cb2-1" aria-hidden="true"&gt;&lt;/a&gt;&lt;span class="co"&gt;;;; rc.lisp&lt;/span&gt;&lt;/span&gt;
23&lt;span id="cb2-2"&gt;&lt;a href="#cb2-2" aria-hidden="true"&gt;&lt;/a&gt;(&lt;span class="ex"&gt;define&lt;/span&gt;&lt;span class="fu"&gt; &lt;/span&gt;(brush kind)&lt;/span&gt; 41&lt;span id="cb2-2"&gt;&lt;a href="#cb2-2" aria-hidden="true"&gt;&lt;/a&gt;(toggle-grid)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
24&lt;span id="cb2-3"&gt;&lt;a href="#cb2-3" aria-hidden="true"&gt;&lt;/a&gt; (&lt;span class="kw"&gt;cond&lt;/span&gt;&lt;/span&gt; 42&lt;p&gt;Some aliases to switch between brushes:&lt;/p&gt;
25&lt;span id="cb2-4"&gt;&lt;a href="#cb2-4" aria-hidden="true"&gt;&lt;/a&gt; ((&lt;span class="kw"&gt;eq?&lt;/span&gt; kind &amp;#39;f) (brush-fill))&lt;/span&gt; 43&lt;div class="sourceCode" id="cb3"&gt;&lt;pre class="sourceCode scheme"&gt;&lt;code class="sourceCode scheme"&gt;&lt;span id="cb3-1"&gt;&lt;a href="#cb3-1" aria-hidden="true"&gt;&lt;/a&gt;&lt;span class="co"&gt;;;; rc.lisp&lt;/span&gt;&lt;/span&gt;
26&lt;span id="cb2-5"&gt;&lt;a href="#cb2-5" aria-hidden="true"&gt;&lt;/a&gt; ((&lt;span class="kw"&gt;eq?&lt;/span&gt; kind &amp;#39;c) (brush-circle))&lt;/span&gt; 44&lt;span id="cb3-2"&gt;&lt;a href="#cb3-2" aria-hidden="true"&gt;&lt;/a&gt;(&lt;span class="ex"&gt;define&lt;/span&gt;&lt;span class="fu"&gt; &lt;/span&gt;(brush kind)&lt;/span&gt;
27&lt;span id="cb2-6"&gt;&lt;a href="#cb2-6" aria-hidden="true"&gt;&lt;/a&gt; ((&lt;span class="kw"&gt;eq?&lt;/span&gt; kind &amp;#39;l) (brush-line))&lt;/span&gt; 45&lt;span id="cb3-3"&gt;&lt;a href="#cb3-3" aria-hidden="true"&gt;&lt;/a&gt; (&lt;span class="kw"&gt;cond&lt;/span&gt;&lt;/span&gt;
28&lt;span id="cb2-7"&gt;&lt;a href="#cb2-7" aria-hidden="true"&gt;&lt;/a&gt; ((&lt;span class="kw"&gt;eq?&lt;/span&gt; kind &amp;#39;l+) (brush-line-extend))&lt;/span&gt; 46&lt;span id="cb3-4"&gt;&lt;a href="#cb3-4" aria-hidden="true"&gt;&lt;/a&gt; ((&lt;span class="kw"&gt;eq?&lt;/span&gt; kind &amp;#39;f) (brush-fill))&lt;/span&gt;
29&lt;span id="cb2-8"&gt;&lt;a href="#cb2-8" aria-hidden="true"&gt;&lt;/a&gt; (&lt;span class="kw"&gt;else&lt;/span&gt; (brush-circle))))&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; 47&lt;span id="cb3-5"&gt;&lt;a href="#cb3-5" aria-hidden="true"&gt;&lt;/a&gt; ((&lt;span class="kw"&gt;eq?&lt;/span&gt; kind &amp;#39;c) (brush-circle))&lt;/span&gt;
48&lt;span id="cb3-6"&gt;&lt;a href="#cb3-6" aria-hidden="true"&gt;&lt;/a&gt; ((&lt;span class="kw"&gt;eq?&lt;/span&gt; kind &amp;#39;l) (brush-line))&lt;/span&gt;
49&lt;span id="cb3-7"&gt;&lt;a href="#cb3-7" aria-hidden="true"&gt;&lt;/a&gt; ((&lt;span class="kw"&gt;eq?&lt;/span&gt; kind &amp;#39;l+) (brush-line-extend))&lt;/span&gt;
50&lt;span id="cb3-8"&gt;&lt;a href="#cb3-8" aria-hidden="true"&gt;&lt;/a&gt; (&lt;span class="kw"&gt;else&lt;/span&gt; (brush-circle))))&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
30&lt;p&gt;The following script draws a straight line along a given axis, at a given distance from the canvas boundary:&lt;/p&gt; 51&lt;p&gt;The following script draws a straight line along a given axis, at a given distance from the canvas boundary:&lt;/p&gt;
31&lt;figure&gt; 52&lt;figure&gt;
32&lt;video src="https://u.peppe.rs/b3i.mp4" controls=""&gt;&lt;a href="https://u.peppe.rs/b3i.mp4"&gt;Day 16&lt;/a&gt;&lt;/video&gt;&lt;figcaption aria-hidden="true"&gt;Day 16&lt;/figcaption&gt; 53&lt;video src="https://u.peppe.rs/b3i.mp4" controls=""&gt;&lt;a href="https://u.peppe.rs/b3i.mp4"&gt;Day 16&lt;/a&gt;&lt;/video&gt;&lt;figcaption aria-hidden="true"&gt;Day 16&lt;/figcaption&gt;
33&lt;/figure&gt; 54&lt;/figure&gt;
34&lt;h3 id="day-15"&gt;Day 15&lt;/h3&gt; 55&lt;h3 id="day-15"&gt;Day 15&lt;/h3&gt;
35&lt;p&gt;I began writing a standard library for the lisp, in lisp. It includes basic list operations: &lt;code&gt;car&lt;/code&gt;, &lt;code&gt;cdr&lt;/code&gt;, &lt;code&gt;null?&lt;/code&gt;, &lt;code&gt;list&lt;/code&gt;, higher order functions: &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;filter&lt;/code&gt;, &lt;code&gt;fold&lt;/code&gt;:&lt;/p&gt; 56&lt;p&gt;I began writing a standard library for the lisp, in lisp. It includes basic list operations: &lt;code&gt;car&lt;/code&gt;, &lt;code&gt;cdr&lt;/code&gt;, &lt;code&gt;null?&lt;/code&gt;, &lt;code&gt;list&lt;/code&gt;, higher order functions: &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;filter&lt;/code&gt;, &lt;code&gt;fold&lt;/code&gt;:&lt;/p&gt;
36&lt;div class="sourceCode" id="cb3"&gt;&lt;pre class="sourceCode lisp"&gt;&lt;code class="sourceCode commonlisp"&gt;&lt;span id="cb3-1"&gt;&lt;a href="#cb3-1" aria-hidden="true"&gt;&lt;/a&gt;(define (member? item ls)&lt;/span&gt; 57&lt;div class="sourceCode" id="cb4"&gt;&lt;pre class="sourceCode lisp"&gt;&lt;code class="sourceCode commonlisp"&gt;&lt;span id="cb4-1"&gt;&lt;a href="#cb4-1" aria-hidden="true"&gt;&lt;/a&gt;(define (member? item ls)&lt;/span&gt;
37&lt;span id="cb3-2"&gt;&lt;a href="#cb3-2" aria-hidden="true"&gt;&lt;/a&gt; (fold &lt;span class="dv"&gt;#f&lt;/span&gt;&lt;/span&gt; 58&lt;span id="cb4-2"&gt;&lt;a href="#cb4-2" aria-hidden="true"&gt;&lt;/a&gt; (fold &lt;span class="dv"&gt;#f&lt;/span&gt;&lt;/span&gt;
38&lt;span id="cb3-3"&gt;&lt;a href="#cb3-3" aria-hidden="true"&gt;&lt;/a&gt; (&lt;span class="kw"&gt;lambda&lt;/span&gt; (acc x) (&lt;span class="kw"&gt;or&lt;/span&gt; acc (eq? item x)))&lt;/span&gt; 59&lt;span id="cb4-3"&gt;&lt;a href="#cb4-3" aria-hidden="true"&gt;&lt;/a&gt; (&lt;span class="kw"&gt;lambda&lt;/span&gt; (acc x) (&lt;span class="kw"&gt;or&lt;/span&gt; acc (eq? item x)))&lt;/span&gt;
39&lt;span id="cb3-4"&gt;&lt;a href="#cb3-4" aria-hidden="true"&gt;&lt;/a&gt; ls))&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; 60&lt;span id="cb4-4"&gt;&lt;a href="#cb4-4" aria-hidden="true"&gt;&lt;/a&gt; ls))&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
40&lt;h3 id="day-14"&gt;Day 14&lt;/h3&gt; 61&lt;h3 id="day-14"&gt;Day 14&lt;/h3&gt;
41&lt;p&gt;I attempted a &lt;a href="https://peppe.rs/art/ramen_noodles.png"&gt;small art piece&lt;/a&gt; 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:&lt;/p&gt; 62&lt;p&gt;I attempted a &lt;a href="https://peppe.rs/art/ramen_noodles.png"&gt;small art piece&lt;/a&gt; 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:&lt;/p&gt;
42&lt;figure&gt; 63&lt;figure&gt;
@@ -69,11 +90,11 @@
69&lt;/figure&gt; 90&lt;/figure&gt;
70&lt;h3 id="day-8"&gt;Day 8&lt;/h3&gt; 91&lt;h3 id="day-8"&gt;Day 8&lt;/h3&gt;
71&lt;p&gt;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):&lt;/p&gt; 92&lt;p&gt;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):&lt;/p&gt;
72&lt;div class="sourceCode" id="cb4"&gt;&lt;pre class="sourceCode rust"&gt;&lt;code class="sourceCode rust"&gt;&lt;span id="cb4-1"&gt;&lt;a href="#cb4-1" aria-hidden="true"&gt;&lt;/a&gt;&lt;span class="kw"&gt;let&lt;/span&gt; line &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="kw"&gt;self&lt;/span&gt;&lt;span class="op"&gt;.&lt;/span&gt;pixmap&lt;span class="op"&gt;.&lt;/span&gt;get_line(start&lt;span class="op"&gt;,&lt;/span&gt; end)&lt;span class="op"&gt;;&lt;/span&gt;&lt;/span&gt; 93&lt;div class="sourceCode" id="cb5"&gt;&lt;pre class="sourceCode rust"&gt;&lt;code class="sourceCode rust"&gt;&lt;span id="cb5-1"&gt;&lt;a href="#cb5-1" aria-hidden="true"&gt;&lt;/a&gt;&lt;span class="kw"&gt;let&lt;/span&gt; line &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="kw"&gt;self&lt;/span&gt;&lt;span class="op"&gt;.&lt;/span&gt;pixmap&lt;span class="op"&gt;.&lt;/span&gt;get_line(start&lt;span class="op"&gt;,&lt;/span&gt; end)&lt;span class="op"&gt;;&lt;/span&gt;&lt;/span&gt;
73&lt;span id="cb4-2"&gt;&lt;a href="#cb4-2" aria-hidden="true"&gt;&lt;/a&gt;&lt;span class="kw"&gt;let&lt;/span&gt; sym_line &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="kw"&gt;self&lt;/span&gt;&lt;span class="op"&gt;.&lt;/span&gt;symmetry&lt;span class="op"&gt;.&lt;/span&gt;apply(&lt;span class="op"&gt;&amp;amp;&lt;/span&gt;line)&lt;span class="op"&gt;;&lt;/span&gt;&lt;/span&gt; 94&lt;span id="cb5-2"&gt;&lt;a href="#cb5-2" aria-hidden="true"&gt;&lt;/a&gt;&lt;span class="kw"&gt;let&lt;/span&gt; sym_line &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="kw"&gt;self&lt;/span&gt;&lt;span class="op"&gt;.&lt;/span&gt;symmetry&lt;span class="op"&gt;.&lt;/span&gt;apply(&lt;span class="op"&gt;&amp;amp;&lt;/span&gt;line)&lt;span class="op"&gt;;&lt;/span&gt;&lt;/span&gt;
74&lt;span id="cb4-3"&gt;&lt;a href="#cb4-3" aria-hidden="true"&gt;&lt;/a&gt;&lt;span class="kw"&gt;for&lt;/span&gt; point on line&lt;span class="op"&gt;.&lt;/span&gt;extend(sym_line) &lt;span class="op"&gt;{&lt;/span&gt;&lt;/span&gt; 95&lt;span id="cb5-3"&gt;&lt;a href="#cb5-3" aria-hidden="true"&gt;&lt;/a&gt;&lt;span class="kw"&gt;for&lt;/span&gt; point on line&lt;span class="op"&gt;.&lt;/span&gt;extend(sym_line) &lt;span class="op"&gt;{&lt;/span&gt;&lt;/span&gt;
75&lt;span id="cb4-4"&gt;&lt;a href="#cb4-4" aria-hidden="true"&gt;&lt;/a&gt; &lt;span class="co"&gt;// draw to window&lt;/span&gt;&lt;/span&gt; 96&lt;span id="cb5-4"&gt;&lt;a href="#cb5-4" aria-hidden="true"&gt;&lt;/a&gt; &lt;span class="co"&gt;// draw to window&lt;/span&gt;&lt;/span&gt;
76&lt;span id="cb4-5"&gt;&lt;a href="#cb4-5" aria-hidden="true"&gt;&lt;/a&gt;&lt;span class="op"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; 97&lt;span id="cb5-5"&gt;&lt;a href="#cb5-5" aria-hidden="true"&gt;&lt;/a&gt;&lt;span class="op"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
77&lt;figure&gt; 98&lt;figure&gt;
78&lt;video src="https://u.peppe.rs/B1.mp4" controls=""&gt;&lt;a href="https://u.peppe.rs/B1.mp4"&gt;Day 8&lt;/a&gt;&lt;/video&gt;&lt;figcaption aria-hidden="true"&gt;Day 8&lt;/figcaption&gt; 99&lt;video src="https://u.peppe.rs/B1.mp4" controls=""&gt;&lt;a href="https://u.peppe.rs/B1.mp4"&gt;Day 8&lt;/a&gt;&lt;/video&gt;&lt;figcaption aria-hidden="true"&gt;Day 8&lt;/figcaption&gt;
79&lt;/figure&gt; 100&lt;/figure&gt;
@@ -113,7 +134,7 @@
113&lt;img src="https://u.peppe.rs/Ma.png" alt="Day 1" /&gt;&lt;figcaption aria-hidden="true"&gt;Day 1&lt;/figcaption&gt; 134&lt;img src="https://u.peppe.rs/Ma.png" alt="Day 1" /&gt;&lt;figcaption aria-hidden="true"&gt;Day 1&lt;/figcaption&gt;
114&lt;/figure&gt;</description> 135&lt;/figure&gt;</description>
115<link>https://peppe.rs/posts/SDL2_devlog/</link> 136<link>https://peppe.rs/posts/SDL2_devlog/</link>
116<pubDate>Thu, 01 Apr 2021 04:11:00 +0000</pubDate> 137<pubDate>Fri, 02 Apr 2021 05:01:00 +0000</pubDate>
117<guid>https://peppe.rs/posts/SDL2_devlog/</guid> 138<guid>https://peppe.rs/posts/SDL2_devlog/</guid>
118</item> 139</item>
119<item> 140<item>
diff --git a/docs/posts/SDL2_devlog/index.html b/docs/posts/SDL2_devlog/index.html
index 80cb297..6b5fd96 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 01/04 — 2021 28 02/04 — 2021
29 <div class="stats"> 29 <div class="stats">
30 <span class="stats-number"> 30 <span class="stats-number">
31 93.51 31 105.89
32 </span> 32 </span>
33 <span class="stats-unit">cm</span> 33 <span class="stats-unit">cm</span>
34 &nbsp 34 &nbsp
35 <span class="stats-number"> 35 <span class="stats-number">
36 7.5 36 8.1
37 </span> 37 </span>
38 <span class="stats-unit">min</span> 38 <span class="stats-unit">min</span>
39 </div> 39 </div>
@@ -43,29 +43,50 @@
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-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>
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>
49<span id="cb1-2"><a href="#cb1-2" aria-hidden="true"></a><span class="kw">let</span> statusline <span class="op">=</span> </span>
50<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>
51<span id="cb1-4"><a href="#cb1-4" aria-hidden="true"></a> <span class="op">.</span>width(<span class="pp">Size::</span>Max)</span>
52<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>
53<span id="cb1-6"><a href="#cb1-6" aria-hidden="true"></a> </span>
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>
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>
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>
57<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>
59<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>
60<span id="cb1-13"><a href="#cb1-13" aria-hidden="true"></a> <span class="pp">HorAlign::</span>Right<span class="op">,</span></span>
61<span id="cb1-14"><a href="#cb1-14" aria-hidden="true"></a> <span class="pp">VertAlign::</span>Center</span>
62<span id="cb1-15"><a href="#cb1-15" aria-hidden="true"></a>)<span class="op">;</span></span></code></pre></div>
63<p>The result (brush preview on the bottom right):</p>
64<figure>
65<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>
66</figure>
46<h3 id="day-16">Day 16</h3> 67<h3 id="day-16">Day 16</h3>
47<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> 68<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>
48<div class="sourceCode" id="cb1"><pre class="sourceCode scheme"><code class="sourceCode scheme"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true"></a><span class="co">;;; rc.lisp</span></span>
49<span id="cb1-2"><a href="#cb1-2" aria-hidden="true"></a>(toggle-grid)</span></code></pre></div>
50<p>Some aliases to switch between brushes:</p>
51<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> 69<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>
52<span id="cb2-2"><a href="#cb2-2" aria-hidden="true"></a>(<span class="ex">define</span><span class="fu"> </span>(brush kind)</span> 70<span id="cb2-2"><a href="#cb2-2" aria-hidden="true"></a>(toggle-grid)</span></code></pre></div>
53<span id="cb2-3"><a href="#cb2-3" aria-hidden="true"></a> (<span class="kw">cond</span></span> 71<p>Some aliases to switch between brushes:</p>
54<span id="cb2-4"><a href="#cb2-4" aria-hidden="true"></a> ((<span class="kw">eq?</span> kind &#39;f) (brush-fill))</span> 72<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>
55<span id="cb2-5"><a href="#cb2-5" aria-hidden="true"></a> ((<span class="kw">eq?</span> kind &#39;c) (brush-circle))</span> 73<span id="cb3-2"><a href="#cb3-2" aria-hidden="true"></a>(<span class="ex">define</span><span class="fu"> </span>(brush kind)</span>
56<span id="cb2-6"><a href="#cb2-6" aria-hidden="true"></a> ((<span class="kw">eq?</span> kind &#39;l) (brush-line))</span> 74<span id="cb3-3"><a href="#cb3-3" aria-hidden="true"></a> (<span class="kw">cond</span></span>
57<span id="cb2-7"><a href="#cb2-7" aria-hidden="true"></a> ((<span class="kw">eq?</span> kind &#39;l+) (brush-line-extend))</span> 75<span id="cb3-4"><a href="#cb3-4" aria-hidden="true"></a> ((<span class="kw">eq?</span> kind &#39;f) (brush-fill))</span>
58<span id="cb2-8"><a href="#cb2-8" aria-hidden="true"></a> (<span class="kw">else</span> (brush-circle))))</span></code></pre></div> 76<span id="cb3-5"><a href="#cb3-5" aria-hidden="true"></a> ((<span class="kw">eq?</span> kind &#39;c) (brush-circle))</span>
77<span id="cb3-6"><a href="#cb3-6" aria-hidden="true"></a> ((<span class="kw">eq?</span> kind &#39;l) (brush-line))</span>
78<span id="cb3-7"><a href="#cb3-7" aria-hidden="true"></a> ((<span class="kw">eq?</span> kind &#39;l+) (brush-line-extend))</span>
79<span id="cb3-8"><a href="#cb3-8" aria-hidden="true"></a> (<span class="kw">else</span> (brush-circle))))</span></code></pre></div>
59<p>The following script draws a straight line along a given axis, at a given distance from the canvas boundary:</p> 80<p>The following script draws a straight line along a given axis, at a given distance from the canvas boundary:</p>
60<figure> 81<figure>
61<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> 82<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>
62</figure> 83</figure>
63<h3 id="day-15">Day 15</h3> 84<h3 id="day-15">Day 15</h3>
64<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> 85<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>
65<div class="sourceCode" id="cb3"><pre class="sourceCode lisp"><code class="sourceCode commonlisp"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true"></a>(define (member? item ls)</span> 86<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>
66<span id="cb3-2"><a href="#cb3-2" aria-hidden="true"></a> (fold <span class="dv">#f</span></span> 87<span id="cb4-2"><a href="#cb4-2" aria-hidden="true"></a> (fold <span class="dv">#f</span></span>
67<span id="cb3-3"><a href="#cb3-3" aria-hidden="true"></a> (<span class="kw">lambda</span> (acc x) (<span class="kw">or</span> acc (eq? item x)))</span> 88<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>
68<span id="cb3-4"><a href="#cb3-4" aria-hidden="true"></a> ls))</span></code></pre></div> 89<span id="cb4-4"><a href="#cb4-4" aria-hidden="true"></a> ls))</span></code></pre></div>
69<h3 id="day-14">Day 14</h3> 90<h3 id="day-14">Day 14</h3>
70<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> 91<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>
71<figure> 92<figure>
@@ -98,11 +119,11 @@
98</figure> 119</figure>
99<h3 id="day-8">Day 8</h3> 120<h3 id="day-8">Day 8</h3>
100<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> 121<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>
101<div class="sourceCode" id="cb4"><pre class="sourceCode rust"><code class="sourceCode rust"><span id="cb4-1"><a href="#cb4-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> 122<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>
102<span id="cb4-2"><a href="#cb4-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> 123<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>
103<span id="cb4-3"><a href="#cb4-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> 124<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>
104<span id="cb4-4"><a href="#cb4-4" aria-hidden="true"></a> <span class="co">// draw to window</span></span> 125<span id="cb5-4"><a href="#cb5-4" aria-hidden="true"></a> <span class="co">// draw to window</span></span>
105<span id="cb4-5"><a href="#cb4-5" aria-hidden="true"></a><span class="op">}</span></span></code></pre></div> 126<span id="cb5-5"><a href="#cb5-5" aria-hidden="true"></a><span class="op">}</span></span></code></pre></div>
106<figure> 127<figure>
107<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> 128<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>
108</figure> 129</figure>
diff --git a/docs/posts/index.html b/docs/posts/index.html
index 697b522..8dcf25c 100644
--- a/docs/posts/index.html
+++ b/docs/posts/index.html
@@ -27,7 +27,7 @@
27 <tr> 27 <tr>
28 <td class=table-post> 28 <td class=table-post>
29 <div class="date"> 29 <div class="date">
30 01/04 — 2021 30 02/04 — 2021
31 </div> 31 </div>
32 <a href="/posts/SDL2_devlog" class="post-link"> 32 <a href="/posts/SDL2_devlog" class="post-link">
33 <span class="post-link">SDL2 Devlog</span> 33 <span class="post-link">SDL2 Devlog</span>
@@ -35,7 +35,7 @@
35 </td> 35 </td>
36 <td class=table-stats> 36 <td class=table-stats>
37 <span class="stats-number"> 37 <span class="stats-number">
38 7.5 38 8.1
39 </span> 39 </span>
40 <span class=stats-unit>min</span> 40 <span class=stats-unit>min</span>
41 </td> 41 </td>
diff --git a/posts/SDL2_devlog.md b/posts/SDL2_devlog.md
index 991a246..eb11de8 100644
--- a/posts/SDL2_devlog.md
+++ b/posts/SDL2_devlog.md
@@ -5,6 +5,37 @@ on the editor. The days are listed in reverse chronological
5order, begin from the bottom, if this is your first time on 5order, begin from the bottom, if this is your first time on
6this page. 6this page.
7 7
8### Day 17
9
10I decided to give the text-only statusline a touch up, by
11adding a active color and dither level preview. Aligning the
12"widget" to the right of statusline involved a lot more than
13I thought, so I created a ghetto CSS-like rectangle
14placement system to position containers inside containers:
15
16```rust
17// roughly something like this
18let statusline =
19 Container::new(Offset::Left(0), Offset::Bottom(40))
20 .width(Size::Max)
21 .height(Size::Absolute(20));
22
23let mut primary = Container::uninit()
24 .width(Size::Absolute(16))
25 .height(Size::Absolute(16));
26
27container.place(
28 &mut padding_box,
29 HorAlign::Right,
30 VertAlign::Center
31);
32```
33
34The result (brush preview on the bottom right):
35
36![Day 17](https://u.peppe.rs/OtU.mp4)
37
38
8### Day 16 39### Day 16
9 40
10The embedded lisp is coming along nicely, users can load 41The embedded lisp is coming along nicely, users can load