| 1 |
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-GD; Base: 10 -*- |
|---|
| 2 |
;;; $Header: /usr/local/cvsrep/gd/specials.lisp,v 1.29 2007/01/01 23:41:00 edi Exp $ |
|---|
| 3 |
|
|---|
| 4 |
;;; Copyright (c) 2003-2007, Dr. Edmund Weitz. All rights reserved. |
|---|
| 5 |
|
|---|
| 6 |
;;; Redistribution and use in source and binary forms, with or without |
|---|
| 7 |
;;; modification, are permitted provided that the following conditions |
|---|
| 8 |
;;; are met: |
|---|
| 9 |
|
|---|
| 10 |
;;; * Redistributions of source code must retain the above copyright |
|---|
| 11 |
;;; notice, this list of conditions and the following disclaimer. |
|---|
| 12 |
|
|---|
| 13 |
;;; * Redistributions in binary form must reproduce the above |
|---|
| 14 |
;;; copyright notice, this list of conditions and the following |
|---|
| 15 |
;;; disclaimer in the documentation and/or other materials |
|---|
| 16 |
;;; provided with the distribution. |
|---|
| 17 |
|
|---|
| 18 |
;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED |
|---|
| 19 |
;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|---|
| 20 |
;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 21 |
;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
|---|
| 22 |
;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|---|
| 23 |
;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
|---|
| 24 |
;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|---|
| 25 |
;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|---|
| 26 |
;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|---|
| 27 |
;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|---|
| 28 |
;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 29 |
|
|---|
| 30 |
(in-package #:cl-gd) |
|---|
| 31 |
|
|---|
| 32 |
(defvar *default-image* nil |
|---|
| 33 |
"The default image. This special variable is usually bound by |
|---|
| 34 |
WITH-IMAGE or WITH-IMAGE-FROM-FILE.") |
|---|
| 35 |
|
|---|
| 36 |
(defvar *default-color* nil |
|---|
| 37 |
"The default color. This special variable is usually bound by |
|---|
| 38 |
WITH-COLOR.") |
|---|
| 39 |
|
|---|
| 40 |
(defvar *default-font* nil |
|---|
| 41 |
"The default font. This special variable is usually bound by |
|---|
| 42 |
WITH-FONT.") |
|---|
| 43 |
|
|---|
| 44 |
(defstruct (image |
|---|
| 45 |
(:conc-name nil) |
|---|
| 46 |
(:constructor make-image (img)) |
|---|
| 47 |
(:copier nil)) |
|---|
| 48 |
img) |
|---|
| 49 |
|
|---|
| 50 |
(defstruct (brush |
|---|
| 51 |
(:include image) |
|---|
| 52 |
(:constructor %make-brush (img)) |
|---|
| 53 |
(:copier nil))) |
|---|
| 54 |
|
|---|
| 55 |
(defun make-brush (image) |
|---|
| 56 |
(%make-brush (img image))) |
|---|
| 57 |
|
|---|
| 58 |
(defstruct (tile |
|---|
| 59 |
(:include image) |
|---|
| 60 |
(:constructor %make-tile (img)) |
|---|
| 61 |
(:copier nil))) |
|---|
| 62 |
|
|---|
| 63 |
(defun make-tile (image) |
|---|
| 64 |
(%make-tile (img image))) |
|---|
| 65 |
|
|---|
| 66 |
(defstruct (anti-aliased-color |
|---|
| 67 |
(:conc-name nil) |
|---|
| 68 |
(:constructor %make-anti-aliased (color do-not-blend)) |
|---|
| 69 |
(:copier nil)) |
|---|
| 70 |
color do-not-blend) |
|---|
| 71 |
|
|---|
| 72 |
(defun make-anti-aliased (color &optional do-not-blend) |
|---|
| 73 |
(%make-anti-aliased color do-not-blend)) |
|---|
| 74 |
|
|---|
| 75 |
;; the following variable will be initialized in "gd-uffi.lisp" |
|---|
| 76 |
(defvar *null-image* nil |
|---|
| 77 |
"A 'null' image which might be useful for DRAW-FREETYPE-STRING.") |
|---|
| 78 |
|
|---|
| 79 |
(defconstant +max-colors+ 256 |
|---|
| 80 |
"Maximum number of colors for palette-based images.") |
|---|
| 81 |
|
|---|
| 82 |
(defconstant +gd-chord+ 1 |
|---|
| 83 |
"Used internally by GD-FILLED-ARC") |
|---|
| 84 |
(defconstant +gd-no-fill+ 2 |
|---|
| 85 |
"Used internally by GD-FILLED-ARC") |
|---|
| 86 |
(defconstant +gd-edged+ 4 |
|---|
| 87 |
"Used internally by GD-FILLED-ARC") |
|---|
| 88 |
|
|---|
| 89 |
(defconstant +brushed+ -3 |
|---|
| 90 |
"Special 'color' for lines drawn with brush.") |
|---|
| 91 |
(defconstant +styled+ -2 |
|---|
| 92 |
"Special 'color' for styled lines.") |
|---|
| 93 |
(defconstant +styled-brushed+ -4 |
|---|
| 94 |
"Special 'color' for lines drawn with styled brush.") |
|---|
| 95 |
(defconstant +transparent+ -6 |
|---|
| 96 |
"Special 'color' used in GD function 'gdImageSetStyle' for transparent color.") |
|---|
| 97 |
(defconstant +tiled+ -5 |
|---|
| 98 |
"Special fill 'color' used for tiles.") |
|---|
| 99 |
(defconstant +anti-aliased+ -7 |
|---|
| 100 |
"Special 'color' for anti-aliased lines.") |
|---|
| 101 |
|
|---|
| 102 |
(defconstant +gd-ftex-linespace+ 1 |
|---|
| 103 |
"Indicate line-spacing for FreeType library.") |
|---|
| 104 |
|
|---|
| 105 |
(defconstant +gd-cmp-image+ 1 |
|---|
| 106 |
"Images will appear different when displayed.") |
|---|
| 107 |
(defconstant +gd-cmp-num-colors+ 2 |
|---|
| 108 |
"Number of colors in palette differ.") |
|---|
| 109 |
(defconstant +gd-cmp-color+ 4 |
|---|
| 110 |
"Image colors differ.") |
|---|
| 111 |
(defconstant +gd-cmp-size-x+ 8 |
|---|
| 112 |
"Image widths differ.") |
|---|
| 113 |
(defconstant +gd-cmp-size-y+ 16 |
|---|
| 114 |
"Image heights differ.") |
|---|
| 115 |
(defconstant +gd-cmp-transparent+ 32 |
|---|
| 116 |
"Transparent color is different.") |
|---|
| 117 |
(defconstant +gd-cmp-background+ 64 |
|---|
| 118 |
"Background color is different.") |
|---|
| 119 |
(defconstant +gd-cmp-interlace+ 128 |
|---|
| 120 |
"Interlace settings are different.") |
|---|
| 121 |
(defconstant +gd-cmp-true-color+ 256 |
|---|
| 122 |
"One image is a true-color image, the other one is palette-based.") |
|---|
| 123 |
|
|---|
| 124 |
(defvar *shared-library-directories* |
|---|
| 125 |
`(,(namestring (make-pathname :name nil |
|---|
| 126 |
:type nil |
|---|
| 127 |
:version :newest |
|---|
| 128 |
:defaults cl-gd.system:*cl-gd-directory*)) |
|---|
| 129 |
"/usr/local/lib/" |
|---|
| 130 |
"/usr/lib/" |
|---|
| 131 |
"/usr/lib/cl-gd/" |
|---|
| 132 |
"/cygwin/usr/local/lib/" |
|---|
| 133 |
"/cygwin/usr/lib/") |
|---|
| 134 |
"A list of directories where UFFI tries to find cl-gd-glue.so") |
|---|
| 135 |
(defvar *shared-library-types* '("so" "dll" "dylib") |
|---|
| 136 |
"The list of types a shared library can have. Used when looking for |
|---|
| 137 |
cl-gd-glue.so") |
|---|
| 138 |
(defvar *shared-library-drive-letters* '("C" "D" "E" "F" "G") |
|---|
| 139 |
"The list of drive letters \(used by Wintendo) used when looking for |
|---|
| 140 |
cl-gd-glue.dll.") |
|---|
| 141 |
|
|---|
| 142 |
(defvar *gd-supporting-libraries* '("c" "gd" "png" "z" "jpeg" "freetype" "iconv" "m") |
|---|
| 143 |
"The libraries which are needed by cl-gd-glues.so \(and GD |
|---|
| 144 |
itself). Only needed for Python-based Lisps like CMUCL, SBCL, or |
|---|
| 145 |
SCL.") |
|---|
| 146 |
|
|---|
| 147 |
(defconstant +radians-to-degree-factor+ (/ 360 (* 2 pi)) |
|---|
| 148 |
"Factor to convert from radians to degrees.") |
|---|
| 149 |
|
|---|
| 150 |
(defvar *transformers* nil |
|---|
| 151 |
"Stack of currently active transformer objects.") |
|---|
| 152 |
|
|---|
| 153 |
(defconstant +most-positive-unsigned-byte-32+ |
|---|
| 154 |
(1- (expt 2 31)) |
|---|
| 155 |
"Name says it all...") |
|---|
| 156 |
|
|---|
| 157 |
;; stuff for Nikodemus Siivola's HYPERDOC |
|---|
| 158 |
;; see <http://common-lisp.net/project/hyperdoc/> |
|---|
| 159 |
;; and <http://www.cliki.net/hyperdoc> |
|---|
| 160 |
|
|---|
| 161 |
(defvar *hyperdoc-base-uri* "http://weitz.de/cl-gd/") |
|---|
| 162 |
|
|---|
| 163 |
(let ((exported-symbols-alist |
|---|
| 164 |
(loop for symbol being the external-symbols of :cl-gd |
|---|
| 165 |
collect (cons symbol |
|---|
| 166 |
(concatenate 'string |
|---|
| 167 |
"#" |
|---|
| 168 |
(string-downcase symbol)))))) |
|---|
| 169 |
(defun hyperdoc-lookup (symbol type) |
|---|
| 170 |
(declare (ignore type)) |
|---|
| 171 |
(cdr (assoc symbol |
|---|
| 172 |
exported-symbols-alist |
|---|
| 173 |
:test #'eq)))) |
|---|