Procedural Graphics System

User Guide - Version 1.2.0
What's New in Version 1.2.0:

Introduction

The Procedural Graphics System is a LiveCode application that generates images mathematically rather than using pre-drawn graphics. By manipulating pixel data directly, the system creates smooth, scalable gradients, organic noise patterns, and geometric tile designs at any resolution.

Key Concept: This system works by directly manipulating the imageData property of a LiveCode image object. Each pixel is encoded as 4 bytes (alpha, red, green, blue) and written into the image's binary data stream, allowing precise mathematical control over every pixel's color.

How It Works

Understanding the underlying mechanism

The system operates on three fundamental principles:

  1. Binary Encoding: Colors are converted to binary format using binaryEncode with ARGB (Alpha-Red-Green-Blue) byte structure
  2. Pixel-by-Pixel Generation: Each pixel's position is calculated mathematically to determine its color
  3. Direct ImageData Application: The complete binary pixel data is applied to the image object in a single operation for maximum performance
Performance Note: By building the entire image data in memory before applying it to the image object, generation is extremely fast—even for large images. An 800×800 pixel gradient (640,000 pixels) typically generates in under 500 milliseconds.

User Interface Overview

The interface is divided into two main areas:

Basic Workflow

  1. Select a generator type from the dropdown menu
  2. Choose start and end colors using the color picker buttons
  3. Adjust generator-specific parameters (direction, angle, center position, etc.)
  4. Set desired resolution (width and height in pixels)
  5. Click GENERATE to create the image
  6. Click Export as PNG to save the result

Generator Types

1. Linear Gradient

Creates a straight-line color transition from start to end color.

Parameters:

Horizontal (Left to Right): ┌─────────────────────────────┐ │Red → → → → → → → → → → Blue │ │Red → → → → → → → → → → Blue │ │Red → → → → → → → → → → Blue │ └─────────────────────────────┘ Vertical (Top to Bottom): ┌─────────────────────────────┐ │Red Red Red Red Red Red Red │ │ ↓ ↓ ↓ ↓ ↓ ↓ ↓ │ │ ↓ ↓ ↓ ↓ ↓ ↓ ↓ │ │Blue Blue Blue Blue Blue Blue│ └─────────────────────────────┘ Diagonal (Top-Left to Bottom-Right): ┌─────────────────────────────┐ │Red ╲ │ │ ╲ │ │ ╲ │ │ ╲ Blue │ └─────────────────────────────┘

2. Linear Gradient (Angled)

Creates a linear gradient rotated to any angle between 0° and 360°.

Parameters:

Angle Direction
Left to Right (horizontal)
45° Top-Left to Bottom-Right
90° Top to Bottom (vertical)
180° Right to Left (reverse horizontal)
270° Bottom to Top (reverse vertical)

3. Radial Gradient

Creates a circular gradient radiating from a center point outward to the edges.

Parameters:

Center Position Examples: 0%, 0% 50%, 0% 100%, 0% ┌─────────────┬─────────────┐ │● │● │● │ │ │ │ │ │ │ ●50%, 50% │ ●100%, 50% │ │ │ │ │● │● │● └─────────────┴─────────────┘ 0%, 100% 50%, 100% 100%, 100% ● = Gradient center point (start color) Gradient radiates outward from ● to edges (end color)
Understanding Percentages: X and Y percentages are independent 2D coordinates. They don't need to sum to 100%. For example, X=50%, Y=50% places the center in the middle of the image, while X=100%, Y=100% places it at the bottom-right corner.

4. Conical Gradient

Creates an angular sweep around a center point, like a color wheel or radar sweep.

Parameters:

