Created
May 19, 2012 11:02
-
-
Save rosylilly/2730475 to your computer and use it in GitHub Desktop.
schemeでrgb->hex hex->rgb変換
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-module color-convert | |
(export hex->rgb) | |
(export rgb->hex) | |
(export rgb->hls)) | |
(select-module color-convert) | |
(use srfi-13) | |
(define (hex->rgb hex) | |
(map | |
(lambda (h) (string->number h 16)) | |
(map list->string | |
(slices (string->list hex) 2)))) | |
(define (rgb->hex r g b) | |
(string-concatenate | |
(map | |
(lambda (c) (number->string c 16 #t)) | |
'(r g b)))) | |
(provide "color-convert") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
星くんに)は全部くっつけるんだよって言われたから直したよ