(class)
public abstract FillPattern
Abstract superclass for all patterns that serve as application-level textures.
Description
FillPattern and its subclasses represent textures that high-level, application code uses to draw regions. For example, various graphical options that specify the texture characteristics of graphical options are of the type
FillPattern.
Although this class and its subclasses represent textures, they do not lie in the
Texture class hierarchy. The
Texture class and its subclasses represent low-level textures. These classes are not usually used by application code but are used at the machine level. The main subclass of
Texture is
Color, which represents a solid-colored texture.
When working with
FillPatterns, you can use the API of a
Pixmap, a
Texture (such as
Color), a
Drawable, or a
Renderer2d. The
FillPattern class lets you use these interfaces by either performing automatic casting or by providing a
FillPattern.to-* conversion method.
For example, to create/specify a
FillPattern that has a uniform texture (solid color), you can provide a supported
String, which identifies a supported color or you call the
Color.from-rgb procedure, which creates a
Color object. In both cases, casting is automatically performed. Refer to
FillPattern.default#factory for information on what object types are supported for casting.
Note that although
Textures are immutable (not able to be modified)
FillPatterns may, in some cases, be mutable. If the writable? getter is true, then the
mutate-fill-pattern form can be used to modify the
FillPattern's underlying image.
In general
FillPatterns created from
Pixmaps are mutable, whereas
FillPatterns created from
Colors are not.
When a
FillPattern is modified,
Textures previously acquired using the
FillPattern.to-Texture method will not change, although subsequent calls to
FillPattern.to-Texture will return a
Texture that represents the new image.
However, this is not true for
FillPatterns made from
Pixmaps or
Drawables; any change to the
Pixmap or
Drawable made after the
FillPattern is created
will alter the
FillPattern.
In particular, if a Drawable is destroyed, any FillPatterns made from that Drawable will become invalid.Note that mutating the
FillPattern (using
mutate-fill-pattern) with a
Pixmap as the mutation medium will cause a
Drawable-based
FillPattern to take a snapshot of the
Drawable; the
Drawable will not be modified by the mutation, and any subsequent modifications to the
Drawable will not affect the
FillPattern.
Example
The following example creates a
Fill (graphical) object and sets its
background property to a
String. Since
background is a
FillPattern, and
"red" translates to one of the supported colors, Curl silently converts it to a
FillPattern object.
| Example |
 |
{Fill width=1in, height=1in, background="red"}
| |
| clone-from: | Constructs a copy of the given FillPattern. |
| constructor
protected
| {FillPattern.clone-from other:FillPattern} |
| constructor
protected
| {FillPattern.default} |
| from-rgb: | Constructs a FillPattern from rgb values between 0 and 1 |
| from-string: | Constructs a FillPattern from a StringInterface. |
| from-url: | Constructs a FillPattern from a Url. |
| ignore-alpha?: | Indicates if the alpha channel (semi-transparency) should be ignored while rendering. |
accessor public FillPattern.ignore-alpha?:
bool
| readable?: | Returns true if this FillPattern is readable |
accessor public abstract FillPattern.readable?:
bool
| uniform?: | Indicates whether the FillPattern has a solid color. |
accessor public abstract FillPattern.uniform?:
bool
| writable?: | Returns true if this FillPattern is writable |
accessor public abstract FillPattern.writable?:
bool
public constant FillPattern.aqua:
FillPattern ={FillPattern.from-color {Palette.get-aqua}}
public constant FillPattern.beige:
FillPattern ={FillPattern.from-color {Palette.get-beige}}
public constant FillPattern.black:
FillPattern ={FillPattern.from-color {Palette.get-black}}
public constant FillPattern.blue:
FillPattern ={FillPattern.from-color {Palette.get-blue}}
public constant FillPattern.brown:
FillPattern ={FillPattern.from-color {Palette.get-brown}}
public constant FillPattern.cyan:
FillPattern ={FillPattern.from-color {Palette.get-cyan}}
public constant FillPattern.fuchsia:
FillPattern ={FillPattern.from-color {Palette.get-fuchsia}}
public constant FillPattern.gray:
FillPattern ={FillPattern.from-color {Palette.get-gray}}
public constant FillPattern.green:
FillPattern ={FillPattern.from-color {Palette.get-green}}
public constant FillPattern.lime:
FillPattern ={FillPattern.from-color {Palette.get-lime}}
public constant FillPattern.magenta:
FillPattern ={FillPattern.from-color {Palette.get-magenta}}
public constant FillPattern.maroon:
FillPattern ={FillPattern.from-color {Palette.get-maroon}}
public constant FillPattern.navy:
FillPattern ={FillPattern.from-color {Palette.get-navy}}
public constant FillPattern.olive:
FillPattern ={FillPattern.from-color {Palette.get-olive}}
public constant FillPattern.orange:
FillPattern ={FillPattern.from-color {Palette.get-orange}}
public constant FillPattern.pink:
FillPattern ={FillPattern.from-color {Palette.get-pink}}
public constant FillPattern.purple:
FillPattern ={FillPattern.from-color {Palette.get-purple}}
public constant FillPattern.red:
FillPattern ={FillPattern.from-color {Palette.get-red}}
public constant FillPattern.silver:
FillPattern ={FillPattern.from-color {Palette.get-silver}}
public constant FillPattern.teal:
FillPattern ={FillPattern.from-color {Palette.get-teal}}
public constant FillPattern.transparent:
FillPattern ={FillPattern.from-color {Palette.get-transparent}}
public constant FillPattern.violet:
FillPattern ={FillPattern.from-color {Palette.get-violet}}
public constant FillPattern.wheat:
FillPattern ={FillPattern.from-color {Palette.get-wheat}}
public constant FillPattern.white:
FillPattern ={FillPattern.from-color {Palette.get-white}}
public constant FillPattern.yellow:
FillPattern ={FillPattern.from-color {Palette.get-yellow}}
| get-white: | Returns a FillPattern that represents the color white. Example This is a Fill with a white background FillPattern and a black border. | Example:
White FillPattern |  | {Fill
width = 1in,
height = 1in,
border-color = {FillPattern.get-black},
border-width = 2pt,
background = {FillPattern.get-white}
}
| |
|
| clone: | Returns an identical copy of the fill-pattern |
| paint: | Paints this FillPattern onto the given Renderer2d in the specified bounds. |
| to-Pixel: | Returns a Pixel that approximates the value of this FillPattern. |
| to-Pixmap: | Returns a Pixmap representing this FillPattern. |
| to-Texture: | Returns a texture from this FillPattern. |
|
public sealed
| {FillPattern.to-uniform-FillPattern}:FillPattern |
(constructor)
Constructs a copy of the given FillPattern.
other: The FillPattern to clone.
Overriding
(constructor)
| protected
| {FillPattern.default} |
Used internally.
Description
See the default factory for the arguments for initializing a FillPattern.
(factory)
Constructs a FillPattern.
Description
You may explicitly create a FillPattern object by supplying as an argument one of the objects that can be converted to a FillPattern.
An easier way is to supply the object directly and avoid explicitly calling FillPattern. For example: let a:FillPattern = "red"
source: An object that can be converted to a
FillPattern.
This factory can silently convert the following object types to a suitable
FillPattern:
This factory is called when you supply an object of any of these data types where a
FillPattern is needed.
Converting StringsThis factory can silently convert a supported string to a
FillPattern by attempting various conversions. The following string values are valid:
Notes
In general, when you create a
FillPattern from a mutable object (
Pixmap or
Drawable), any change to the source object affects the
FillPattern.
In particular, if a Drawable is destroyed, any FillPatterns made from that Drawable will become invalid.Note that mutating the
FillPattern (using
mutate-fill-pattern) with a
Pixmap as the mutation medium will cause a
Drawable-based
FillPattern to take a snapshot of the
Drawable; the
Drawable will not be modified by the mutation, and any subsequent modifications to the
Drawable will not affect the
FillPattern.
On the other hand, if a
FillPattern is mutated using a
Pixmap, then the source
Pixmap (if any) and the returned
Pixmaps of any previous calls to
FillPattern.to-Pixmap will reflect the changes made during the mutation.
Example
The following example uses the
url format.
| Example:
Creating a FillPattern from a Url |
 |
{value
let t:FillPattern = {url "curl://install/docs/default/images/grass.jpg"}
{Fill width=1in, height=1in, background=t}
}
| |
Example
The following example creates a
FillPattern from a
Color.
| Example:
Creating a FillPattern from a Color |
 |
{import * from CURL.GRAPHICS.RENDERER3D} || for Color
{value
|| Initializing a FillPattern by calling a procedure that
|| returns a Color object, which can be automatically
|| converted to a FillPattern.
let moss:FillPattern = {FillPattern {Color.from-rgb 0.3, 0.9, 0.2}}
|| The following is fine too
|| let moss:FillPattern = {Color.from-rgb 0.3, 0.9, 0.2}
{Frame
border-width=2pt,
border-color=moss,
margin=0.5cm,
height=2cm,
{text color=moss, MOSS MAN!}
}
}
| |
(factory)
Constructs a FillPattern from a Color.
(factory)
Constructs a FillPattern from a Drawable.
(factory)
Constructs a FillPattern from a Pixmap.
(factory)
Constructs a FillPattern from rgb values between 0 and 1
(factory)
Constructs a FillPattern from a StringInterface.
(factory)
Constructs a FillPattern from a Texture.
(factory)
Constructs a FillPattern from a Url.
(accessor)
accessor public FillPattern.ignore-alpha?:
bool Indicates if the alpha channel (semi-transparency) should be ignored while rendering.
Description
The default value is false, and the alpha channel should come under consideration.
(accessor)
accessor public abstract FillPattern.readable?:
bool Returns true if this FillPattern is readable
(accessor)
accessor public abstract FillPattern.uniform?:
bool Indicates whether the FillPattern has a solid color.
Overriding
The default implementation returns true. Subclasses should override it such that it returns true if FillPattern.tget-square returns the same value for all arguments.
(accessor)
accessor public abstract FillPattern.writable?:
bool Returns true if this FillPattern is writable
(class constant)
public constant FillPattern.aqua:
FillPattern ={FillPattern.from-color {Palette.get-aqua}}
(class constant)
public constant FillPattern.beige:
FillPattern ={FillPattern.from-color {Palette.get-beige}}
(class constant)
public constant FillPattern.black:
FillPattern ={FillPattern.from-color {Palette.get-black}}
(class constant)
public constant FillPattern.blue:
FillPattern ={FillPattern.from-color {Palette.get-blue}}
(class constant)
public constant FillPattern.brown:
FillPattern ={FillPattern.from-color {Palette.get-brown}}
(class constant)
public constant FillPattern.cyan:
FillPattern ={FillPattern.from-color {Palette.get-cyan}}
(class constant)
public constant FillPattern.fuchsia:
FillPattern ={FillPattern.from-color {Palette.get-fuchsia}}
A FillPattern that represents the color fuchsia (fuchsia).
(class constant)
public constant FillPattern.gray:
FillPattern ={FillPattern.from-color {Palette.get-gray}}
(class constant)
public constant FillPattern.green:
FillPattern ={FillPattern.from-color {Palette.get-green}}
(class constant)
public constant FillPattern.lime:
FillPattern ={FillPattern.from-color {Palette.get-lime}}
(class constant)
public constant FillPattern.magenta:
FillPattern ={FillPattern.from-color {Palette.get-magenta}}
A FillPattern that represents the color magenta (magenta).
(class constant)
public constant FillPattern.maroon:
FillPattern ={FillPattern.from-color {Palette.get-maroon}}
A FillPattern that represents the color maroon (maroon).
(class constant)
public constant FillPattern.navy:
FillPattern ={FillPattern.from-color {Palette.get-navy}}
(class constant)
public constant FillPattern.olive:
FillPattern ={FillPattern.from-color {Palette.get-olive}}
(class constant)
public constant FillPattern.orange:
FillPattern ={FillPattern.from-color {Palette.get-orange}}
A FillPattern that represents the color orange (orange).
(class constant)
public constant FillPattern.pink:
FillPattern ={FillPattern.from-color {Palette.get-pink}}
(class constant)
public constant FillPattern.purple:
FillPattern ={FillPattern.from-color {Palette.get-purple}}
A FillPattern that represents the color purple (purple).
(class constant)
public constant FillPattern.red:
FillPattern ={FillPattern.from-color {Palette.get-red}}
(class constant)
public constant FillPattern.silver:
FillPattern ={FillPattern.from-color {Palette.get-silver}}
A FillPattern that represents the color silver (silver).
(class constant)
public constant FillPattern.teal:
FillPattern ={FillPattern.from-color {Palette.get-teal}}
(class constant)
public constant FillPattern.transparent:
FillPattern ={FillPattern.from-color {Palette.get-transparent}}
A FillPattern that represents the color transparent (transparent).
(class constant)
public constant FillPattern.violet:
FillPattern ={FillPattern.from-color {Palette.get-violet}}
A FillPattern that represents the color violet (violet).
(class constant)
public constant FillPattern.wheat:
FillPattern ={FillPattern.from-color {Palette.get-wheat}}
(class constant)
public constant FillPattern.white:
FillPattern ={FillPattern.from-color {Palette.get-white}}
(class constant)
public constant FillPattern.yellow:
FillPattern ={FillPattern.from-color {Palette.get-yellow}}
A FillPattern that represents the color yellow (yellow).
(class proc)
Returns a FillPattern that represents the color aqua. This is the same color as cyan.
Example
| Example:
Aqua FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-aqua}
}
| |
(class proc)
Returns a FillPattern that represents the color beige.
Example
| Example:
Beige FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-beige}
}
| |
(class proc)
Returns a FillPattern that represents the color black.
Example
| Example:
Black FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-black}
}
| |
(class proc)
Returns a FillPattern that represents the color blue.
Example
| Example:
Blue FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-blue}
}
| |
(class proc)
Returns a FillPattern that represents the color brown.
Example
| Example:
Brown FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-brown}
}
| |
(class proc)
Returns a FillPattern that represents the color cyan. This is the same color as aqua.
Example
| Example:
Cyan FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-cyan}
}
| |
(class proc)
Returns a FillPattern that represents the color fuchsia. This is the same color as magenta.
Example
| Example:
Fuchsia FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-fuchsia}
}
| |
(class proc)
Returns a FillPattern that represents the color gray.
Example
| Example:
Gray FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-gray}
}
| |
(class proc)
Returns a FillPattern that represents the color green.
Example
| Example:
Green FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-green}
}
| |
(class proc)
Returns a FillPattern that represents the color lime.
Example
| Example:
Lime FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-lime}
}
| |
(class proc)
Returns a FillPattern that represents the color magenta. This is the same color as fuchsia.
Example
| Example:
Magenta FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-magenta}
}
| |
(class proc)
Returns a FillPattern that represents the color maroon.
Example
| Example:
Maroon FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-maroon}
}
| |
(class proc)
Returns a FillPattern that represents the color navy.
Example
| Example:
Navy FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-navy}
}
| |
(class proc)
Returns a FillPattern that represents the color olive.
Example
| Example:
Olive FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-olive}
}
| |
(class proc)
Returns a FillPattern that represents the color orange.
Example
| Example:
Orange FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-orange}
}
| |
(class proc)
Returns a FillPattern that represents the color pink.
Example
| Example:
Pink FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-pink}
}
| |
(class proc)
Returns a FillPattern that represents the color purple.
Example
| Example:
Purple FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-purple}
}
| |
(class proc)
Returns a FillPattern that represents the color red.
Example
| Example:
Red FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-red}
}
| |
(class proc)
Returns a FillPattern that represents the color silver.
Example
| Example:
Silver FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-silver}
}
| |
(class proc)
Returns a FillPattern that represents the color teal.
Example
| Example:
Teal FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-teal}
}
| |
(class proc)
(class proc)
Returns a FillPattern that represents the color violet.
Example
| Example:
Violet FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-violet}
}
| |
(class proc)
Returns a FillPattern that represents the color wheat.
Example
| Example:
Wheat FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-wheat}
}
| |
(class proc)
Returns a FillPattern that represents the color white.
Example
This is a
Fill with a white background
FillPattern and a black border.
| Example:
White FillPattern |
 |
{Fill
width = 1in,
height = 1in,
border-color = {FillPattern.get-black},
border-width = 2pt,
background = {FillPattern.get-white}
}
| |
(class proc)
Returns a FillPattern that represents the color yellow.
Example
| Example:
Yellow FillPattern |
 |
{Fill
width = 1in,
height = 1in,
background = {FillPattern.get-yellow}
}
| |
(method)
Returns an identical copy of the fill-pattern
Overriding
Each class which inherits from
FillPattern should implement a
clone-from constructor, which copies its fields and calls
construct-super.clone-from.
clone should then be implemented as just constructing a new top-level object and calling its
clone-from constructor, such as:
{define-class final Foo
{inherits FillPattern}
field my-field:int
{constructor {clone-from
other:Foo
}
{construct-super.clone-from other}
set self.my-field = other.my-field
}
{method {clone}:FillPattern {return {Foo.clone-from self}}}
...
}
(method)
Paints this FillPattern onto the given Renderer2d in the specified bounds.
x, y: The upper-left corner of the rectangle to be filled.
width, height: The width and height of the rectangle to be filled. width and height must be non-negative.
uv1: The texture coordinate at the upper-left corner of the rectangle.
uv2: The texture coordinate at the bottom-right corner of the rectangle.
Description
It is important that the
FillPattern does not attempt to render (or cause anything to be rendered) using itself as a
fill-pattern since this would cause an infinite loop.
(method)
Returns a Pixel that approximates the value of this FillPattern.
Overriding
Override this method. The default method has no implementation.
Notes
(method)
Returns a Pixmap representing this FillPattern.
Overriding
Override this method. The default method has no implementation.
You may mutate, free, etc. the resulting pixmap.
out: A Pixmap that can be used by the FillPattern for dumping its output.
(method)
Returns a texture from this FillPattern.
Description
The default implementation calls
to-Pixmap, which, in this class is not implemented. A
Texture is created from the
Pixmap and returned.
If you just implement
to-Pixmap, then each time you make a
to-Texture call, a new
Pixmap object is first created, from which, the
Texture is then created and returned.
This may not be most efficient way to return a
Texture for your application. You may want to override this method directly for efficiency.
(method)
| public sealed
| {FillPattern.to-uniform-FillPattern}:FillPattern |
Returns a uniform FillPattern that approximates the value of this FillPattern.
Description
The returned FillPattern should be identical to the FillPattern obtained by calling {FillPattern {Color.from-rgb r, g, b, opacity=opacity}}, where the components are of a Pixel obtained by calling {{self.to-Texture}.to-Pixel} on the original FillPattern.
Note that this may return a new FillPattern even if self.uniform? is true.