Merge pull request #10 from phoe-trash/master
[vecto.git] / utils.lisp
blob0dc4f94333e32c95bd7fc36d46436e7ef529852f
1 ;;; Copyright (c) 2007 Zachary Beane, All Rights Reserved
2 ;;;
3 ;;; Redistribution and use in source and binary forms, with or without
4 ;;; modification, are permitted provided that the following conditions
5 ;;; are met:
6 ;;;
7 ;;; * Redistributions of source code must retain the above copyright
8 ;;; notice, this list of conditions and the following disclaimer.
9 ;;;
10 ;;; * Redistributions in binary form must reproduce the above
11 ;;; copyright notice, this list of conditions and the following
12 ;;; disclaimer in the documentation and/or other materials
13 ;;; provided with the distribution.
14 ;;;
15 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
16 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ;;;
27 ;;; $Id: utils.lisp,v 1.3 2007/09/20 17:41:21 xach Exp $
29 (in-package #:vecto)
31 (defun clamp-range (low value high)
32 (min (max value low) high))
34 (defun float-octet (float)
35 "Convert a float in the range 0.0 - 1.0 to an octet."
36 (values (round (* float 255.0))))
38 (defun octet-float (octet)
39 "Convert an octet to a float."
40 (/ octet 255.0))
42 ;; hyperdoc definitions
43 (defvar *hyperdoc-base-uri* "http://www.xach.com/lisp/vecto/")
45 (let ((exported-symbols-alist
46 (loop for symbol being the external-symbols of :vecto
47 collect (cons symbol
48 (concatenate 'string
49 "#"
50 (string-downcase symbol))))))
51 (defun hyperdoc-lookup (symbol type)
52 (declare (ignore type))
53 (cdr (assoc symbol
54 exported-symbols-alist
55 :test #'eq))))