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