From d91d4b3d74f56b62903a26f1c7f09ef558820446 Mon Sep 17 00:00:00 2001 From: frese Date: Mon, 16 Jul 2001 13:08:08 +0000 Subject: [PATCH] fixed make-color bug. added comments. --- scheme/xlib/color.scm | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/scheme/xlib/color.scm b/scheme/xlib/color.scm index 720a3c6..cc4c91f 100644 --- a/scheme/xlib/color.scm +++ b/scheme/xlib/color.scm @@ -1,18 +1,27 @@ ;; Author: David Frese -;; r,g,b should be values between 0.0 to 1.0 inclusive. +;; make-color creates a color with the given r,g,b values, which should be +;; values between 0.0 to 1.0 inclusive. + +(define (my-floor v) + (if (exact? v) + (floor v) + (my-floor (inexact->exact v)))) (define (make-color r g b) - (create-color (floor (* r 65535)) - (floor (* g 65535)) - (floor (* b 65535)))) + (create-color (my-floor (* r 65535)) + (my-floor (* g 65535)) + (my-floor (* b 65535)))) + +;; color-rgb-values returns a list of the rgb-values (see make-color). (define (color-rgb-values color) (map (lambda (x) (/ x 65535)) ;; exact<->inexact? (extract-rgb-values color))) -;; ... +;; query-color returns the color of the given pixel in the given colormap. +;; See XQueryColor. (define (query-color colormap pixel) (apply create-color @@ -23,7 +32,8 @@ (import-lambda-definition %query-color (Xcolormap Xpixel Xdisplay) "Query_Color") -;; ... +;; query-colors does the same as query-color but on vectors of pixels and +;; colors. See XQueryColors. (define (query-colors colormap pixels) (let ((res (%query-colors (colormap-Xcolormap colormap) @@ -35,7 +45,10 @@ (import-lambda-definition %query-colors (Xcolormap Xpixels Xdisplay) "Query_Colors") -;; ... +;; lookup-color takes the name of a color (a string or symbol) looks it up in +;; the colormap and returns a pair of colors: the exact color and the closest +;; color provided by the screen associated to the colormap. If the color-name +;; can't be found an error is raised. See XLookupColor. (define (lookup-color colormap color-name) (let ((r (%lookup-color (colormap-Xcolormap colormap)