1 ;;; flower.el --- can `xpm-raster' DTRT? -*- lexical-binding: t -*-
3 ;; Copyright (C) 2014 Free Software Foundation, Inc.
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, either version 3 of the License, or
8 ;; (at your option) any later version.
10 ;; This program is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ;; This file helps visualize `xpm-raster' failure modes. Maybe one
21 ;; day it will be rendered useless by improvements to `xpm-raster'.
23 ;; NB: There is no `provide' form.
24 ;; NB: Loading munges the global keymap -- YHBW!
32 (defun flower (&optional again)
33 "Stress `xpm-raster' in various ways."
35 (let ((buf (get-buffer "flower")))
36 (when buf (kill-buffer buf)))
38 (xpm-generate-buffer "flower" 99 99 2
43 (setq truncate-lines t)
44 (let* ((τ (* 4 2 (atan 1)))
46 (mag-fns (vector (lambda (θ) (ignore θ) 1)
49 (lambda (θ) (sin (* 0.5 τ θ)))
50 (lambda (θ) (cos (* 0.5 τ θ)))
51 (lambda (θ) (sin (* 0.25 τ θ)))
52 (lambda (θ) (cos (* 0.25 τ θ)))
53 (lambda (θ) (sin (* τ θ)))
54 (lambda (θ) (cos (* τ θ)))))
55 (n-mag-fns (length mag-fns)))
57 ((random-mag-fn () (aref mag-fns (random n-mag-fns)))
58 (form (fn &rest args) (apply fn half half (random 42) args)))
59 (let* ((x-mag-fn (random-mag-fn))
60 (y-mag-fn (random-mag-fn))
64 (if (zerop (random 5))
65 (let ((one (form 'xpm-m2z-circle))
66 (two (form 'xpm-m2z-ellipse (random 42))))
69 for θ below τ by 0.003
73 (truncate (+ half (* 42 (funcall mfn θ)
75 (cons (at 'cos x-mag-fn)
76 (at 'sin y-mag-fn)))))))))
77 (put 'flower 'form form)
78 (xpm-raster form "OO" ".."))))
80 ;; strangely, image-mode screws up the markers, so we need to do
81 ;; this again if we want to do subsequent xpm-* access:
85 ;;;---------------------------------------------------------------------------
88 (global-set-key [f9] 'flower)
91 (lambda () (interactive)
92 (message "xpm-raster-inhibit-continuity-optimization now %s"
93 (setq xpm-raster-inhibit-continuity-optimization
94 (not xpm-raster-inhibit-continuity-optimization)))))
96 ;;; flower.el ends here