source: release/1.3/source/examples/cocoa/easygui/rgb.lisp @ 11842

Last change on this file since 11842 was 11842, checked in by cater, 11 years ago

RGB functions for EASYGUI

File size: 1.4 KB
Line 
1(in-package :easygui)
2
3; --------------------------------------------------------------------------------
4; This provides for Clozure CL some RGB functions to match Allegro CL.
5; Contributed by AWSC (arthur.cater@ucd.ie) March 2009.
6; Permission to disseminate, use and modify is granted.
7; --------------------------------------------------------------------------------
8
9(defun make-rgb (&key (red 0) (green 0) (blue 0) (opacity 1.0))
10  (assert (typep red     '(integer 0 255)) (red)
11          "Value of RED component for make-rgb must be an integer 0-255 inclusive")
12  (assert (typep green   '(integer 0 255)) (green)
13          "Value of GREEN component for make-rgb must be an integer 0-255 inclusive")
14  (assert (typep blue    '(integer 0 255)) (blue)
15          "Value of BLUE component for make-rgb must be an integer 0-255 inclusive")
16  (assert (typep opacity '(single-float 0.0 1.0)) (opacity)
17          "Value of OPACITY component for make-rgb must be a single-float 0.0-1.0 inclusive")
18  (#/retain
19   (#/colorWithCalibratedRed:green:blue:alpha:
20    ns:ns-color
21    (/ red 255.0)
22    (/ green 255.0)
23    (/ blue 255.0)
24    opacity)))
25
26(defun rgb-red (color)   (round (* 255 (#/redComponent color))))
27
28(defun rgb-green (color) (round (* 255 (#/greenComponent color))))
29
30(defun rgb-blue (color)  (round (* 255 (#/blueComponent color))))
31
32(defun rgb-opacity (color)  (#/alphaComponent color))
33
Note: See TracBrowser for help on using the repository browser.