Drawing
Comprehensive guide to drawing operations on images using BoxLang's image manipulation module.
Learn how to draw shapes, lines, curves, and text on images in BoxLang.
Table of Contents
Setup & Configuration
Before drawing, configure colors, strokes, and rendering options:
Set Drawing Color
// Named color
img = ImageNew(400, 300, "rgb", "white");
img.setDrawingColor("red");
// Hex color
img.setDrawingColor("#FF0000");Supported Colors: black, blue, cyan, darkgray, gray, green, lightgray, magenta, orange, pink, red, white, yellow
Set Background Color
Configure Stroke (Line Style)
Stroke Properties:
width - Line thickness in pixels
endCaps - How line ends are drawn
lineJoins - How line corners are drawn
miterLimit - Miter join limit
dashArray - Dash pattern (on, off, on, off...)
dashPhase - Offset for dash pattern
Set Transparency
Enable Anti-Aliasing
Drawing Shapes
Draw Rectangle
BIF Syntax:
Draw Rounded Rectangle
Draw Beveled Rectangle (3D Effect)
Draw Oval/Circle
Clear Rectangle
Drawing Lines
Draw Single Line
Draw Multiple Lines (Polyline)
Draw Polygon
Draw Single Point
Draw Arc
Angles:
0° = 3 o'clock position
90° = 12 o'clock position
Positive angles go counter-clockwise
Drawing Curves
Quadratic Bézier Curve
Cubic Bézier Curve
Drawing Text
Simple Text
Styled Text
Font Configuration:
font - Font family name (e.g., "Arial", "Times New Roman")
size - Font size in points
style - "plain", "bold", "italic", "bolditalic"
underline - true/false
strikeThrough - true/false
Text Examples
Advanced Drawing
Complex Shape Example
Chart/Graph Drawing
Drawing Axis Transformations
These transformations affect the coordinate system for drawing, not the image itself.
Translate Origin
Rotate Coordinate System
Shear Coordinate System
Complete Drawing Examples
Create Badge
Create Button
Watermark with Text
Drawing Tips
Enable anti-aliasing for smooth curves and text
Set stroke before drawing for consistent line widths
Use transparency for subtle effects like watermarks
Translate axis to center for symmetrical drawing
Rotate axis for angled text without rotating the image
Next Steps
Advanced Examples - Complex drawing projects
Filters & Effects - Apply visual effects
Transformations - Resize and rotate images
Last updated
Was this helpful?
