rearranged things so that 2htdp/image has its core snip stuff loaded into drscheme so that saving files with 2htdp/image images in them works

svn: r16317
This commit is contained in:
Robby Findler 2009-10-13 23:06:24 +00:00
parent a2ccd6147e
commit 11e87632dc
7 changed files with 66 additions and 48 deletions

View File

@ -1,5 +1,51 @@
#lang scheme/base #lang scheme/base
(require "private/image-core.ss"
#|
Need to test copy & paste. Also test that if the "if"
expression in image-snipclass%'s read
method returns #f, then you get a black circle out.
---
improvments/changes wrt to htdp/image:
- copying and pasting does not introduce jaggies
- equal comparisions are more efficient
- added rotation & scaling
- got rid of pinholes (see the new overlay, beside, and above functions)
Equality change: equality is now based on the structure of the construction of the picture.
This means that some equalities that were there before are no longer true. For example,
in the old library, these two images are the same:
(overlay/xy (rectangle 100 10 'solid 'red)
0
10
(rectangle 100 10 'solid 'red))
(rectangle 100 20 'solid 'red)
... and why aren't they the same again....?!
todo: sort out wxme library support (loading in text mode).
------------
From Matthias: (to use to compare with this library)
You asked about exercises and code snippets for HtDP/2e yesterday. I actually do have a bunch of stuff in
svn: 2HtDP/SampleCode/
and they all have good sample contracts. (It is amazing what we can do with kids who have just a few weeks of cs down; I would have never dared to write an editor after six weeks in Algol.)
|#
(require mrlib/image-core
"private/image-more.ss") "private/image-more.ss")
(provide overlay (provide overlay
@ -14,6 +60,9 @@
rotate rotate
frame frame
scale
scale/xy
ellipse ellipse
rectangle rectangle

View File

@ -1,6 +1,6 @@
#lang scheme/base #lang scheme/base
(require "image-core.ss" (require mrlib/image-core
scheme/class scheme/class
scheme/gui/base scheme/gui/base
htdp/error htdp/error

View File

@ -11,8 +11,7 @@
;; to ensure this guy is loaded (and the snipclass installed) in the drscheme namespace & eventspace ;; to ensure this guy is loaded (and the snipclass installed) in the drscheme namespace & eventspace
;; these things are for effect only! ;; these things are for effect only!
(require mrlib/cache-image-snip (require mrlib/cache-image-snip
#; (prefix image-core: mrlib/image-core))
(prefix foo htdp/matrix))
(define op (current-output-port)) (define op (current-output-port))
(define (oprintf . args) (apply fprintf op args)) (define (oprintf . args) (apply fprintf op args))
@ -184,6 +183,7 @@
'(lib "mzlib/foreign.ss") '(lib "mzlib/foreign.ss")
'(lib "mred/mred.ss") '(lib "mred/mred.ss")
'(lib "mrlib/cache-image-snip.ss") '(lib "mrlib/cache-image-snip.ss")
'(lib "mrlib/image-core.ss")
'(lib "mrlib/matrix-snip.ss") '(lib "mrlib/matrix-snip.ss")
'(lib "mzlib/pconvert-prop.ss") '(lib "mzlib/pconvert-prop.ss")
'(lib "planet/terse-info.ss"))) '(lib "planet/terse-info.ss")))

View File

@ -24,6 +24,7 @@ module browser threading seems wrong.
mrlib/include-bitmap mrlib/include-bitmap
mrlib/switchable-button mrlib/switchable-button
mrlib/cache-image-snip mrlib/cache-image-snip
(prefix-in image-core: mrlib/image-core)
mrlib/include-bitmap mrlib/include-bitmap
mrlib/close-icon mrlib/close-icon
net/sendurl net/sendurl
@ -166,6 +167,7 @@ module browser threading seems wrong.
(send text split-snip (+ pos 1)) (send text split-snip (+ pos 1))
(let ([snip (send text find-snip pos 'after-or-none)]) (let ([snip (send text find-snip pos 'after-or-none)])
(when (or (is-a? snip image-snip%) (when (or (is-a? snip image-snip%)
(is-a? snip image-core:image%)
(is-a? snip cache-image-snip%)) (is-a? snip cache-image-snip%))
(add-sep) (add-sep)
(new menu-item% (new menu-item%

View File

@ -2,57 +2,24 @@
#| #|
Need to test copy & paste. Also test that if the "if" This library is the part of the 2htdp/image
expression in image-snipclass%'s read teachpack that has to be shared between drscheme
method returns #f, then you get a black circle out. and the user's program to make copy and paste
work right.
---
improvments/changes wrt to htdp/image:
- copying and pasting does not introduce jaggies
- equal comparisions are more efficient
- added rotation & scaling
- got rid of pinholes (see the new overlay, beside, and above functions)
Equality change: equality is now based on the structure of the construction of the picture.
This means that some equalities that were there before are no longer true. For example,
in the old library, these two images are the same:
(overlay/xy (rectangle 100 10 'solid 'red)
0
10
(rectangle 100 10 'solid 'red))
(rectangle 100 20 'solid 'red)
... and why aren't they the same again....?!
todo: sort out wxme library support (loading in text mode).
------------
From Matthias: (to use to compare with this library)
You asked about exercises and code snippets for HtDP/2e yesterday. I actually do have a bunch of stuff in
svn: 2HtDP/SampleCode/
and they all have good sample contracts. (It is amazing what we can do with kids who have just a few weeks of cs down; I would have never dared to write an editor after six weeks in Algol.)
Most of the exports are jsut for use in 2htdp/image
(technically, 2htdp/private/image-more). The main
use of this library is the snip class addition it
does (and any code that that does not depend on
has been moved out).
|# |#
(require scheme/class (require scheme/class
scheme/gui/base scheme/gui/base
scheme/math scheme/math
(for-syntax scheme/base)) (for-syntax scheme/base))
(define-for-syntax id-constructor-pairs '()) (define-for-syntax id-constructor-pairs '())
(define-for-syntax (add-id-constructor-pair a b) (define-for-syntax (add-id-constructor-pair a b)
(set! id-constructor-pairs (cons (list a b) id-constructor-pairs))) (set! id-constructor-pairs (cons (list a b) id-constructor-pairs)))

View File

@ -71,7 +71,7 @@ Existing images can be rotated, scaled, and overlaid on top of each other.
@defproc[(scale [factor real?] [image image?]) image?]{ @defproc[(scale [factor real?] [image image?]) image?]{
Scales @scheme[image] by @scheme[factor]. For example, Scales @scheme[image] by @scheme[factor]. For example,
scaling @scheme[(ellipse 40 60 "solid" "blue")] produces scaling @scheme[(ellipse 40 60 "solid" "blue")] by @scheme[2] produces
@scheme[(ellipse 80 120 "solid" "blue")]. @scheme[(ellipse 80 120 "solid" "blue")].
} }

View File

@ -1,5 +1,5 @@
#lang scheme/base #lang scheme/base
(require "../../2htdp/private/image-core.ss" (require "../../mrlib/image-core.ss"
"../../2htdp/private/image-more.ss" "../../2htdp/private/image-more.ss"
scheme/math scheme/math
scheme/class scheme/class