► |  | Slideshow: Figure and Presentation Tools

1 | Creating Slide Presentations
2 | Making Pictures
3 | Making Slides
4 | Typesetting Racket Code
5 | Animations
| Bibliography
| Index

▼ | 2 | Making Pictures

2.1 | Pict Datatype
2.2 | Basic Pict Constructors
2.3 | Pict Combiners
2.4 | Pict Drawing Adjusters
2.5 | Bounding Box Adjusters
2.6 | Pict Finders
2.7 | More Pict Constructors
2.8 | Miscellaneous
2.9 | Rendering
2.10 | Conversion to Picts

On this page:

prop: pict-convertible
prop: pict-convertible?
pict-convertible?
pict-convert

top ← prev up next →

#### 2.10`` Conversion to Picts

(require slideshow/pict-convert)

The slideshow/pict-convert library defines a protocol for values to convert themselves to picts. The protocol is used by DrRacket’s interactions window, for example, to render values that it prints

> > value

> > prop:pict-convertible : struct-type-property?

A property whose value should be a procedure matching the contract (-> any/c pict?). The procedure is called when a structure with the property is passed to pict-convert; the argument to the procedure is the structure, and the procedure’s result should be a pict.

> > value

> > prop:pict-convertible? : struct-type-property?

A property whose value should be a predicate procedure (i.e., matching the contract predicate/c).

If this property is not set, then it is assumed to be the function (λ (x) #t).

If this property is set, then this procedure is called by pict-convertible? to determine if this particular value is convertible (thereby supporting situations where some instances of a given struct are convertible to picts, but others are not).

> > procedure

> > (pict-convertible? v) → boolean?

> v : any/c

Returns #t if v supports the conversion protocol (by being a struct with the prop:pict-convertible property) and #f otherwise.

> > procedure

> > (pict-convert v) → pict?

> v : pict-convertible?

Requests a data conversion from v to a pict.
top ← prev up next →