diff --git a/collects/2htdp/planetcute.rkt b/collects/2htdp/planetcute.rkt new file mode 100644 index 0000000000..6a8022e7f4 --- /dev/null +++ b/collects/2htdp/planetcute.rkt @@ -0,0 +1,14 @@ +#lang racket/base +(require 2htdp/image + (for-syntax "private/planetcute-image-list.rkt") + (for-syntax racket/base)) + +(define-syntax (definitions stx) + #`(begin + #,@(for/list ([img (in-list images)]) + (define req (string->symbol (format "2htdp/planetcute/~a" (name->filename img)))) + #`(begin + (provide #,img) + (define #,img (bitmap #,req)))))) + +(definitions) diff --git a/collects/2htdp/planetcute/Brown Block.png b/collects/2htdp/planetcute/Brown Block.png new file mode 100644 index 0000000000..75c5e1ff50 Binary files /dev/null and b/collects/2htdp/planetcute/Brown Block.png differ diff --git a/collects/2htdp/planetcute/Character Boy.png b/collects/2htdp/planetcute/Character Boy.png new file mode 100644 index 0000000000..3dc7c298f3 Binary files /dev/null and b/collects/2htdp/planetcute/Character Boy.png differ diff --git a/collects/2htdp/planetcute/Character Cat Girl.png b/collects/2htdp/planetcute/Character Cat Girl.png new file mode 100644 index 0000000000..dc0538b131 Binary files /dev/null and b/collects/2htdp/planetcute/Character Cat Girl.png differ diff --git a/collects/2htdp/planetcute/Character Horn Girl.png b/collects/2htdp/planetcute/Character Horn Girl.png new file mode 100644 index 0000000000..90f22784ca Binary files /dev/null and b/collects/2htdp/planetcute/Character Horn Girl.png differ diff --git a/collects/2htdp/planetcute/Character Pink Girl.png b/collects/2htdp/planetcute/Character Pink Girl.png new file mode 100644 index 0000000000..baef1772a4 Binary files /dev/null and b/collects/2htdp/planetcute/Character Pink Girl.png differ diff --git a/collects/2htdp/planetcute/Character Princess Girl.png b/collects/2htdp/planetcute/Character Princess Girl.png new file mode 100644 index 0000000000..9d9f958c43 Binary files /dev/null and b/collects/2htdp/planetcute/Character Princess Girl.png differ diff --git a/collects/2htdp/planetcute/Chest Closed.png b/collects/2htdp/planetcute/Chest Closed.png new file mode 100644 index 0000000000..78b716bb54 Binary files /dev/null and b/collects/2htdp/planetcute/Chest Closed.png differ diff --git a/collects/2htdp/planetcute/Chest Lid.png b/collects/2htdp/planetcute/Chest Lid.png new file mode 100644 index 0000000000..bb79dfb762 Binary files /dev/null and b/collects/2htdp/planetcute/Chest Lid.png differ diff --git a/collects/2htdp/planetcute/Chest Open.png b/collects/2htdp/planetcute/Chest Open.png new file mode 100644 index 0000000000..65073fe2fd Binary files /dev/null and b/collects/2htdp/planetcute/Chest Open.png differ diff --git a/collects/2htdp/planetcute/Dirt Block.png b/collects/2htdp/planetcute/Dirt Block.png new file mode 100644 index 0000000000..bd85e94e5f Binary files /dev/null and b/collects/2htdp/planetcute/Dirt Block.png differ diff --git a/collects/2htdp/planetcute/Door Tall Closed.png b/collects/2htdp/planetcute/Door Tall Closed.png new file mode 100644 index 0000000000..57e8e56e29 Binary files /dev/null and b/collects/2htdp/planetcute/Door Tall Closed.png differ diff --git a/collects/2htdp/planetcute/Door Tall Open.png b/collects/2htdp/planetcute/Door Tall Open.png new file mode 100644 index 0000000000..4dbcf37674 Binary files /dev/null and b/collects/2htdp/planetcute/Door Tall Open.png differ diff --git a/collects/2htdp/planetcute/Enemy Bug.png b/collects/2htdp/planetcute/Enemy Bug.png new file mode 100644 index 0000000000..191587b4fa Binary files /dev/null and b/collects/2htdp/planetcute/Enemy Bug.png differ diff --git a/collects/2htdp/planetcute/Gem Blue.png b/collects/2htdp/planetcute/Gem Blue.png new file mode 100644 index 0000000000..5808a7def6 Binary files /dev/null and b/collects/2htdp/planetcute/Gem Blue.png differ diff --git a/collects/2htdp/planetcute/Gem Green.png b/collects/2htdp/planetcute/Gem Green.png new file mode 100644 index 0000000000..e971d14d79 Binary files /dev/null and b/collects/2htdp/planetcute/Gem Green.png differ diff --git a/collects/2htdp/planetcute/Gem Orange.png b/collects/2htdp/planetcute/Gem Orange.png new file mode 100644 index 0000000000..f8faf7b5a6 Binary files /dev/null and b/collects/2htdp/planetcute/Gem Orange.png differ diff --git a/collects/2htdp/planetcute/Grass Block.png b/collects/2htdp/planetcute/Grass Block.png new file mode 100644 index 0000000000..eb04ba9069 Binary files /dev/null and b/collects/2htdp/planetcute/Grass Block.png differ diff --git a/collects/2htdp/planetcute/Heart.png b/collects/2htdp/planetcute/Heart.png new file mode 100644 index 0000000000..aa49b5c36b Binary files /dev/null and b/collects/2htdp/planetcute/Heart.png differ diff --git a/collects/2htdp/planetcute/Key.png b/collects/2htdp/planetcute/Key.png new file mode 100644 index 0000000000..7602326ab2 Binary files /dev/null and b/collects/2htdp/planetcute/Key.png differ diff --git a/collects/2htdp/planetcute/Plain Block.png b/collects/2htdp/planetcute/Plain Block.png new file mode 100644 index 0000000000..9e9c65f51f Binary files /dev/null and b/collects/2htdp/planetcute/Plain Block.png differ diff --git a/collects/2htdp/planetcute/Ramp East.png b/collects/2htdp/planetcute/Ramp East.png new file mode 100644 index 0000000000..927f09e782 Binary files /dev/null and b/collects/2htdp/planetcute/Ramp East.png differ diff --git a/collects/2htdp/planetcute/Ramp North.png b/collects/2htdp/planetcute/Ramp North.png new file mode 100644 index 0000000000..c9678ba6cb Binary files /dev/null and b/collects/2htdp/planetcute/Ramp North.png differ diff --git a/collects/2htdp/planetcute/Ramp South.png b/collects/2htdp/planetcute/Ramp South.png new file mode 100644 index 0000000000..bde7360cb2 Binary files /dev/null and b/collects/2htdp/planetcute/Ramp South.png differ diff --git a/collects/2htdp/planetcute/Ramp West.png b/collects/2htdp/planetcute/Ramp West.png new file mode 100644 index 0000000000..1554c8d136 Binary files /dev/null and b/collects/2htdp/planetcute/Ramp West.png differ diff --git a/collects/2htdp/planetcute/Rock.png b/collects/2htdp/planetcute/Rock.png new file mode 100644 index 0000000000..29c4e2000e Binary files /dev/null and b/collects/2htdp/planetcute/Rock.png differ diff --git a/collects/2htdp/planetcute/Roof East.png b/collects/2htdp/planetcute/Roof East.png new file mode 100644 index 0000000000..3c3b7569ea Binary files /dev/null and b/collects/2htdp/planetcute/Roof East.png differ diff --git a/collects/2htdp/planetcute/Roof North East.png b/collects/2htdp/planetcute/Roof North East.png new file mode 100644 index 0000000000..f81f9bc6e0 Binary files /dev/null and b/collects/2htdp/planetcute/Roof North East.png differ diff --git a/collects/2htdp/planetcute/Roof North West.png b/collects/2htdp/planetcute/Roof North West.png new file mode 100644 index 0000000000..16ab3fd7b1 Binary files /dev/null and b/collects/2htdp/planetcute/Roof North West.png differ diff --git a/collects/2htdp/planetcute/Roof North.png b/collects/2htdp/planetcute/Roof North.png new file mode 100644 index 0000000000..a0f68cf9e0 Binary files /dev/null and b/collects/2htdp/planetcute/Roof North.png differ diff --git a/collects/2htdp/planetcute/Roof South East.png b/collects/2htdp/planetcute/Roof South East.png new file mode 100644 index 0000000000..f875039aed Binary files /dev/null and b/collects/2htdp/planetcute/Roof South East.png differ diff --git a/collects/2htdp/planetcute/Roof South West.png b/collects/2htdp/planetcute/Roof South West.png new file mode 100644 index 0000000000..636c0ccf66 Binary files /dev/null and b/collects/2htdp/planetcute/Roof South West.png differ diff --git a/collects/2htdp/planetcute/Roof South.png b/collects/2htdp/planetcute/Roof South.png new file mode 100644 index 0000000000..dda41b4d38 Binary files /dev/null and b/collects/2htdp/planetcute/Roof South.png differ diff --git a/collects/2htdp/planetcute/Roof West.png b/collects/2htdp/planetcute/Roof West.png new file mode 100644 index 0000000000..c7d92774e3 Binary files /dev/null and b/collects/2htdp/planetcute/Roof West.png differ diff --git a/collects/2htdp/planetcute/Selector.png b/collects/2htdp/planetcute/Selector.png new file mode 100644 index 0000000000..e7c5475a6e Binary files /dev/null and b/collects/2htdp/planetcute/Selector.png differ diff --git a/collects/2htdp/planetcute/Shadow East.png b/collects/2htdp/planetcute/Shadow East.png new file mode 100644 index 0000000000..e2fbadc5de Binary files /dev/null and b/collects/2htdp/planetcute/Shadow East.png differ diff --git a/collects/2htdp/planetcute/Shadow North East.png b/collects/2htdp/planetcute/Shadow North East.png new file mode 100644 index 0000000000..015a8cff3e Binary files /dev/null and b/collects/2htdp/planetcute/Shadow North East.png differ diff --git a/collects/2htdp/planetcute/Shadow North West.png b/collects/2htdp/planetcute/Shadow North West.png new file mode 100644 index 0000000000..d4ad7b79e8 Binary files /dev/null and b/collects/2htdp/planetcute/Shadow North West.png differ diff --git a/collects/2htdp/planetcute/Shadow North.png b/collects/2htdp/planetcute/Shadow North.png new file mode 100644 index 0000000000..eb35321562 Binary files /dev/null and b/collects/2htdp/planetcute/Shadow North.png differ diff --git a/collects/2htdp/planetcute/Shadow Side West.png b/collects/2htdp/planetcute/Shadow Side West.png new file mode 100644 index 0000000000..9c02903965 Binary files /dev/null and b/collects/2htdp/planetcute/Shadow Side West.png differ diff --git a/collects/2htdp/planetcute/Shadow South East.png b/collects/2htdp/planetcute/Shadow South East.png new file mode 100644 index 0000000000..7bde7f3abb Binary files /dev/null and b/collects/2htdp/planetcute/Shadow South East.png differ diff --git a/collects/2htdp/planetcute/Shadow South West.png b/collects/2htdp/planetcute/Shadow South West.png new file mode 100644 index 0000000000..ee845db9c1 Binary files /dev/null and b/collects/2htdp/planetcute/Shadow South West.png differ diff --git a/collects/2htdp/planetcute/Shadow South.png b/collects/2htdp/planetcute/Shadow South.png new file mode 100644 index 0000000000..0a122b9f84 Binary files /dev/null and b/collects/2htdp/planetcute/Shadow South.png differ diff --git a/collects/2htdp/planetcute/Shadow West.png b/collects/2htdp/planetcute/Shadow West.png new file mode 100644 index 0000000000..6203d90545 Binary files /dev/null and b/collects/2htdp/planetcute/Shadow West.png differ diff --git a/collects/2htdp/planetcute/SpeechBubble.png b/collects/2htdp/planetcute/SpeechBubble.png new file mode 100644 index 0000000000..7e03049840 Binary files /dev/null and b/collects/2htdp/planetcute/SpeechBubble.png differ diff --git a/collects/2htdp/planetcute/Star.png b/collects/2htdp/planetcute/Star.png new file mode 100644 index 0000000000..17c0af58a7 Binary files /dev/null and b/collects/2htdp/planetcute/Star.png differ diff --git a/collects/2htdp/planetcute/Stone Block Tall.png b/collects/2htdp/planetcute/Stone Block Tall.png new file mode 100644 index 0000000000..cc3ce6ac9a Binary files /dev/null and b/collects/2htdp/planetcute/Stone Block Tall.png differ diff --git a/collects/2htdp/planetcute/Stone Block.png b/collects/2htdp/planetcute/Stone Block.png new file mode 100644 index 0000000000..01113cffa8 Binary files /dev/null and b/collects/2htdp/planetcute/Stone Block.png differ diff --git a/collects/2htdp/planetcute/Tree Short.png b/collects/2htdp/planetcute/Tree Short.png new file mode 100644 index 0000000000..28a15d058c Binary files /dev/null and b/collects/2htdp/planetcute/Tree Short.png differ diff --git a/collects/2htdp/planetcute/Tree Tall.png b/collects/2htdp/planetcute/Tree Tall.png new file mode 100644 index 0000000000..1ae3581ec9 Binary files /dev/null and b/collects/2htdp/planetcute/Tree Tall.png differ diff --git a/collects/2htdp/planetcute/Tree Ugly.png b/collects/2htdp/planetcute/Tree Ugly.png new file mode 100644 index 0000000000..957dca61ee Binary files /dev/null and b/collects/2htdp/planetcute/Tree Ugly.png differ diff --git a/collects/2htdp/planetcute/Wall Block Tall.png b/collects/2htdp/planetcute/Wall Block Tall.png new file mode 100644 index 0000000000..08d85d928a Binary files /dev/null and b/collects/2htdp/planetcute/Wall Block Tall.png differ diff --git a/collects/2htdp/planetcute/Wall Block.png b/collects/2htdp/planetcute/Wall Block.png new file mode 100644 index 0000000000..9cad766568 Binary files /dev/null and b/collects/2htdp/planetcute/Wall Block.png differ diff --git a/collects/2htdp/planetcute/Water Block.png b/collects/2htdp/planetcute/Water Block.png new file mode 100644 index 0000000000..0383ed8143 Binary files /dev/null and b/collects/2htdp/planetcute/Water Block.png differ diff --git a/collects/2htdp/planetcute/Window Tall.png b/collects/2htdp/planetcute/Window Tall.png new file mode 100644 index 0000000000..ca1af59dd1 Binary files /dev/null and b/collects/2htdp/planetcute/Window Tall.png differ diff --git a/collects/2htdp/planetcute/Wood Block.png b/collects/2htdp/planetcute/Wood Block.png new file mode 100644 index 0000000000..0705007f2e Binary files /dev/null and b/collects/2htdp/planetcute/Wood Block.png differ diff --git a/collects/2htdp/private/planetcute-image-list.rkt b/collects/2htdp/private/planetcute-image-list.rkt new file mode 100644 index 0000000000..50fb3c2c76 --- /dev/null +++ b/collects/2htdp/private/planetcute-image-list.rkt @@ -0,0 +1,67 @@ +#lang racket/base +(provide images name->filename) + +(define (name->filename img) + (define-values (_ new-chars) + (for/fold ([cap-next? #t] + [chars '()]) + ([c (in-string (format "~a" img))]) + (values (equal? #\- c) + (cons (cond + [(equal? c #\-) #\space] + [cap-next? (char-upcase c)] + [else c]) + chars)))) + (format "~a.png" (apply string (reverse new-chars)))) + +(define images + '(brown-block + character-boy + character-cat-girl + character-horn-girl + character-pink-girl + character-princess-girl + chest-closed + chest-lid + chest-open + dirt-block + door-tall-closed + door-tall-open + enemy-bug + gem-blue + gem-green + gem-orange + grass-block + heart + key + plain-block + ramp-north + ramp-south + ramp-west + roof-east + roof-north-east + roof-north-west + roof-north + roof-south-east + roof-south-west + roof-south + roof-west + shadow-east + shadow-north-east + shadow-north-west + shadow-north + shadow-side-west + shadow-south-east + shadow-south-west + shadow-south + shadow-west + stone-block-tall + stone-block + tree-short + tree-tall + tree-ugly + wall-block-tall + wall-block + water-block + window-tall + wood-block)) \ No newline at end of file diff --git a/collects/teachpack/2htdp/scribblings/2htdp.scrbl b/collects/teachpack/2htdp/scribblings/2htdp.scrbl index 3f8b0f55cc..20b1bf20f9 100644 --- a/collects/teachpack/2htdp/scribblings/2htdp.scrbl +++ b/collects/teachpack/2htdp/scribblings/2htdp.scrbl @@ -11,3 +11,4 @@ @include-section["image.scrbl"] @include-section["universe.scrbl"] @include-section["port.scrbl"] +@include-section["planetcute.scrbl"] diff --git a/collects/teachpack/2htdp/scribblings/image.scrbl b/collects/teachpack/2htdp/scribblings/image.scrbl index b097d69390..95ca2a8f4f 100644 --- a/collects/teachpack/2htdp/scribblings/image.scrbl +++ b/collects/teachpack/2htdp/scribblings/image.scrbl @@ -1224,6 +1224,8 @@ are represented as bitmaps, i.e., an array of colors (that can be quite large in This means that scaling and rotating them loses fidelity in the image and is significantly more expensive than with the other shapes. +See also the @racketmodname[2htdp/planetcute] library. + @defform/subs[(bitmap bitmap-spec) ([bitmap-spec rel-string id])]{ diff --git a/collects/teachpack/2htdp/scribblings/planetcute.scrbl b/collects/teachpack/2htdp/scribblings/planetcute.scrbl new file mode 100644 index 0000000000..3cce53d844 --- /dev/null +++ b/collects/teachpack/2htdp/scribblings/planetcute.scrbl @@ -0,0 +1,60 @@ +#lang scribble/doc + +@(require "shared.rkt" + "port.rkt" + scribble/manual + scribble/eval + (for-syntax racket/base) + 2htdp/image + (for-label 2htdp/image + 2htdp/planetcute)) + +@; ----------------------------------------------------------------------------- + +@title{Planet Cute Images} + +@defmodule[2htdp/planetcute] + +@(define pc-eval (make-base-eval)) +@(interaction-eval #:eval pc-eval (require 2htdp/image)) +@(interaction-eval #:eval pc-eval (require 2htdp/planetcute)) + +The @racketmodname[2htdp/planetcute] library contains the +Planet Cute images: +@url{http://www.lostgarden.com/2007/05/dancs-miraculously-flexible-game.html}. + +The images are designed to be overlaid with each other to build +scenes for use in games. Here is an example image taken +from the Planet Cute website. + +@racketblock+eval[#:eval + pc-eval + (define (stack arg . args) + (cond + [(null? args) arg] + [else (overlay/xy arg 0 40 + (apply stack args))]))] +@interaction[#:eval + pc-eval + (scale + 1 + (beside/align + "bottom" + (stack wall-block-tall stone-block) + (stack character-cat-girl + stone-block stone-block + stone-block stone-block) + water-block + (stack grass-block dirt-block) + (stack grass-block dirt-block dirt-block)))] + +@(close-eval pc-eval) + +@(require (for-syntax 2htdp/private/planetcute-image-list)) +@(define-syntax (defthings stx) + #`(begin + #,@(for/list ([img (in-list images)]) + (define req (string->symbol (format "2htdp/planetcute/~a" (name->filename img)))) + #`@defthing[#,img image?]{ @(bitmap #,req) }))) + +@defthings[]