From 938c4648b102975cd73f82457544ec7dc0318bfa Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 4 Oct 2021 08:10:24 +0530 Subject: new art: b8 --- docs/posts/SDL2_devlog/index.html | 68 +++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'docs/posts/SDL2_devlog') 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 @@

Day 17

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:

-
// roughly something like this
-let statusline = 
-    Container::new(Offset::Left(0), Offset::Bottom(40))
-    .width(Size::Max)
-    .height(Size::Absolute(20));
-    
-let mut primary = Container::uninit()
-    .width(Size::Absolute(16))
-    .height(Size::Absolute(16));
-    
-container.place(
-    &mut padding_box,
-    HorAlign::Right,
-    VertAlign::Center
-);
+
// roughly something like this
+let statusline = 
+    Container::new(Offset::Left(0), Offset::Bottom(40))
+    .width(Size::Max)
+    .height(Size::Absolute(20));
+    
+let mut primary = Container::uninit()
+    .width(Size::Absolute(16))
+    .height(Size::Absolute(16));
+    
+container.place(
+    &mut padding_box,
+    HorAlign::Right,
+    VertAlign::Center
+);

The result (brush preview on the bottom right):

Day 16

The embedded lisp is coming along nicely, users can load a custom rc.lisp, which is evaluated on startup. To disable to grid on start, for example:

-
;;; rc.lisp
-(toggle-grid)
+
;;; rc.lisp
+(toggle-grid)

Some aliases to switch between brushes:

-
;;; rc.lisp
-(define (brush kind)
-  (cond
-    ((eq? kind 'f) (brush-fill))
-    ((eq? kind 'c) (brush-circle))
-    ((eq? kind 'l) (brush-line))
-    ((eq? kind 'l+) (brush-line-extend))
-    (else (brush-circle))))
+
;;; rc.lisp
+(define (brush kind)
+  (cond
+    ((eq? kind 'f) (brush-fill))
+    ((eq? kind 'c) (brush-circle))
+    ((eq? kind 'l) (brush-line))
+    ((eq? kind 'l+) (brush-line-extend))
+    (else (brush-circle))))

The following script draws a straight line along a given axis, at a given distance from the canvas boundary:

Day 15

I began writing a standard library for the lisp, in lisp. It includes basic list operations: car, cdr, null?, list, higher order functions: map, filter, fold:

-
(define (member? item ls)
-  (fold #f
-        (lambda (acc x) (or acc (eq? item x)))
-        ls))
+
(define (member? item ls)
+  (fold #f
+        (lambda (acc x) (or acc (eq? item x)))
+        ls))

Day 14

I attempted a small art piece 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:

@@ -134,11 +134,11 @@

Day 8

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):

-
let line = self.pixmap.get_line(start, end);
-let sym_line = self.symmetry.apply(&line);
-for point on line.extend(sym_line) {
-    // draw to window
-}
+
let line = self.pixmap.get_line(start, end);
+let sym_line = self.symmetry.apply(&line);
+for point on line.extend(sym_line) {
+    // draw to window
+}
-- cgit v1.2.3