Conical Gradient Visualization: Full Circle (Sweep = 360°): 0° (Start Color) │ 315° ┌──┼──┐ 45° │ │ │ 270°─┼──●──┼─90° │ │ 225° └─────┘ 135° │ 180° (End Color) Half Circle (Sweep = 180°): 0° (Start) │ ┌──┼──┐ │ │ │ ← Gradient sweeps │ ● │ from 0° to 180° │ │ └─────┘ │ 180° (End Color) (Rest filled with end color)
Start Angle Starting Position
Right (3 o'clock)
90° Bottom (6 o'clock)
180° Left (9 o'clock)
270° Top (12 o'clock)

5. Perlin Noise

Generates organic, natural-looking noise patterns using Perlin noise algorithm. Perfect for creating textures that mimic natural phenomena like clouds, terrain, water, or marble.

Parameters:

Perlin Noise Characteristics: Low Scale (Fine Detail): High Scale (Large Features): ┌─────────────────────┐ ┌─────────────────────┐ │░▒▓░▒░▓▒░▒▓░▒░▓▒░▒▓│ │░░░░▒▒▒▓▓▓▓▒▒▒░░░░│ │▒░▓▒░▓░▒▓░▒▓░▒░▓▒░▓│ │░░░░▒▒▒▓▓▓▓▒▒▒░░░░│ │░▓▒░▓▒░▓▒░▓▒░▓▒░▓▒░│ │▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒│ │▓▒░▓░▒░▓▒░▓░▒░▓▒░▓▒│ │▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒│ └─────────────────────┘ └─────────────────────┘ Low Octaves (Smooth): High Octaves (Detailed): ┌─────────────────────┐ ┌─────────────────────┐ │░░░░▒▒▒▓▓▓▓▓▓▒▒▒░░░│ │░▒░▓▒▓░▒▓░▓▒░▓▒▓░▒│ │░░░░▒▒▒▓▓▓▓▓▓▒▒▒░░░│ │▒▓▒░▓░▒▓▒░▓▒░▓░▒▓▒│ │▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒│ │░▒▓░▒▓░▒▓░▒▓░▒▓░▒▓│ │▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒│ │▓▒░▓▒░▓▒▓░▒▓▒░▓▒░▓│ └─────────────────────┘ └─────────────────────┘ ░ = Dark values ▒ = Mid values ▓ = Light values
Parameter Interaction: These parameters work together to create the final texture: Start with Scale=30, Octaves=4, Persistence=0.5 for natural-looking results, then adjust to taste.

6. Truchet Tiles

Generates intricate patterns by placing and rotating simple geometric tiles. Each tile contains a quarter-circle arc, and when randomly rotated, creates complex maze-like or flowing patterns.

Parameters:

Truchet Tile Basics: Base Tile (Quarter-Circle Arc): ┌─────────┐ │╭────────┤ ← Arc connects ││ │ two adjacent edges ││ │ ││ │ │╰────────┤ ← Arc endpoints └─────────┘ Four Possible Rotations (0°, 90°, 180°, 270°): 0° 90° 180° 270° ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │╭────────┤ │ ╭│ ├────────╮│ │╮ │ ││ │ │ ││ │ ││ │││ │ ││ │ │ ││ │ ││ │││ │ ││ │ │ ││ │ ││ │││ │ │╰────────┤ ├────────╯│ │╭────────┤ │╰╮ │ └─────────┘ └─────────┘ └─────────┘ └─────────┘ Random Pattern Example (4×4 grid): ┌─────┬─────┬─────┬─────┐ │╭──┐ │ ╭──╮│╭──┐ │╭────┤ ││ │ │ │ ││││ │ ││ │ ││ ╰─┼─╯ ╰┼╯│ ╰─┼╯ │ ├┤ │ ├┤ ├┤ │ ││ ╭─┼─╮ ╭┼╮│ ╭─┼╮ │ ││ │ │ │ ││││ │ ││ │ │╰──╯ │ ╰──╯│╰╯ │ │╰────┤ └─────┴─────┴─────┴─────┘ (Creates flowing, maze-like patterns)
Pattern Characteristics:

Interpolation Methods

Control how colors transition between start and end (applies to gradients and Perlin noise)

Gradient and Perlin noise generators support three interpolation methods:

Note: Truchet Tiles do not use interpolation as they create discrete geometric patterns with solid colors.

Resolution Control

Set the output dimensions in pixels:

Tips:

Practical Applications

Linear Gradients

Radial Gradients

Conical Gradients

Perlin Noise

Truchet Tiles

Tips & Techniques

Creating Subtle Effects

Creating Dramatic Effects

Combining Techniques

Performance Considerations

Export Options

Once an image is generated, click Export as PNG to save it. PNG format is used because it:

Technical Notes

ImageData Format: The system writes directly to the image object's imageData property. Each pixel is encoded as 4 bytes in ARGB format: This binary format allows extremely fast pixel manipulation compared to setting individual pixel properties.

Perlin Noise Algorithm

The Perlin noise implementation uses a gradient-based approach with:

Truchet Tile System

The Truchet tile generator:

Troubleshooting

Issue Solution
Image appears banded or blocky This is normal for very small dimensions. Try increasing resolution.
Generation takes a long time Large dimensions (2000+ pixels) require processing millions of pixels. Consider reducing size for preview. Perlin noise with many octaves is particularly intensive.
Radial gradient not circular Use square dimensions (e.g., 800×800 instead of 1920×1080) for perfect circles.
Perlin noise looks too smooth or too noisy Adjust octaves (more = more detail) and persistence (higher = rougher texture). Start with 4 octaves and 0.5 persistence.
Truchet tiles have gaps or don't align Ensure image dimensions are evenly divisible by tile size. For example, 800×800 with 40px tiles = 20×20 grid (perfect fit).
Truchet pattern looks too busy Increase tile size or decrease line thickness for a cleaner look.
Colors don't match expected result Different displays may show colors differently. Export and view on target display.
Export button disabled You must generate an image first before exporting.

Conclusion

The Procedural Graphics System provides powerful, mathematically-precise generation of gradients, organic textures, and geometric patterns through direct imageData manipulation. By controlling every pixel programmatically, it creates infinitely scalable, high-quality graphics suitable for any application.

From smooth color transitions to natural noise patterns to intricate tile designs, the system offers creative flexibility while maintaining exceptional performance. The foundation in binary imageData encoding ensures maximum speed while providing complete creative control over the final output.