take advantage of new equal<%> and snip% setup to make image-snip%s equal to 2htdp/image images (when appropriate)
This commit is contained in:
parent
2f009ca529
commit
e896360dcf
|
@ -1312,6 +1312,12 @@
|
|||
=>
|
||||
(to-img (make-object image-snip% green-blue-20x10-bitmap)))
|
||||
|
||||
;; make sure that raw image snips are equal to image snips
|
||||
(let ([i1 (make-object image-snip% (collection-file-path "bug09.png" "icons"))]
|
||||
[i2 (make-object image-snip% (collection-file-path "bug09.png" "icons"))])
|
||||
(test (equal? (rotate 0 i1) i2) => #t)
|
||||
(test (equal? i1 (rotate 0 i2)) => #t))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; cropping (and place-image)
|
||||
|
|
|
@ -223,9 +223,13 @@ has been moved out).
|
|||
(send bdc set-bitmap #f))))
|
||||
|
||||
(define image%
|
||||
(class* snip% (png-convertible<%> equal<%> image<%>)
|
||||
(class* snip% (png-convertible<%> image<%>)
|
||||
(init-field shape bb normalized? pinhole)
|
||||
(define/public (equal-to? that eq-recur)
|
||||
|
||||
(define/override (equal-to? that eq-recur) (compare-em that eq-recur))
|
||||
(define/override (other-equal-to? that eq-recur) (compare-em that eq-recur))
|
||||
|
||||
(define/private (compare-em that eq-recur)
|
||||
(or (eq? this that)
|
||||
(let ([that
|
||||
(cond
|
||||
|
@ -256,8 +260,11 @@ has been moved out).
|
|||
(render-image obj bdc 0 0)
|
||||
(send bdc get-argb-pixels 0 0 (send bm get-width) (send bm get-height) bytes))
|
||||
|
||||
(define/public (equal-hash-code-of y) 42)
|
||||
(define/public (equal-secondary-hash-code-of y) 3)
|
||||
;; this could render the image into a bitmap and then get the hash code of the bytes
|
||||
;; cannot render the tree into a string and then get the hash code of that string
|
||||
;; b/c that might make equal things have the same code.
|
||||
(define/override (equal-hash-code-of y) 42)
|
||||
(define/override (equal-secondary-hash-code-of y) 3)
|
||||
|
||||
(define/public (get-shape) shape)
|
||||
(define/public (set-shape s) (set! shape s))
|
||||
|
|
Loading…
Reference in New Issue
Block a user