File canvas-draw/api/primitives.wiki artifact 36cfca72a5 part of check-in ed10f826ff
primitives Module
Synopsis
Racket | (require (planet murphy/canvas-draw:1:0/primitives)) |
---|---|
CHICKEN | (require-extension canvas-draw-primitives) |
Drawing primitives.
Points
(canvas-pixel! [canvas canvas?] [x integer?] [y integer?] [color integer? (canvas-foreground canvas)]) → void?
Draws a single pixel of the given color on the given canvas.
(canvas-mark! [canvas canvas?] [x integer?] [y integer?]) → void?
Draws a marker symbol on the given canvas.
(canvas-mark-type [canvas canvas?]) → symbol?
Retrieves the current marker symbol type for the given canvas. Possible values are
'+
or'plus
'*
or'star
'0
or'circle
'O
or'hollow-circle
'X
or'x
'box
'hollow-box
'diamond
'hollow-diamond
(canvas-mark-type-set! [canvas canvas?] [mark-type symbol?]) → void?
(set! (canvas-mark-type [canvas canvas?]) [mark-type symbol?]) → void?
(set! (canvas-mark-type [canvas canvas?]) [mark-type symbol?]) → void?
Sets the current marker symbol type for the given canvas.
(canvas-mark-size [canvas canvas?]) → integer?
Retrieves the current marker symbol size for the given canvas.
(canvas-mark-size-set! [canvas canvas?] [size integer?]) → void?
(set! (canvas-mark-size [canvas canvas?]) [size integer?]) → void?
(set! (canvas-mark-size [canvas canvas?]) [size integer?]) → void?
Sets the current marker symbol size for the given canvas.
Lines
(canvas-line! [canvas canvas?] [x0 real?] [y0 real?] [x1 real?] [y1 real?]) → void?
Draws a line on the given canvas.
(canvas-rectangle! [canvas canvas?] [x0 real?] [x1 real?] [y0 real?] [y1 real?]) → void?
Draws a hollow rectangle on the given canvas.
(canvas-arc! [canvas canvas?] [x real?] [y real?] [width real?] [height real?] [alpha0 real?] [alpha1 real?]) → void?
Draws a hollow ellipsis segment on the given canvas.
(canvas-line-style [canvas canvas?]) → symbol?
Retrieves the current line style of the given canvas. Possible values are
'continuous
'dashed
'dotted
'dash-dotted
'dash-dot-dotted
'custom
(canvas-line-style-set! [canvas canvas?] [line-style (or/c symbol? list?)]) → symbol?
(set! (canvas-line-style [canvas canvas?]) [line-style (or/c symbol? list?)]) → symbol?
(set! (canvas-line-style [canvas canvas?]) [line-style (or/c symbol? list?)]) → symbol?
Sets the current line style of the given canvas and returns the previous value.
In addition to the possible return values of canvas-line-style
a custom line-style
can be fully specified using the form
(list 'custom [len integer?] ...)
.
(canvas-line-width [canvas canvas?]) → integer?
Retrieves the current line width of the given canvas.
(canvas-line-width-set! [canvas canvas?] [line-width integer?]) → integer?
(set! (canvas-line-width [canvas canvas?]) [line-width integer?]) → integer?
(set! (canvas-line-width [canvas canvas?]) [line-width integer?]) → integer?
Sets the current line width of the given canvas and returns the previous value.
(canvas-line-join [canvas canvas?]) → symbol?
Retrieves the current line join style of the given canvas. Possible values are
'miter
'bevel
'round
(canvas-line-join-set! [canvas canvas?] [line-join symbol?]) → symbol?
(set! (canvas-line-join [canvas canvas?]) [line-join symbol?]) → symbol?
(set! (canvas-line-join [canvas canvas?]) [line-join symbol?]) → symbol?
Sets the current line join style of the given canvas and returns the previous value.
(canvas-line-cap [canvas canvas?]) → symbol?
Retrieves the current line cap style of the given canvas.
'flat
'square
'round
(canvas-line-cap-set! [canvas canvas?] [line-cap symbol?]) → symbol?
(set! (canvas-line-cap [canvas canvas?]) [line-cap symbol?]) → symbol?
(set! (canvas-line-cap [canvas canvas?]) [line-cap symbol?]) → symbol?
Sets the current line cap style of the given canvas and returns the previous value.
Filled Areas
(canvas-box! [canvas canvas?] [x0 real?] [x1 real?] [y0 real?] [y1 real?]) → void?
Draws a filled rectangle on the given canvas.
(canvas-sector! [canvas canvas?] [x real?] [y real?] [width real?] [height real?] [alpha0 real?] [alpha1 real?]) → void?
Draws a filled ellipsis sector on the given canvas.
(canvas-chord! [canvas canvas?] [x real?] [y real?] [width real?] [height real?] [alpha0 real?] [alpha1 real?]) → void?
Draws a filled ellipsis arc on the given canvas.
(canvas-background-opacity [canvas canvas?]) → symbol?
Retrieves the current background opacity of the given canvas. Possible values are
'transparent
'opaque
(canvas-background-opacity-set! [canvas canvas?] [background-opacity symbol?]) → symbol?
(set! (canvas-background-opacity-set! [canvas canvas?]) [background-opacity symbol?]) → symbol?
(set! (canvas-background-opacity-set! [canvas canvas?]) [background-opacity symbol?]) → symbol?
Sets the current background opacity of the given canvas and returns the previous value.
(canvas-fill-mode [canvas canvas?]) → symbol?
Retrieves the current polygon fill mode of the given canvas. Possible values are
'even-odd
'winding
(canvas-fill-mode-set! [canvas canvas?] [fill-mode symbol?]) → symbol?
(set! (canvas-fill-mode [canvas canvas?]) [fill-mode symbol?]) → symbol?
(set! (canvas-fill-mode [canvas canvas?]) [fill-mode symbol?]) → symbol?
Sets the current polygon fill mode of the given canvas and returns the previous value.
(canvas-interior-style [canvas canvas?]) → (or/c symbol? list?)
Retrieves the current interior style of the given canvas. Possible values are
'solid
'(hatch horizontal)
'(hatch vertical)
'(hatch forward-diagonal)
'(hatch backward-diagonal)
'(hatch cross)
'(hatch diagonal-cross)
(list 'stipple [width integer?] [height integer?] [data blob?])
(list 'pattern/rgb [width integer?] [height integer?] [data blob?])
(list 'pattern/rgba [width integer?] [height integer?] [data blob?])
#f
(canvas-interior-style-set! [canvas canvas?] [interior-style (or/c symbol? list?)]) → void?
(set! (canvas-interior-style [canvas canvas?]) [interior-style (or/c symbol? list?)]) → void?
(set! (canvas-interior-style [canvas canvas?]) [interior-style (or/c symbol? list?)]) → void?
Sets the current interior style of the given canvas and returns the previous value.
Text
(canvas-text! [canvas canvas?] [x real?] [y real?] [text string?]) → void?
Draws a string of text on the given canvas.
(canvas-font [canvas canvas?]) → string?
Retrieves the current font of the given canvas.
(canvas-font-set! [canvas canvas?] [font string?]) → void?
(set! (canvas-font [canvas canvas?]) [font string?]) → void?
(set! (canvas-font [canvas canvas?]) [font string?]) → void?
Sets the current font of the given canvas and returns the previous value.
(canvas-text-alignment [canvas canvas?]) → symbol?
Retrieves the current text alignment of the given canvas. Possible values are
'north
'south
'east
'west
'north-east
'north-west
'south-east
'south-west
'center
'base-left
'base-center
'base-right
(canvas-text-alignment-set! [canvas canvas?] [text-alignment symbol?]) → void?
(set! (canvas-text-alignment [canvas canvas?]) [text-alignment symbol?]) → void?
(set! (canvas-text-alignment [canvas canvas?]) [text-alignment symbol?]) → void?
Sets the current text alignment of the given canvas and returns the previous value.
(canvas-text-orientation [canvas canvas?]) → real?
Retrieves the current text orientation of the given canvas.
(canvas-text-orientation-set! [canvas canvas?] [orientation real?]) → void?
(set! (canvas-text-orientation [canvas canvas?]) [orientation real?]) → void?
(set! (canvas-text-orientation [canvas canvas?]) [orientation real?]) → void?
Sets the current text orientation of the given canvas and returns the previous value.
(canvas-font-dimensions [canvas canvas?]) → (values integer? integer? integer? integer?)
Returns the maximum width, height, ascent and descent of the current font of the given canvas.
(canvas-text-size [canvas canvas?] [text string?]) → (values integer? integer?)
Computes the width and height of the given text when drawn on the given canvas.
(canvas-text-box [canvas canvas?] [x integer?] [y integer?] [text string?]) → (values integer? integer? integer? integer?)
Computes the bounding box of the given text when drawn on the given canvas. Returns the minimum and maximum x and y coordinates.
Vertices
(call-with-canvas-in-mode [canvas canvas?] [mode symbol?] [proc (-> canvas? any)]) → any
Calls proc
with the given canvas and ready to receive vertex data
in the given mode. Returns whatever proc
returns.
Possible modes are
'open-lines
'closed-lines
'fill
'clip
'bezier
'region
'path
(canvas-path-set! [canvas canvas?] [path-action symbol?]) → void?
Configures the action between sequences of vertex data sent to the given canvas. Possible actions are
'new
'move-to
'line-to
'arc
'curve-to
'close
'fill
'stroke
'fill+stroke
'clip
(canvas-vertex! [canvas canvas?] [x real?] [y real?]) → void?
Sends a vertex to the given canvas.