Skip to content

Commit

Permalink
fix color-list->bitmap's interpretation of the color argument
Browse files Browse the repository at this point in the history
related to #148
  • Loading branch information
rfindler committed Apr 29, 2021
1 parent 180248d commit 6d89265
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion htdp-lib/2htdp/private/image-more.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@
(bytes-set! bytes (+ j 3) (color-blue c))]
[else
(define str (if (string? c) c (symbol->string c)))
(define clr (or (send the-color-database find-color str)
(define clr (or (string->color-object/f str)
(send the-color-database find-color "black")))
(bytes-set! bytes j 255) ;; this should probably (send clr alpha) when that's possible
(bytes-set! bytes (+ j 1) (send clr red))
Expand Down
9 changes: 9 additions & 0 deletions htdp-test/2htdp/tests/test-image.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -2216,6 +2216,15 @@
(rectangle 1 1 'solid (color 5 5 5))
(rectangle 1 1 'solid (color 6 6 6)))))

(test (equal? (color-list->bitmap (list "MediumGreen") 1 1)
(color-list->bitmap (list "black") 1 1))
=>
#f)
(test (equal? (color-list->bitmap (list "DarkPink") 1 1)
(color-list->bitmap (list "black") 1 1))
=>
#f)

(test (color-list->bitmap '() 0 0) => (empty-scene 0 0))
(test (color-list->bitmap '() 0 10) => (empty-scene 0 10))
(test (color-list->bitmap '() 4 0) => (empty-scene 4 0))
Expand Down

0 comments on commit 6d89265

Please sign in to comment.