Changeset 27048 in project


Ignore:
Timestamp:
07/11/12 22:20:56 (9 years ago)
Author:
Christian Kellermann
Message:

doodle docs: document blit-image and define-resources

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/doodle

    r26070 r27048  
    161161{{#:right}}.
    162162
     163<procedure>(text-width text)</procedure>
     164
     165Returns multiple values: The ''width'' and ''height'' in pixels of the
     166given ''text'' when rendered with the current font settings. ''text''
     167is assumed to be a string.
     168
    163169<procedure>(save-screenshot filename)</procedure>
    164170
     
    176182<parameter>(font-color)</parameter>
    177183
    178 Holds the current font color.
     184Holds the current font color. Default is black.
    179185
    180186<parameter>(font-size)</parameter>
    181187
    182 Holds the current font-size.
     188Holds the current font-size. Default is 12.
    183189
    184190<parameter>(current-background)</parameter>
    185191
    186 Holds the current background color.
     192Holds the current background color. Default is black.
     193
     194<parameter>(line-width)</parameter>
     195
     196Holds the line width used for drawing. Default is 2.0.
     197
     198==== Images
     199
     200Since version XXX doodle supports blitting images in. The initial form
     201is {{define-resource}}. This registers an image and makes it available
     202through the given symbol ''name'' to all procedures that take a
     203resource argument below.
     204
     205<procedure>(define-resource name type filename . data )</procedure>
     206
     207Registers a resource under the name ''name''. The resource is read
     208from a file specified with ''filename''. The ''type'' argument is a
     209keyword and specifies how the ''data'' argument is handled and which
     210form is expected.
     211
     212The following types are handled:
     213
     214* #:image
     215
     216  A single image from a single file. It takes optional argumens
     217  ''x-offset'', ''y-offset'' and ''scale-factor'' to take just a
     218  fraction out of the given image file and to be able to scale it.
     219
     220  The following example does this several times:
     221
     222  <enscript language="scheme">
     223(define-resource 'water #:image "Water Block.png" *terrain-xoffset* *terrain-yoffset*)
     224(define-resource 'stone #:image "Stone Block.png" *terrain-xoffset* *terrain-yoffset*)
     225(define-resource 'princess #:image "Character Princess Girl.png" 0 -80)
     226(define-resource 'bubble #:image "SpeechBubble.png" -15 -120)
     227(define-resource 'bug #:image "Enemy Bug.png" 0 -80)
     228(define-resource 'tree #:image "Tree Tall.png" 0 -80 )
     229(define-resource 'heart #:image "Heart.png" 0 0 0.5)
     230  </enscript>
     231
     232* #:tileset
     233
     234  This assumes the image to consist of one or more square tiles. Then
     235  several images are referenced out of a single image file. The
     236  ''data'' argument is expected to be a list of two elements: the
     237  tile-size and a list consisting of (name number) pairs (proper
     238  lists). The following examples makes three tiles accessible through
     239  their names: wall, floor and hero. They can be drawn with the
     240  {{blit-image}} procedure.
     241
     242  <enscript language="scheme">
     243(define-resource 'tiles
     244                  #:tileset
     245                   "../roguelike/tile.png"
     246                    32
     247                    '((wall 2)
     248                      (floor 30)
     249                      (hero 486)))
     250  </enscript>
     251
     252<procedure>(blit-image name x y rotation: angle )</procedure>
     253
     254Blits in the image ''name'' at position (x, y). If angle is given the
     255image is rotated. The angle has to be given in degrees, negative
     256values indicate counter-clockwise rotation.
    187257
    188258==== Collision detection
     
    251321
    252322; 0.1 : Initial version
    253 ; 0.2 : Fixed event handling, added mouse events, background images possible
     323; 0.2 : bogus tag, sorry
     324; 0.3 : Fixed event handling, added mouse events, background images possible
     325; 0.4 : blit-image and define-resources added, text-width and line-width are exported
    254326
    255327=== License
Note: See TracChangeset for help on using the changeset viewer.