[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 92120d3 3/3: [xpm] Make ‘flower’ size customizable.
From: |
Thien-Thi Nguyen |
Subject: |
[elpa] master 92120d3 3/3: [xpm] Make ‘flower’ size customizable. |
Date: |
Sat, 4 Feb 2017 16:29:26 +0000 (UTC) |
branch: master
commit 92120d30899e5cac795b485ede2705feb6d7aa70
Author: Thien-Thi Nguyen <address@hidden>
Commit: Thien-Thi Nguyen <address@hidden>
[xpm] Make ‘flower’ size customizable.
* packages/xpm/flower.el (flower-size): New defvar.
(flower): Don't hardcode 99 as flower size; instead, consult
‘flower-size’; also, adjust max magnitude appropriately.
---
packages/xpm/flower.el | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/packages/xpm/flower.el b/packages/xpm/flower.el
index 9738b31..35c0005 100644
--- a/packages/xpm/flower.el
+++ b/packages/xpm/flower.el
@@ -32,20 +32,24 @@
(require 'xpm-m2z)
(require 'cl-lib)
+(defvar flower-size 99
+ "Number of pixels in the flower image (a square).
+For best results, this should be at least 99 and odd.")
+
(defun flower (&optional again)
"Stress `xpm-raster' in various ways."
(interactive "P")
(let ((buf (get-buffer "flower")))
(when buf (kill-buffer buf)))
(switch-to-buffer
- (xpm-generate-buffer "flower" 99 99 2
+ (xpm-generate-buffer "flower" flower-size flower-size 2
'((" " . "green")
(".." . "yellow")
("OO" . "red")
("--" . "black"))))
(setq truncate-lines t)
(let* ((τ (* 4 2 (atan 1)))
- (half (/ 99 2.0))
+ (half (/ flower-size 2.0))
(mag-fns (vector (lambda (θ) (ignore θ) 1)
(lambda (θ) (sin θ))
(lambda (θ) (cos θ))
@@ -69,11 +73,13 @@
(two (form 'xpm-m2z-ellipse (random 42))))
(append one two))
(cl-loop
+ with bias = (* 0.42 half)
+ with mm = (+ bias (random (truncate bias)))
for θ below τ by 0.003
collect
(cl-flet
((at (f mfn)
- (truncate (+ half (* 42 (funcall mfn θ)
+ (truncate (+ half (* mm (funcall mfn θ)
(funcall f θ))))))
(cons (at 'cos x-mag-fn)
(at 'sin y-mag-fn)))))))))