#! /usr/bin/python3.13 from PIL import Image import numpy as np img = Image.open("data/src.webp").convert("L") w, h = img.size pxls = np.array(img, dtype=np.float32) z_norm = ((pxls / 255.0) * 2.0 - 1.0) * 16.0 verts = [] for y in range (0, h, 4): for x in range (0, w, 4): nx = (x / (w - 1.0)) * 2.0 - 1.0 ny = (y / (h - 1.0)) * 2.0 - 1.0 nz = float (z_norm [y, x]) verts.append ([nx, ny, nz, 1.0]) print (";;; bad-mesh.el --- we came out of a crazy mind -*- lexical-binding: t -*-") print (";;") print (";;; Commentary:") print (";;") print (";; Elisp mesh generated from Python and a webp image.") print (";; I guess I like it fine - so far.") print (";;") print (";;; Code:\n") print ("(defvar img-mesh)\n") print ("(setf img-mesh `[") st = False nd = False rd = False for v in verts: strv = str(v) if (not st): st = strv elif (not nd): nd = strv elif (not rd): rd = strv if (st and nd and rd): print (f"[ {st} {nd} {rd} ]") st = False nd = False rd = False print ("])\n") print ("(provide 'bad-mesh)") print (";;; bad-mesh.el ends here\n")