DRAW - Cor, gradientes e padrões
DRAW pen <cor>
Red [needs: view]
view [
base draw [
pen yellow ; cor como nome
triangle 10x10 50x50 50x10
pen 255.10.10 ; cor como tuple!
circle 40x40 20
]
]
DRAW fill-pen <color>
Red [needs: view]
view [
base draw [
fill-pen yellow ; cor como nome
triangle 10x10 50x50 50x10
fill-pen 255.10.10 ; cor como tuple!
circle 40x40 20
]
]
Desligando o pen e o fill-pen:
Red [needs: view]
view [
base draw [
pen off
fill-pen yellow
triangle 10x10 50x50 50x10
fill-pen off
circle 40x40 20
]
]
DRAW linear - gradiente linear de cor
From Red's official documentation (with eventual minor changes):
Syntax
<pen/fill-pen> linear <color1> <offset> ... <colorN> <offset> <start> <end> <spread>
<color1/N> : list of colors for the gradient (tuple! word!).
<offset> : (optional) offset of gradient color (float!).
<start> : (optional) starting point (pair!).
<end> : (optional unless <start>) ending point (pair!).
<spread> : (optional) spread method (word!).
Description
Sets a linear gradient to be used for drawing operations. The following values are accepted for the spread method: pad, repeat, reflect (currently pad is same as repeat for Windows platform).
When used, the start/end points define a line where the gradient paints along. If they are not used, the gradient will be paint along a horizontal line inside the shape currently drawing.
Pen
Red [needs: view]
view [
base draw [
pen linear blue green red 0x0 80x80
line-width 5
line 0x0 80x80
]
base draw [
pen linear blue green 0x0 40x40 pad
line-width 5
line 0x0 80x80
]
base draw [
pen linear blue green 0x0 40x40 reflect
line-width 5
line 0x0 80x80
]
]
Fill-pen
Red [needs: view]
view [
base draw [
fill-pen linear blue green red 18x18 62x62
circle 40x40 30
]
]
DRAW radial - gradiente radial de cor
From Red's official documentation (with eventual minor changes):
Syntax
<pen/fill-pen> radial <color1> <offset> ... <colorN> <offset> <center> <radius> <focal> <spread>
<color1/N> : list of colors for the gradient (tuple! word!).
<offset> : (optional) offset of gradient color (float!).
<center> : (optional) center point (pair!).
<radius> : (optional unless <center>) radius of the circle to paint along (integer! float!).
<focal> : (optional) focal point (pair!).
<spread> : (optional) spread method (word!).
Description
Sets a radial gradient to be used for drawing operations. The following values are accepted for the spread method: pad, repeat, reflect (currently pad is same as repeat for Windows platform).
The radial gradient will be painted from focal point to the edge of a circle defined by center point and radius. The start color will be painted in focal point and the end color will be painted in the edge of the circle.
Pen
Red [needs: view]
view [
base draw [
pen radial blue green red 40x40 40 ; colors center radius
line-width 20
line 10x30 70x30
]
]
Fill-pen
Red [needs: view]
view [
base draw [
fill-pen radial blue green red 40x40 40 ; colors center radius
triangle 20x70 60x70 40x20
]
]
DRAW diamond - gradiente de cor em forma de diamante
From Red's official documentation (with eventual minor changes):
Syntax
<pen/fill-pen> diamond <color1> <offset> ... <colorN> <offset> <upper> <lower> <focal> <spread>
<color1/N> : list of colors for the gradient (tuple! word!).
<offset> : (optional) offset of gradient color (float!).
<upper> : (optional) upper corner of a rectangle. (pair!).
<lower> : (optional unless <upper>) lower corner of a rectangle (pair!).
<focal> : (optional) focal point (pair!).
<spread> : (optional) spread method (word!).
Description
Sets a diamond-shaped gradient to be used for drawing operations. The following values are accepted for the spread method: pad, repeat, reflect (currently pad is same as repeat for Windows platform).
The diamond gradient will be painted from focal point to the edge of a rectangle defined by upper and lower. The start color will be painted in focal point and the end color will be painted in the edge of the diamond.
Red [needs: view]
view [
base draw [
fill-pen diamond blue green red ; just centers the gradient
circle 40x40 35
]
base draw [
fill-pen diamond blue green red 10x10 50x50 ;added coordinates of the gradient "box"
circle 40x40 35
]
base draw [
fill-pen diamond blue green red 10x10 50x50 30x48; added a point of focus
circle 40x40 35
]
base draw [
pen diamond blue green red 10x10 50x50 30x48
; a line over the last gradient:
line-width 10
line 10x10 70x70
]
]
DRAW bitmap - preenchimento bitmap
From Red's official documentation (with eventual minor changes):
Syntax
<pen/fill-pen> bitmap <image> <start> <end> <mode>
<image> : image used for tiling (image!).
<start> : (optional) upper corner for crop section within image (pair!).
<end> : (optional) lower corner for crop section within image (pair!).
<mode> : (optional) tile mode (word!).
Description
Sets an image as pattern to be used for filling operations. The following values are accepted for the tile mode: tile (default), flip-x, flip-y, flip-xy, clamp.
Starting default point is 0x0 and ending point is image’s size.
O bitmap usado dos exemplos é:
Red [needs: view]
myimage: load %asprite.bmp ; primeiro carrega o bitmap
view [
base draw [
fill-pen bitmap myimage tile ; padrão (default)
box 0x0 79x79
]
base draw [
fill-pen bitmap myimage flip-x
box 0x0 79x79
]
base draw [
fill-pen bitmap myimage flip-y
box 0x0 79x79
]
base draw [
fill-pen bitmap myimage flip-xy
box 0x0 79x79
]
base draw [
fill-pen bitmap myimage clamp
box 0x0 79x79
]
base draw [
pen bitmap myimage
line-width 15
line 0x0 80x80
]
]
DRAW pattern - preenchimento com padrão desenhado
From Red's official documentation (with eventual minor changes):
Syntax
<pen-fill-pen> pattern <size> <start> <end> <mode> [<commands>]
<size> : size of the internal image where <commands> will be drawn (pair!).
<start> : (optional) upper corner for crop section within internal image (pair!).
<end> : (optional) lower corner for crop section within internal image (pair!).
<mode> : (optional) tile mode (word!).
<commands> : block of Draw commands to define the pattern.
Description
Sets a custom shape as pattern to be used for filling operations. The following values are accepted for the tile mode: tile (default), flip-x, flip-y, flip-xy, clamp.
Starting default point is 0x0 and ending point is <size>.
Red [needs: view]
view [
; first we draw a filled box:
base draw [
fill-pen pattern 10x10 [
circle 5x5 4
line 3x3 7x7
]
box 0x0 79x79
]
; then we draw a line:
base draw [
pen pattern 10x10 [
circle 5x5 4
line 3x3 7x7
]
line-width 15
line 0x0 79x79
]
]