Drawmethod: Difference between revisions
Created page with "<!-- Source reviewed: DCurrent/openbor, experiment/gpu-palette-cache, commit 9ed58e87955632714d3c6e561d0c8cf11e685609, 2026-11-28. --> == Introduction == Drawmethod is the collection of settings OpenBOR uses to control an item's appearance when drawing it. Scaling, rotation, mirroring, palette selection, transparency, color effects, texture filtering, surface transforms, and per-pixel drawing depth belong to this system. Creators can author drawmethod settings for anim..." |
No edit summary |
||
| Line 1: | Line 1: | ||
== Introduction == | == Introduction == | ||
| Line 5: | Line 4: | ||
Creators can author drawmethod settings for animation frames or change them through script. Entity drawing, level layers, direct sprite drawing, source screens, and mesh-map artwork use the settings appropriate to their drawing path. One image can therefore appear several times with different sizes, colors, transforms, or depth adjustments. | Creators can author drawmethod settings for animation frames or change them through script. Entity drawing, level layers, direct sprite drawing, source screens, and mesh-map artwork use the settings appropriate to their drawing path. One image can therefore appear several times with different sizes, colors, transforms, or depth adjustments. | ||
=== Main controls === | === Main controls === | ||
| Line 36: | Line 33: | ||
|} | |} | ||
'''Entity and frame settings are not merged property by property.''' When an entity's method is enabled, that method supplies the entire set of settings. Disabling the entity method returns ordinary entity drawing to its current frame settings. New entity methods begin disabled. | '''Entity and frame settings are not merged property by property.''' When an entity's method is enabled, that method supplies the entire set of settings. Disabling the entity method returns ordinary entity drawing to its current frame settings. New entity methods begin disabled. | ||
Most script property setters retain the drawmethod's current enabled state. Enable an entity method before using its settings: | Most script property setters retain the drawmethod's current enabled state. Enable an entity method before using its settings: | ||
| Line 131: | Line 128: | ||
=== Positional form === | === Positional form === | ||
The positional command sets several properties in one line: | |||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
| Line 141: | Line 138: | ||
== Script API == | == Script API == | ||
OpenBOR provides named entity/common access and handle-based property access. Their first arguments identify different kinds of objects. | OpenBOR provides named entity/common access and handle-based property access. Their first arguments identify different kinds of objects. | ||
=== Named properties === | === Named properties === | ||
| Line 194: | Line 191: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
The <code>DM_*</code> names | The <code>DM_*</code> names are shorthand property constants. For example, <code>DM_RESAMPLE</code> and <code>DRAWMETHOD_PROPERTY_RESAMPLE</code> select the same property. These functions expect a drawmethod handle, whereas <code>changedrawmethod()</code> expects an entity pointer or <code>NULL()</code>. | ||
=== Enable and configure === | === Enable and configure === | ||
| Line 290: | Line 287: | ||
| Dot, line, and box functions || Use applicable material settings. Their own blend argument supplies the blend mode; image-specific transforms and filters have no source image to operate on. | | Dot, line, and box functions || Use applicable material settings. Their own blend argument supplies the blend mode; image-specific transforms and filters have no source image to operate on. | ||
|- | |- | ||
| <code>drawstring()</code> and <code>drawstringtoscreen()</code> || Use their font-drawing path. They do not inherit common drawmethod effects | | <code>drawstring()</code> and <code>drawstringtoscreen()</code> || Use their font-drawing path. They do not inherit common drawmethod effects. | ||
|- | |- | ||
| <code>draw_meshmap(..., method, ...)</code> || Uses the supplied method handle. <code>NULL()</code> selects the plain material, so pass the common handle explicitly when that state is wanted. | | <code>draw_meshmap(..., method, ...)</code> || Uses the supplied method handle. <code>NULL()</code> selects the plain material, so pass the common handle explicitly when that state is wanted. | ||
| Line 486: | Line 483: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Match the alpha canvas to the original artwork canvas. Cropping follows the artwork so both images stay aligned. When present, the alpha mask takes precedence over tint, selected blend mode, and channel-opacity controls. Fill still supplies source color before mask composition. | Match the alpha canvas to the original artwork canvas. Cropping follows the artwork so both images stay aligned. When present, the alpha mask takes precedence over tint, selected blend mode, and channel-opacity controls. Fill still supplies source color before mask composition. | ||
== Chroma and Substitute == | == Chroma and Substitute == | ||
| Line 528: | Line 525: | ||
Enabled match colors must be distinct. Enabled replacements cannot equal any enabled match. Disable affected slots before configuring a conflicting arrangement. Substitution applies once to a result; it does not cascade through replacement pairs. | Enabled match colors must be distinct. Enabled replacements cannot equal any enabled match. Disable affected slots before configuring a conflicting arrangement. Substitution applies once to a result; it does not cascade through replacement pairs. | ||
For both systems, one <code>NULL()</code> value disables the selected slot while retaining its stored colors. Black is a valid color. Numeric zero is therefore color data, rather than the disable instruction. | For both systems, one <code>NULL()</code> value disables the selected slot while retaining its stored colors. Black is a valid color. Numeric zero is therefore color data, rather than the disable instruction. | ||
=== Read slot settings === | === Read slot settings === | ||
| Line 553: | Line 550: | ||
== Resampling == | == Resampling == | ||
Resampling determines how an image is reconstructed when a transform samples between its original pixels. One selection applies to scaling, rotation, shear, affine transforms, water, perspective planes, and curves. It is an image-level setting; different objects in one frame can use different filters. | Resampling determines how an image is reconstructed when a transform samples between its original pixels. One selection applies to scaling, rotation, shear, affine transforms, water, perspective planes, and curves. It is an image-level setting; different objects in one frame can use different filters. | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 596: | Line 593: | ||
== Affine transforms == | == Affine transforms == | ||
Affine transforms combine scale, rotation, shear, and translation in six coefficients. They are useful when one image needs a precise combined transform, such as a leaning panel, a rotated sign, or artwork positioned on a projected surface. | Affine transforms combine scale, rotation, shear, and translation in six coefficients. They are useful when one image needs a precise combined transform, such as a leaning panel, a rotated sign, or artwork positioned on a projected surface. | ||
=== Script API === | === Script API === | ||
| Line 722: | Line 719: | ||
== Curves == | == Curves == | ||
Curve transforms bend an image into a surface, then apply tilt and projection. They support in-plane turns, curved panels, columns, and concentrated horizon rolls. Shape and texture scrolling have separate controls, allowing a road or belt texture to move across a stable bend. | Curve transforms bend an image into a surface, then apply tilt and projection. They support in-plane turns, curved panels, columns, and concentrated horizon rolls. Shape and texture scrolling have separate controls, allowing a road or belt texture to move across a stable bend. | ||
=== Script API === | === Script API === | ||
| Line 790: | Line 787: | ||
== Drawing depth == | == Drawing depth == | ||
Depth companions give each source pixel a drawing-Z adjustment. The GPU adds that adjustment to the draw's existing Z before deciding which covered pixel appears in front. Greater final drawing Z takes priority; at equal depth, later drawing retains priority. | Depth companions give each source pixel a drawing-Z adjustment. The GPU adds that adjustment to the draw's existing Z before deciding which covered pixel appears in front. Greater final drawing Z takes priority; at equal depth, later drawing retains priority. | ||
For example, a wall sprite can contain a far portion that actors draw over and a near portion that draws over actors. The image carries both relationships in its depth companion. The same approach works with mesh-map artwork. | For example, a wall sprite can contain a far portion that actors draw over and a near portion that draws over actors. The image carries both relationships in its depth companion. The same approach works with mesh-map artwork. | ||
| Line 839: | Line 836: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Optional arguments can be omitted from the end. Use <code>none</code> in the alpha position when supplying depth alone. Explicit alpha arguments, including <code>none</code>, take precedence over a pending | Optional arguments can be omitted from the end. Use <code>none</code> in the alpha position when supplying depth alone. Explicit alpha arguments, including <code>none</code>, take precedence over a pending <code>alphamask</code> declaration. Omitting the alpha argument retains that declaration's behavior. | ||
=== Script-loaded sprites and screens === | === Script-loaded sprites and screens === | ||
| Line 996: | Line 993: | ||
# Repetition places complete transformed copies, and clipping restricts destination coverage. | # Repetition places complete transformed copies, and clipping restricts destination coverage. | ||
Palette lookup, source transparency, and Chroma determine source color and coverage. Resampling reconstructs those values at the transformed source coordinates. Fill, tint, blending, and opacity then compose the result according to their material rules. Substitute examines the final RGB result. Depth companions supply a separate drawing-Z adjustment at the final artwork coordinates. | Palette lookup, source transparency, and Chroma determine source color and coverage. Resampling reconstructs those values at the transformed source coordinates. Fill, tint, blending, and opacity then compose the result according to their material rules. Substitute examines the final RGB result. Depth companions supply a separate drawing-Z adjustment at the final artwork coordinates. | ||
For example, a curved sign can use a palette swap, Mitchell resampling, a Chroma slot, and a depth companion together. Its curve determines the surface, the filter determines color reconstruction, and the companion determines which covered portions appear in front of other drawing. | For example, a curved sign can use a palette swap, Mitchell resampling, a Chroma slot, and a depth companion together. Its curve determines the surface, the filter determines color reconstruction, and the companion determines which covered portions appear in front of other drawing. | ||
| Line 1,007: | Line 1,004: | ||
* [[Animation Overview]] | * [[Animation Overview]] | ||
* [[Time]] | * [[Time]] | ||
[[Category:Openbor]] | [[Category:Openbor]] | ||
[[Category:Graphics]] | [[Category:Graphics]] | ||
[[Category:Script]] | [[Category:Script]] | ||
Revision as of 18:18, 28 November 2026
Introduction
Drawmethod is the collection of settings OpenBOR uses to control an item's appearance when drawing it. Scaling, rotation, mirroring, palette selection, transparency, color effects, texture filtering, surface transforms, and per-pixel drawing depth belong to this system.
Creators can author drawmethod settings for animation frames or change them through script. Entity drawing, level layers, direct sprite drawing, source screens, and mesh-map artwork use the settings appropriate to their drawing path. One image can therefore appear several times with different sizes, colors, transforms, or depth adjustments.
Main controls
- Size, orientation, and placement - Scale, rotate, mirror, or shear an image around its drawing point.
- Repetition and clipping - Place repeated copies or restrict the visible destination area.
- Color and transparency - Select palettes, fill or tint artwork, and control blending and opacity.
- Chroma and Substitute - Remove selected source colors or replace selected final colors.
- Resampling - Choose how transformed artwork is reconstructed between source pixels.
- Affine transforms, water and perspective planes, and curves - Build more complex image and surface transformations.
- Drawing depth - Let different parts of one image draw in front of or behind other items.
Selecting a drawmethod
Drawmethod settings belong to particular drawing contexts. Selecting the correct context is the first step in using them.
| Context | How it is selected | Behavior |
|---|---|---|
| Animation frame | Model-file drawmethod commands |
Settings are recorded with subsequent frames in the current animation. |
| Entity | changedrawmethod(entity, ...), or the entity's drawmethod handle |
When enabled, the entity drawmethod replaces the complete frame drawmethod for ordinary entity rendering. |
| Common script state | changedrawmethod(NULL(), ...), or the common drawmethod handle |
Supplies settings to direct image drawing functions that use common state. |
| Explicit handle | Drawmethod parameter accepted by the drawing function | Uses the selected method. For example, mesh drawing accepts a drawmethod handle. |
| Level layer | Layer configuration and its native drawing preparation | Layer drawing supplies its own placement, repetition, palette, and other contextual settings. |
Entity and frame settings are not merged property by property. When an entity's method is enabled, that method supplies the entire set of settings. Disabling the entity method returns ordinary entity drawing to its current frame settings. New entity methods begin disabled.
Most script property setters retain the drawmethod's current enabled state. Enable an entity method before using its settings:
void entity = getlocalvar("self");
changedrawmethod(entity, "enabled", 1);
changedrawmethod(entity, "scalex", 384);
changedrawmethod(entity, "scaley", 384);Common script state begins with the enabled default method. Changes persist until another script changes or resets them. Keep a drawing routine's settings contained so later drawing receives the intended state.
Model authoring
Place named drawmethod commands before the frames they should affect. Each command changes the named setting and enables the frame method. Settings continue into subsequent frames of the same animation until changed. Starting another anim restores the authoring defaults.
anim idle
delay 8
offset 24 64
drawmethod scale 1.5
frame data/chars/example/idle0.png
frame data/chars/example/idle1.png
drawmethod scale 1.0
frame data/chars/example/idle2.pngThe first two frames use 150% scale. The third restores ordinary scale. Commands change individual settings, so changing scale leaves previously selected rotation, tint, and other settings in place.
Disable frame effects
nodrawmethod
frame data/chars/example/idle3.pngnodrawmethod disables the frame method without clearing its stored settings. Later drawmethod commands enable those settings again. Enabled entity drawmethods still take precedence over their frames.
Supported named commands
| Command | Values |
|---|---|
drawmethod scale x [y] |
Scale multipliers. Omitted Y uses X. |
drawmethod scalex valuedrawmethod scaley value |
Separate scale multipliers. |
drawmethod flipx valuedrawmethod flipy valuedrawmethod fliprotate value |
Boolean switches: 0 or 1. |
drawmethod rotate degrees |
Rotation angle. |
drawmethod shiftx value |
Horizontal shear multiplier. |
drawmethod xrepeat countdrawmethod yrepeat count |
Number of copies along each drawing axis. |
drawmethod xspan pixelsdrawmethod yspan pixels |
Distance between consecutive drawing positions. |
drawmethod clip x y width height |
Clipping rectangle. |
drawmethod alpha modedrawmethod tintmode mode |
Integer blend selectors from the blend-mode table. |
drawmethod fillcolor R_G_Bdrawmethod tintcolor R_G_B |
Color components separated by underscores. |
drawmethod channel red [green [blue]] |
Channel-opacity factors, normally 0.0 through 1.0. Each omitted channel uses red. |
drawmethod channelr valuedrawmethod channelg valuedrawmethod channelb value |
Separate channel-opacity factors. |
drawmethod remap index |
Entity palette selection; -1 inherits the current selection. |
drawmethod depthrange adjust_0 adjust_65535drawmethod depthrange inherit |
Override or inherit the depth companion's adjustment range. |
Center offsets, water controls, affine transforms, curves, resampling, Chroma, and Substitute use the script interfaces documented in their sections. The model-file command does not accept arbitrary script property names.
Text and script units
| Setting | Model text | Script property | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Normal scale | 1.0 |
256
|
Half scale | 0.5 |
128
|
Double scale | 2.0 |
512
|
Unit horizontal shear | 1.0 |
256
|
Channel opacity | Factor from 0.0 through 1.0 | Integer byte from 0 through 255 | RGB color | For example, 255_128_0 |
rgbcolor(255, 128, 0)
|
Rotation uses degrees, and pixel offsets use pixels. Depth-range endpoints use drawing-Z units in both interfaces.
Positional form
The positional command sets several properties in one line:
drawmethod scalex scaley flipx flipy shiftx alpha remap fillcolor rotate fliprotateThis form uses stored integer scale and shear units, with 256 representing normal scale. The named commands above make individual changes easier to read and maintain.
Script API
OpenBOR provides named entity/common access and handle-based property access. Their first arguments identify different kinds of objects.
Named properties
changedrawmethod(entity_or_NULL, "property", value);
getdrawmethod(entity_or_NULL, "property");Use an entity pointer to change its method. Use NULL() to change common script state. Some properties accept several values, such as clip, affine, curve, and depthrange. Entity getters read the entity override's stored settings, rather than resolving the frame method currently selected for drawing.
changedrawmethod(NULL(), "enabled", 1);
changedrawmethod(NULL(), "rotate", 30);
int angle = getdrawmethod(NULL(), "rotate");
drawsprite(sprite, 160, 120, 100);Boolean-style getters can return a nonzero flag value. Test the result as true or false rather than requiring it to equal 1.
Drawmethod handles
void common = openborvariant("drawmethod_common");
void defaults = openborvariant("drawmethod_default");
void entity_method = get_entity_property(
entity, openborconstant("ENTITY_PROPERTY_DRAWMETHOD")
);These are borrowed handles to existing methods. The common handle points to live shared state. The default handle is read only. Retaining either handle does not create a saved copy of its settings.
Handle-based access uses named property constants:
set_drawmethod_property(
entity_method, openborconstant("DRAWMETHOD_PROPERTY_SCALE_X"), 384
);
int scale_x = get_drawmethod_property(
entity_method, openborconstant("DRAWMETHOD_PROPERTY_SCALE_X")
);The convenience functions accept a drawmethod handle or NULL() for common state:
set_draw_method(method_or_NULL, property_constant, value);
get_draw_method(method_or_NULL, property_constant);The DM_* names are shorthand property constants. For example, DM_RESAMPLE and DRAWMETHOD_PROPERTY_RESAMPLE select the same property. These functions expect a drawmethod handle, whereas changedrawmethod() expects an entity pointer or NULL().
Enable and configure
Use named configuration flags when working through a handle. Preserve existing flags when enabling one feature:
int config = get_drawmethod_property(
entity_method, openborconstant("DRAWMETHOD_PROPERTY_CONFIG")
);
config = config | openborconstant("DRAWMETHOD_CONFIG_ENABLED");
set_drawmethod_property(
entity_method, openborconstant("DRAWMETHOD_PROPERTY_CONFIG"), config
);| Script constant | Purpose |
|---|---|
DRAWMETHOD_CONFIG_NONE |
Clear the configuration flags. |
DRAWMETHOD_CONFIG_ENABLED |
Apply the method's settings. |
DRAWMETHOD_CONFIG_BACKGROUND_TRANSPARENCY |
Request zero-key transparency for source screens and applicable layer drawing. |
DRAWMETHOD_CONFIG_FLIP_XDRAWMETHOD_CONFIG_FLIP_Y |
Mirror the corresponding source axis. |
DRAWMETHOD_CONFIG_FLIP_ROTATE |
Reverse ordinary entity rotation when facing left. |
DRAWMETHOD_CONFIG_CURVE |
Select the stored curve transform. Curve setters also manage this feature flag. |
The named enabled, flipx, flipy, fliprotate, transbg, affineenabled, and curveenabled properties provide direct control without assembling configuration flags.
Copy and reset
// Destination first, source second.
copy_drawmethod(target_method, source_method);
// Restore every common setting to the engine defaults.
copy_drawmethod(
openborvariant("drawmethod_common"),
openborvariant("drawmethod_default")
);
// Named equivalent for an enabled default method.
changedrawmethod(NULL(), "reset", 1);Reset with a nonzero value restores normal scale, one copy, nearest resampling, inherited depth endpoints, and the other default values. Passing 0 leaves the method unchanged. To restore defaults and then disable the method, use reset with 1 followed by enabled with 0. reset is an action, not a readable scalar property.
Resetting an entity to enabled defaults makes its method take precedence over its frames. Use changedrawmethod(entity, "enabled", 0) when the intended result is to resume frame-controlled effects.
Contain temporary changes
Queued image draws retain the drawmethod values selected when submitted. Drawing routines can restore shared state immediately after adding their draws to the queue. Referenced artwork and palette handles must remain valid for the pending drawing.
int saved_config = get_draw_method(
NULL(), openborconstant("DRAWMETHOD_PROPERTY_CONFIG")
);
int saved_x = getdrawmethod(NULL(), "scalex");
int saved_y = getdrawmethod(NULL(), "scaley");
changedrawmethod(NULL(), "enabled", 1);
changedrawmethod(NULL(), "scalex", 512);
changedrawmethod(NULL(), "scaley", 512);
drawsprite(sprite, 160, 120, 100);
changedrawmethod(NULL(), "scalex", saved_x);
changedrawmethod(NULL(), "scaley", saved_y);
set_draw_method(
NULL(), openborconstant("DRAWMETHOD_PROPERTY_CONFIG"), saved_config
);Save every setting the routine changes. This example preserves an existing method while changing only scale and its general enable state. Full reset is appropriate when the routine deliberately owns the entire common drawing setup.
Drawing functions and common state
| Drawing call | Drawmethod behavior |
|---|---|
drawsprite(sprite, x, y, z [, sort_id]) |
Copies common state into the queued image draw. |
drawscreen(screen, x, y, z) |
Copies common state into the queued screen draw. |
drawscreen(screen, x, y, z, blend) |
Builds a plain method with the supplied blend and background transparency. Use the four-argument form to keep common transforms and other overrides. |
drawspritetoscreen(sprite, screen, x, y) |
Uses common state for an immediate image draw. |
| Dot, line, and box functions | Use applicable material settings. Their own blend argument supplies the blend mode; image-specific transforms and filters have no source image to operate on. |
drawstring() and drawstringtoscreen() |
Use their font-drawing path. They do not inherit common drawmethod effects. |
draw_meshmap(..., method, ...) |
Uses the supplied method handle. NULL() selects the plain material, so pass the common handle explicitly when that state is wanted.
|
See Direct Drawing for drawing-function arguments and resource management.
Size, orientation, and placement
Scale
scalex and scaley change the drawn width and height. Script values use 256 units for original size:
changedrawmethod(entity, "enabled", 1);
changedrawmethod(entity, "scalex", 384); // 150% width.
changedrawmethod(entity, "scaley", 128); // 50% height.The handle properties are DRAWMETHOD_PROPERTY_SCALE_X and DRAWMETHOD_PROPERTY_SCALE_Y. Both default to 256. Zero ordinary scale hides the image. Use positive script scales with explicit flip properties for mirroring.
Model text accepts multipliers. Negative text scales become positive magnitudes and toggle the corresponding flip flag. Script scale setters do not perform that conversion.
Rotation and mirroring
changedrawmethod(entity, "rotate", 45);
changedrawmethod(entity, "flipx", 1);
changedrawmethod(entity, "fliprotate", 1);Ordinary positive rotation turns clockwise around the drawing pivot when no flip is applied. flipx mirrors horizontally, and flipy mirrors vertically. Entity facing also contributes to the final horizontal orientation. fliprotate reverses ordinary entity rotation when the entity faces left.
Rotation defaults to zero degrees. The ordinary rotation path uses whole-degree angles. The handle property is DRAWMETHOD_PROPERTY_ROTATE.
Drawing pivot
centerx and centery add source-pixel offsets to the drawing pivot. Sprite drawing includes the sprite's authored center. Source screens have their intrinsic center at the upper-left corner.
For example, place a source screen around its center before rotating it:
changedrawmethod(NULL(), "reset", 1);
changedrawmethod(NULL(), "centerx", getgfxproperty(surface, "width") / 2);
changedrawmethod(NULL(), "centery", getgfxproperty(surface, "height") / 2);
changedrawmethod(NULL(), "rotate", 20);
drawscreen(surface, 320, 180, 100);
changedrawmethod(NULL(), "reset", 1);The handle properties are DRAWMETHOD_PROPERTY_CENTER_X and DRAWMETHOD_PROPERTY_CENTER_Y. Both offsets default to zero.
Horizontal shear
shiftx leans the image by shifting successive rows horizontally. Its script value uses 256 units per unit shear:
changedrawmethod(entity, "shiftx", 64);The corresponding model command is drawmethod shiftx 0.25. Use the named script property for this control. Ordinary rotation takes precedence over this shear; affine can combine rotation and shear in one matrix.
Repetition and clipping
Repetition
xrepeat and yrepeat specify the number of copies, including the first image. xspan and yspan specify the difference between consecutive drawing positions in destination pixels.
changedrawmethod(NULL(), "reset", 1);
changedrawmethod(NULL(), "xrepeat", 3);
changedrawmethod(NULL(), "xspan", 48);
drawsprite(icon, 80, 60, 1000);
changedrawmethod(NULL(), "reset", 1);This places three copies at X positions 80, 128, and 176. The span is the entire position step. Include the image's drawn width when calculating a step that should leave a gap between copies. Zero span places copies on top of each other.
Ordinary image methods default to one copy along each axis and zero spans. Their nonpositive repeat counts draw nothing. Each copy uses its own shifted drawing point, while the repeat grid remains aligned to the destination axes. Scaling or rotating the artwork does not scale or rotate the span distances.
Native level-layer declarations have a separate negative-repeat convention, usually written as -1. The layer loader expands it into a large tiled region, and layer drawing submits the copies needed for the current viewport. Their step comes from the image dimensions plus layer spacing. Assigning a negative repeat count through a runtime layer property does not repeat that loading conversion; use a positive runtime count.
The handle properties are DRAWMETHOD_PROPERTY_REPEAT_X, DRAWMETHOD_PROPERTY_REPEAT_Y, DRAWMETHOD_PROPERTY_SPAN_X, and DRAWMETHOD_PROPERTY_SPAN_Y.
Clipping
Clipping restricts the destination area in which an image may appear. It is useful for interface windows, gauges, portraits, and animated reveals.
changedrawmethod(NULL(), "reset", 1);
changedrawmethod(NULL(), "clip", 40, 30, 160, 90);
drawsprite(sprite, 80, 70, 1000);
changedrawmethod(NULL(), "reset", 1);Direct image drawing uses destination-screen pixels. Entity-method clipping uses offsets from the entity's projected drawing point. Model-frame clipping is authored relative to the original frame canvas; loading adjusts it by that frame's offset.
Both width and height must be positive to activate the rectangle. Read or change individual values through clipx, clipy, clipw, and cliph. The aggregate clip name is a four-value setter.
Handle properties are DRAWMETHOD_PROPERTY_CLIP_POSITION_X, DRAWMETHOD_PROPERTY_CLIP_POSITION_Y, DRAWMETHOD_PROPERTY_CLIP_SIZE_X, and DRAWMETHOD_PROPERTY_CLIP_SIZE_Y. All four stored defaults are zero.
Color and transparency
Colors and palettes
Use rgbcolor(red, green, blue) to construct script colors. Model color commands accept underscore-separated components:
drawmethod fillcolor 255_192_64changedrawmethod(entity, "fillcolor", rgbcolor(255, 192, 64));fillcolor fills covered artwork with one color. Its default value, zero, disables the fill. Consequently, packed black from rgbcolor(0, 0, 0) also disables this particular control.
remap selects an entity palette by index. Its default, -1, inherits the entity's current palette selection. Zero requests the model's default palette, and positive values select alternate palettes. table supplies an explicit palette or color-table pointer; retain the lifetime of the palette being referenced.
Handle properties are DRAWMETHOD_PROPERTY_FILL_COLOR, DRAWMETHOD_PROPERTY_COLORSET_INDEX, and DRAWMETHOD_PROPERTY_COLORSET_TABLE.
Blend modes
The alpha property selects a blending operation. It is a mode selector, not a general opacity percentage.
| Script constant | Model-text value | Effect |
|---|---|---|
BLEND_MODE_MODEL |
-1 | Inherit the model's blend mode during entity rendering. This is the default alpha setting. |
BLEND_MODE_NONE |
0 | Apply ordinary source color, subject to its coverage. |
BLEND_MODE_ALPHA |
1 | Screen-style brightening. |
BLEND_MODE_ALPHA_NEGATIVE |
2 | Multiply-style darkening. |
BLEND_MODE_OVERLAY |
3 | Combine multiply and screen behavior according to the destination color. |
BLEND_MODE_HARDLIGHT |
4 | Combine multiply and screen behavior according to the source color. |
BLEND_MODE_DODGE |
5 | Brighten the destination with source-controlled color dodge. |
BLEND_MODE_AVERAGE |
6 | Average source and destination; also supports channel opacity under the conditions below. |
Model text uses the integer selectors in this table. Scripts use the named constants:
changedrawmethod(entity, "enabled", 1);
changedrawmethod(entity, "alpha", openborconstant("BLEND_MODE_ALPHA"));The handle property is DRAWMETHOD_PROPERTY_ALPHA.
Tint
tintcolor supplies a color to blend with the artwork, and tintmode selects that operation. Tint mode defaults to BLEND_MODE_NONE. Select an actual blend operation for a visible tint; model inheritance is an alpha setting rather than a tint operation.
changedrawmethod(entity, "tintcolor", rgbcolor(64, 160, 255));
changedrawmethod(entity, "tintmode", openborconstant("BLEND_MODE_AVERAGE"));Handle properties are DRAWMETHOD_PROPERTY_TINT_COLOR and DRAWMETHOD_PROPERTY_TINT_MODE.
Channel opacity
channelr, channelg, and channelb control the contribution of each source channel to the destination. Script values are integer bytes, normally 0 through 255. Use the named script setters for these controls.
Channel opacity applies when the image has no alpha mask, tint is disabled, and alpha is BLEND_MODE_AVERAGE. At least one channel must be below 255. When all three are 255, average mode uses its ordinary half-source, half-destination operation.
changedrawmethod(entity, "enabled", 1);
changedrawmethod(entity, "tintmode", openborconstant("BLEND_MODE_NONE"));
changedrawmethod(entity, "alpha", openborconstant("BLEND_MODE_AVERAGE"));
changedrawmethod(entity, "channelr", 128);
changedrawmethod(entity, "channelg", 128);
changedrawmethod(entity, "channelb", 128);This produces approximately half opacity for an image without an alpha mask. Values of 254 provide near-opaque channel weighting without selecting the all-255 averaging case.
Image transparency and alpha masks
Sprite index zero supplies transparent coverage. Source screens can request zero-key transparency through transbg; the plain drawmethod leaves this switch off.
Alpha companions supply per-pixel opacity. Each is an 8-bit indexed image whose stored byte values supply opacity directly. The palette's displayed colors do not substitute for those byte values. Lower values increase transparency, and higher values increase the artwork's contribution.
frame data/props/wall.png data/props/wall_alpha.pngvoid sprite = loadsprite("data/props/wall.png", "data/props/wall_alpha.png");Match the alpha canvas to the original artwork canvas. Cropping follows the artwork so both images stay aligned. When present, the alpha mask takes precedence over tint, selected blend mode, and channel-opacity controls. Fill still supplies source color before mask composition.
Chroma and Substitute
Each drawmethod has five Chroma slots and five Substitute pairs, named A through E. All slots begin disabled. These controls use script APIs.
Chroma
Chroma turns matching source colors transparent. Matching uses the exact source RGB after palette lookup and before fill, tint, and filtering.
changedrawmethod(NULL(), "enabled", 1);
set_draw_method(NULL(), openborconstant("DM_CHROMA_KEY_A"),
rgbcolor(255, 0, 255));
drawscreen(surface, 0, 0, 100);
set_draw_method(NULL(), openborconstant("DM_CHROMA_KEY_A"), NULL());This keys magenta source pixels for the queued draw and then disables that slot for subsequent draws. The example assumes the routine owns this slot; save its old color and enable state when preserving another routine's configuration.
The other slots are DM_CHROMA_KEY_B through DM_CHROMA_KEY_E. Named equivalents are chromakeya through chromakeye.
Substitute
Substitute replaces an exact final RGB result after material processing, blending, and quantization. It can therefore match colors created by those operations.
changedrawmethod(NULL(), "enabled", 1);
set_draw_method(NULL(), openborconstant("DM_SUBSTITUTE_A"),
rgbcolor(255, 255, 255), rgbcolor(255, 192, 64));
drawscreen(surface, 0, 0, 100);
set_draw_method(NULL(), openborconstant("DM_SUBSTITUTE_A"), NULL());Each setter supplies the complete match/replacement pair. The other slots are DM_SUBSTITUTE_B through DM_SUBSTITUTE_E, with named equivalents substitutea through substitutee.
Enabled match colors must be distinct. Enabled replacements cannot equal any enabled match. Disable affected slots before configuring a conflicting arrangement. Substitution applies once to a result; it does not cascade through replacement pairs.
For both systems, one NULL() value disables the selected slot while retaining its stored colors. Black is a valid color. Numeric zero is therefore color data, rather than the disable instruction.
Read slot settings
| Component constant | Result |
|---|---|
DM_COLOR_MATCH |
Stored key or match color. This is the default getter component. |
DM_COLOR_SUBSTITUTE |
Stored replacement color for a Substitute slot. |
DM_COLOR_ENABLED |
Whether the individual slot is enabled. |
int active = get_draw_method(
NULL(), openborconstant("DM_SUBSTITUTE_A"),
openborconstant("DM_COLOR_ENABLED")
);The long-form property names use DRAWMETHOD_PROPERTY_CHROMA_KEY_* and DRAWMETHOD_PROPERTY_SUBSTITUTE_* with the same slot letters.
Resampling
Resampling determines how an image is reconstructed when a transform samples between its original pixels. One selection applies to scaling, rotation, shear, affine transforms, water, perspective planes, and curves. It is an image-level setting; different objects in one frame can use different filters.
| Constant | Character |
|---|---|
DC_RESAMPLE_NEAREST |
Default. Selects source pixels directly for crisp pixel boundaries. |
DC_RESAMPLE_BILINEAR |
Linear interpolation between neighboring pixels. |
DC_RESAMPLE_BICUBIC_CATMULL_ROM |
Sharper cubic reconstruction. |
DC_RESAMPLE_BICUBIC_MITCHELL |
Balanced cubic reconstruction. |
DC_RESAMPLE_BICUBIC_BSPLINE |
Softer cubic reconstruction. |
DC_RESAMPLE_LANCZOS_2 |
Windowed sinc reconstruction with a two-pixel radius. |
DC_RESAMPLE_LANCZOS_3 |
Windowed sinc reconstruction with a three-pixel radius. |
DC_RESAMPLE_MOVIE |
Alias of bilinear. |
Script API
changedrawmethod(NULL(), "enabled", 1);
set_draw_method(NULL(), openborconstant("DM_RESAMPLE"),
openborconstant("DC_RESAMPLE_BICUBIC_MITCHELL"));
drawsprite(sprite, 160, 120, 100);
set_draw_method(NULL(), openborconstant("DM_RESAMPLE"),
openborconstant("DC_RESAMPLE_NEAREST"));The named property is resample. The long-form constant is DRAWMETHOD_PROPERTY_RESAMPLE. Setters require one defined integer selector. Reset restores nearest.
Palette indices resolve to colors before filtering. Chroma and opacity also contribute to reconstruction, so invisible source colors do not bleed into visible neighbors. Depth companions keep separate nearest numeric sampling.
Sharper filters can emphasize high-contrast edges; softer filters can suit smooth artwork. Per-object resampling operates while the object is drawn, whereas a video output filter processes the composed display.
Affine transforms
Affine transforms combine scale, rotation, shear, and translation in six coefficients. They are useful when one image needs a precise combined transform, such as a leaning panel, a rotated sign, or artwork positioned on a projected surface.
Script API
changedrawmethod(entity_or_NULL, "affine", m00, m01, m10, m11, tx, ty);The mapping is:
destination_x = draw_x + tx + m00 * local_x + m01 * local_y
destination_y = draw_y + ty + m10 * local_x + m11 * local_yLocal coordinates are measured from the source's complete drawing pivot. Flip settings reflect the appropriate local axes before the matrix is applied.
changedrawmethod(NULL(), "reset", 1);
// Shear horizontally and move the result 12 pixels right, 8 up.
changedrawmethod(NULL(), "affine", 1, 0.4, 0, 1, 12, -8);
drawsprite(sprite, 160, 120, 100);
changedrawmethod(NULL(), "affineenabled", 0);| Named property | Meaning | Default |
|---|---|---|
affine00, affine11 |
Diagonal coefficients | 1, 1 |
affine01, affine10 |
Cross-axis coefficients | 0, 0 |
affinex, affiney |
Translation in destination pixels | 0, 0 |
affineenabled |
Enable the stored matrix | 0 |
The aggregate setter validates all six coefficients before replacing them. Setting an individual coefficient also enables affine geometry. The general drawmethod enable flag still applies. Reading affine returns the feature's enable state.
When affine is enabled, its matrix supplies the scale, rotation, and shear that ordinary geometry would otherwise provide. Include the intended scale or rotation in the matrix itself. Singular matrices produce no drawable area. Disabling affine retains its coefficients for later use.
Water and perspective planes
Water controls provide row-based image transformations. The sine mode is useful for ripples and heat distortion. The shear mode changes row sampling to create a receding, textured plane.
Modes and properties
| Named property | Purpose |
|---|---|
watermode |
Select WATER_MODE_NONE, WATER_MODE_SINE, or WATER_MODE_SHEAR.
|
amplitude |
Horizontal wave displacement magnitude in pixels. |
wavelength |
Positive source-pixel distance for a complete wave. |
wavespeed |
Multiplier used when setting named wavetime.
|
wavetime |
Wave phase, or horizontal texture phase for the perspective plane. |
beginsize |
Positive texture scale at the plane's top. |
endsize |
Nonnegative texture scale toward the plane's bottom. |
perspective |
Select how source rows advance through the plane. |
Water mode defaults to none, with all stored water parameters zero. Set the parameters required by a mode when enabling it. Switching modes should supply the complete new setup because some parameters share storage.
Animated wave
changedrawmethod(NULL(), "reset", 1);
changedrawmethod(NULL(), "watermode", openborconstant("WATER_MODE_SINE"));
changedrawmethod(NULL(), "amplitude", 6);
changedrawmethod(NULL(), "wavelength", 48.0);
changedrawmethod(NULL(), "wavespeed", 1.0);
changedrawmethod(NULL(), "wavetime", openborvariant("elapsed_time"));
drawscreen(surface, 0, 0, 100);
changedrawmethod(NULL(), "reset", 1);Run the phase update when submitting each displayed frame. Setting wavespeed alone does not advance a common or entity drawmethod. Native level-layer drawing supplies its own time update.
The named wavetime setter stores the supplied value multiplied by wavespeed, converted to an integer. The handle property DRAWMETHOD_PROPERTY_WATER_WAVE_TIME writes the raw stored phase directly.
Perspective plane
changedrawmethod(NULL(), "reset", 1);
changedrawmethod(NULL(), "watermode", openborconstant("WATER_MODE_SHEAR"));
changedrawmethod(NULL(), "beginsize", 0.25);
changedrawmethod(NULL(), "endsize", 2.0);
changedrawmethod(NULL(), "perspective",
openborconstant("WATER_PERSPECTIVE_TILE"));
drawscreen(surface, 0, 0, 100);
changedrawmethod(NULL(), "reset", 1);The plane occupies a source-sized destination rectangle. Changing row scale changes texture sampling within that rectangle, and source coordinates wrap through the texture.
For animated plane scrolling, write its raw texture phase with DRAWMETHOD_PROPERTY_WATER_WAVE_TIME. This preserves the plane's perspective setting. The named wavetime setter's speed multiplier belongs to the sine-wave setup.
set_draw_method(NULL(), openborconstant("DRAWMETHOD_PROPERTY_WATER_WAVE_TIME"),
openborvariant("elapsed_time"));| Perspective constant | Source-row behavior |
|---|---|
WATER_PERSPECTIVE_NONE |
Advance one source row for each destination row. |
WATER_PERSPECTIVE_TILE |
Advance by the reciprocal row scale, matching horizontal texture scaling. |
WATER_PERSPECTIVE_STRETCH |
Use that reciprocal scale adjusted by source height divided by source width. |
Handle properties use DRAWMETHOD_PROPERTY_WATER_MODE, _WATER_PERSPECTIVE, _WATER_SIZE_BEGIN, _WATER_SIZE_END, and _WATER_WAVE_AMPLITUDE, _WATER_WAVE_LENGTH, _WATER_WAVE_SPEED, _WATER_WAVE_TIME, each with the full DRAWMETHOD_PROPERTY prefix.
Curves
Curve transforms bend an image into a surface, then apply tilt and projection. They support in-plane turns, curved panels, columns, and concentrated horizon rolls. Shape and texture scrolling have separate controls, allowing a road or belt texture to move across a stable bend.
Script API
changedrawmethod(entity_or_NULL, "curve",
angle, axis, plane, focus, extent, perspective, tilt,
profile, scrollx, scrolly, wrap);The complete setter takes eleven values. The constant-based equivalent uses DM_CURVE. Setting the complete curve or an individual curve parameter enables the feature. curveenabled explicitly enables or disables the stored curve, while the method's general enabled state remains separate.
changedrawmethod(NULL(), "reset", 1);
changedrawmethod(NULL(), "curve",
120, 0, 90, 0.5, 1, 2, 0,
openborconstant("DC_CURVE_PROFILE_UNIFORM"),
0, 0, openborconstant("DC_CURVE_WRAP_CLIP"));
drawsprite(sprite, 160, 120, 100);
changedrawmethod(NULL(), "curveenabled", 0);Curve properties
| Named property / constant | Meaning | Default and accepted values |
|---|---|---|
curveangleDM_CURVE_ANGLE |
Total bend angle | 0; -180 through 180 degrees |
curveaxisDM_CURVE_AXIS |
Direction along the source image over which the bend develops | 0; -360 through 360 degrees |
curveplaneDM_CURVE_PLANE |
Orientation of the bend plane | 90; -360 through 360 degrees |
curvefocusDM_CURVE_FOCUS |
Bend midpoint as a proportion of the source span | 0.5; -4 through 5 |
curveextentDM_CURVE_EXTENT |
Length of the bending region as a proportion of the source span | 1; 0.01 through 16 |
curveperspectiveDM_CURVE_PERSPECTIVE |
Camera-distance factor relative to the larger source dimension | 0; 0 through 64 |
curvetiltDM_CURVE_TILT |
Surface tilt | 0; -89 through 89 degrees |
curveprofileDM_CURVE_PROFILE |
Distribution of curvature | DC_CURVE_PROFILE_UNIFORM or DC_CURVE_PROFILE_SMOOTH; uniform is default
|
curvescrollxDM_CURVE_SCROLL_XcurvescrollyDM_CURVE_SCROLL_Y |
Texture phase in source pixels | 0; -10000000 through 10000000, fractional values allowed |
curvewrapDM_CURVE_WRAP |
Texture boundary behavior | DC_CURVE_WRAP_CLIP or DC_CURVE_WRAP_REPEAT; clip is default
|
curveenabledDM_CURVE_ENABLED |
Enable or disable the stored curve | 0 or 1; disabled by default |
These shorthand constants also have corresponding DRAWMETHOD_PROPERTY_CURVE_* names. Reading the aggregate curve property returns its enable state.
Choosing a shape
Axis 0 develops the bend across the source width; axis 90 develops it down the source height. Plane 0 creates an in-plane turn, useful for a turning road. Plane 90 bends out of the source plane, useful for a rounded column or horizon roll.
Focus values 0, 0.5, and 1 locate the bend midpoint at the beginning, center, and end of the source span. Extent controls how much of that span contains the bend. Regions outside it continue along the ending tangents.
The uniform profile follows a circular cross-section. The smooth profile concentrates curvature around the focus and eases it toward the ends. Perspective 0 selects orthographic projection. Positive values supply camera distance; greater distance weakens perspective.
Texture scrolling changes which artwork lies on the surface. Positive source-X scrolling moves the visible pattern left. Repeat wrapping repeats the texture through its seams; the geometric surface remains one bend.
Tight in-plane turns can fold across their inner edge. Use a smaller turn angle, a longer extent, or narrower source artwork to keep the surface drawable. Enabled curves can use affine for final placement, as described in Combining effects.
Drawing depth
Depth companions give each source pixel a drawing-Z adjustment. The GPU adds that adjustment to the draw's existing Z before deciding which covered pixel appears in front. Greater final drawing Z takes priority; at equal depth, later drawing retains priority.
For example, a wall sprite can contain a far portion that actors draw over and a near portion that draws over actors. The image carries both relationships in its depth companion. The same approach works with mesh-map artwork.
Companion format and defaults
Use a single-channel, 16-bit grayscale PNG. Match the original sprite canvas, allocated source-screen dimensions, or mesh visual-texture dimensions. Mesh collision-grid dimensions may differ from the visual texture. Sprite cropping preserves alignment with the original companion canvas.
The default mapping is a direct one-to-one adjustment:
adjustment = sample - 32768
final_pixel_z = existing_drawing_z + adjustment| Stored grayscale value | Default drawing-Z adjustment |
|---|---|
| 0 | -32768 |
| 32736 | -32 |
| 32767 | -1 |
| 32768 | 0 |
| 32769 | +1 |
| 32800 | +32 |
| 65535 | +32767 |
Use the exact stored value 32768 for neutral regions under the default mapping. Every sample is valid, including zero. Artwork transparency and alpha masks determine coverage. The geometry-map convention that zero opens a hole does not apply to a depth companion.
Depth sampling follows the artwork's final source coordinates, including cropping, flips, and transforms. It uses nearest numeric sampling independently of the selected color resampling filter. Palette, tint, and color replacement settings preserve these numerical values.
Model frames
frame sprite [alpha_or_none] [depth_or_none]
# Depth companion without a separate alpha image.
frame data/props/wall.png none data/props/wall_depth16.png
# Both companion images.
frame data/props/wall.png data/props/wall_alpha.png data/props/wall_depth16.pngOptional arguments can be omitted from the end. Use none in the alpha position when supplying depth alone. Explicit alpha arguments, including none, take precedence over a pending alphamask declaration. Omitting the alpha argument retains that declaration's behavior.
Script-loaded sprites and screens
void wall = loadsprite(
"data/props/wall.png", NULL(), "data/props/wall_depth16.png"
);
void surface = allocscreen(
320, 180, "data/props/panel_depth16.png"
);loadsprite(sprite_path [, alpha_path_or_NULL [, depth_path_or_NULL]])
allocscreen(width, height [, depth_path_or_NULL])Use NULL() or omit trailing optional arguments when no companion is wanted. The mask belongs to the loaded sprite or allocated screen. Freeing that script-owned object also releases its companion resources.
Drawing into a screen changes its color contents while retaining its authored source mask. That source mask is distinct from the transient depth buffer used when the screen itself is a drawing destination.
Mesh maps
meshmap_index 0 0 0 2
meshmap_texture data/terrain/wall.png
meshmap_depth -24 24 data/terrain/wall_depth16.pngmeshmap_depth operates on the current authoring index. Its first two values assign the drawing-Z adjustments for stored samples 0 and 65535. The mesh's existing meshmap_layer supplies the baseline drawing Z. Use meshmap_depth none to remove its companion.
Override the adjustment range
depthrange replaces both endpoints for a particular draw:
drawmethod depthrange -48 48
drawmethod depthrange inheritchangedrawmethod(entity, "enabled", 1);
changedrawmethod(entity, "depthrange", -48.0, 48.0);
// Resume the companion's authored or default mapping.
changedrawmethod(entity, "depthrange", NULL());The constant-based property is DM_DEPTH_RANGE, also named DRAWMETHOD_PROPERTY_DEPTH_RANGE:
changedrawmethod(NULL(), "enabled", 1);
set_draw_method(NULL(), openborconstant("DM_DEPTH_RANGE"), -16.0, 16.0);
drawsprite(wall, 160, 80, 200);
set_draw_method(NULL(), openborconstant("DM_DEPTH_RANGE"), 16.0, -16.0);
drawsprite(wall, 320, 80, 200);
set_draw_method(NULL(), openborconstant("DM_DEPTH_RANGE"), NULL());These two queued draws retain different mappings of the same companion. Range changes update draw parameters while the image remains available for reuse.
With a custom pair, the adjustment is:
adjustment = adjust_0 + (sample / 65535.0) * (adjust_65535 - adjust_0)The effective pair comes from the active drawmethod override, then the asset's authored pair, then the default pair -32768 and 32767. Overrides replace the pair rather than adding another range on top of it.
| Range selection | Result |
|---|---|
inherit, or script NULL() |
Use the companion's authored or default pair. |
0, 0 |
Flatten the companion's depth contribution. |
| Equal nonzero endpoints | Apply a constant adjustment to all covered source pixels. |
| Reversed endpoints | Reverse which sample values receive the nearer adjustment. |
| No depth companion | Apply no per-pixel adjustment. |
Endpoints may be finite signed integers or decimals. Both are validated before either changes. Neutral sample 32768 is exact for the default mapping; a custom pair follows its own interpolation formula.
Read depth settings
| Getter component | Result |
|---|---|
DM_DEPTH_SAMPLE_0 |
First override endpoint, or NULL() while inheriting. This is the default component.
|
DM_DEPTH_SAMPLE_65535 |
Second override endpoint, or NULL() while inheriting.
|
DM_DEPTH_INHERIT |
1 while inheriting, 0 while overriding. |
int inherited = get_draw_method(
NULL(), openborconstant("DM_DEPTH_RANGE"),
openborconstant("DM_DEPTH_INHERIT")
);Queued composition
Ordinary queued sprites, screens, and mesh artwork use depth composition automatically when a companion is present. Ordinary overlapping draws participate with their existing drawing Z and zero adjustment.
Queue submission order remains based on submitted Z, then sort ID, then insertion order for equal keys. Per-pixel comparisons determine visibility within the depth composition. Queue layer-range filters continue to use submitted base Z.
Opaque and fully covered cutout pixels test and write depth. Zero-coverage pixels leave color and depth untouched. Partially covered or blended pixels test depth without writing it and retain ordered composition.
Immediate composition
Scripts that combine several immediate draws into one screen can begin an explicit depth pass:
begin_draw_depth(target_screen, minimum_z, maximum_z)
set_draw_depth(drawing_z)
end_draw_depth(target_screen)Choose bounds that contain every final drawing Z, including companion adjustments. Both bounds must be finite, and the minimum must be less than the maximum.
For example, with the wall's configured layer and all companion-adjusted depths inside 100 through 400:
if(begin_draw_depth(surface, 100.0, 400.0)) {
draw_meshmap(maps, wall_id, surface, NULL(), 0, 0);
set_draw_depth(220.0);
drawspritetoscreen(actor_sprite, surface, actor_x, actor_y);
end_draw_depth(surface);
}Immediate mesh draws select their current mesh layer. Other immediate draws use the baseline selected by set_draw_depth(). Beginning a pass clears that target's transient depth while preserving its color and initially selects drawing Z zero.
Passes are target-specific and non-nested. Queued drawing into the active target can join the pass without clearing or ending it. The three functions return 1 for success or 0 when the requested pass operation is unavailable or mismatched; malformed arguments report an error.
Combining effects
Drawmethod controls share one drawing operation, but several geometry modes select different paths. Use the following order when combining them:
- Enabled curve builds the surface, then applies its tilt and projection.
- Enabled affine places that projected curve. Without affine, curve placement uses ordinary scale and rotation, or shear when rotation is zero.
- Without a curve, enabled affine supplies the geometry.
- Otherwise, water or perspective-plane geometry takes precedence over ordinary rotation and shear.
- Ordinary rotation takes precedence over ordinary
shiftx; scale still participates. - Repetition places complete transformed copies, and clipping restricts destination coverage.
Palette lookup, source transparency, and Chroma determine source color and coverage. Resampling reconstructs those values at the transformed source coordinates. Fill, tint, blending, and opacity then compose the result according to their material rules. Substitute examines the final RGB result. Depth companions supply a separate drawing-Z adjustment at the final artwork coordinates.
For example, a curved sign can use a palette swap, Mitchell resampling, a Chroma slot, and a depth companion together. Its curve determines the surface, the filter determines color reconstruction, and the companion determines which covered portions appear in front of other drawing.