Isometric Grammars

art

Table of Contents

Introduction

This post extends the ideas presented in Isometric Snowflakes adding other transformations on cuboids.

To do so, transformations are combined in (randomly generated) groups, then used to generate cuboids to add to the image.

Transformation

  • Swapping axes
  • Mirroring along an axis

Iteration 1

(defun plt-swap-random-both (obj)
  (plt-choice
   (plt-swap-xy-both obj)
   (plt-swap-xz-both obj)
   (plt-swap-yz-both obj)))

(defun plt-mirror-random-both (obj)
  (plt-choice
   (plt-mirror-x-at-both obj 64)
   (plt-mirror-x-at-both obj 64)
   (plt-mirror-x-at-both obj 64)))

(defun plt-translate-repeat-random (obj)
  (let ((times (plt-random-in-range 2 10))
        (step (plt-random-in-range 2 10)))
    (plt-choice
     (plt-translate-repeat-x obj step times)
     (plt-translate-repeat-y obj step times)
     (plt-translate-repeat-z obj step times))))

(defun plt-ig-random (obj)
  (plt-choice
   (plt-ig-random (plt-mirror-random-both obj))
   (plt-ig-random (plt-swap-random-both obj))
   (plt-ig-random (plt-swap-random-both obj))
   (plt-ig-random (plt-swap-random-both obj))
   (plt-ig-random (plt-translate-repeat-random obj))
   (plt-ig-random (plt-translate-repeat-random obj))
   (plt-ig-random (plt-translate-repeat-random obj))
   obj
   obj
   obj))

(let ((revision (format-time-string "%FT%H:%M:%S")))
  (dotimes (_i 100)
    (let* ((seed (plt-random-seed))
           (caption (vector (format "0x%s" seed))))
      (random seed)
      (let* ((grid-size 128)
             (n-cuboids (plt-random-pow2 1 4))
             (grid (plt-make-grid grid-size)))
        (dotimes (_ n-cuboids)
              (->
               (plt-random-iso-cuboid
                (plt-random-pow2-size 0 6)
                grid-size)
               (plt-ig-random)
               (plt-grid-add grid)))
        (plt-grid-to-image-bw
         grid
         (vector 32.0 32.0)
         (concat dir "/" revision "/" seed ".svg"))))))

DONE Implement repeat function

DONE Bounds check be adding cuboid to grid

DONE Allow isize for positions

TODO Remove random cuboids from image

DONE Bounding box f list of cuboids

TODO bounded + randomly placed translate repeat

generate, bb, move to origin, translate repeat, randomly place


If you have an idea how this page could be improved or a comment send me a mail.