Done!
Free Tool • No Registration

Draw a Morton Fractal

Generate beautiful Z-order Morton curves with full customization

Structure

Recursion Depth3
Rotation (°)0
Scale (%)90
Padding (%)5

Appearance

Color Theme
#6366f1
#22d3ee
#000000
Line Width2.0
Opacity (%)100

Effects

Cells: 0 Segments: 0 Grid: 0×0 Canvas: 1200×800
×

Advanced Features

8-Level Recursion

Generate up to 65,536 cells with depth 8

7 Color Themes

Gradient, rainbow, ocean, neon, fire & more

Animated Drawing

Watch the Z-curve trace its path in real time

PNG & SVG Export

Up to 4K resolution or scalable vector

Grid & Numbers

Visual grid overlay with Morton code labels

Glow & Fill

Luminous glow and cell fill effects

Direction Arrows

Show traversal direction on each segment

100% Private

All rendering in your browser locally

How to Use

1

Pick a Preset

Choose a sample or start with defaults

2

Adjust Controls

Tweak depth, colors, rotation & effects

3

Preview Live

See instant real-time canvas updates

4

Export

Download as PNG, SVG, or save config

What Is a Morton Fractal and Why Is It Important?

A Morton fractal, also widely known as the Z-order curve or Morton code curve, is a space-filling fractal curve that maps multidimensional data to a single dimension while preserving spatial locality. Named after Guy Macdonald Morton who introduced the concept in 1966 for file sequencing in geographic databases, this remarkable curve traces a distinctive Z-shaped pattern through a grid of cells, visiting each cell exactly once in a specific order determined by interleaving the binary representations of the x and y coordinates. When you draw a Morton fractal, you create a visual representation of this elegant mapping that connects computer science, mathematics, and visual art in a single image.

The Z-order curve gets its informal name from the characteristic "Z" shape it traces at every level of recursion. At the lowest level, the curve visits four cells in a pattern that looks exactly like the letter Z. At the next level, each of those four cells is subdivided into four smaller cells, and the same Z-pattern is applied within each quadrant, creating a recursive structure. This self-similar Morton curve continues at every scale, producing an increasingly detailed space-filling path that eventually visits every cell in the grid. Our free Morton fractal generator lets you explore this fascinating mathematical structure through an intuitive browser-based interface with real-time previewing, multiple color themes, and professional export options.

The practical importance of the Morton curve extends far beyond visual aesthetics. In computer science, Morton codes are used extensively for spatial indexing, texture mapping in graphics processing units, database organization, and collision detection in physics simulations. The Z-order curve's ability to preserve two-dimensional locality when linearized into one dimension makes it invaluable for cache-coherent memory access patterns. Understanding and visualizing this curve through a Morton fractal generator provides essential insight into algorithms used throughout modern computing infrastructure, from video game engines to geographic information systems.

How Does the Morton Z-Order Curve Algorithm Work?

The algorithm behind our online Morton fractal tool generates Z-order curves by computing Morton codes for each cell in a 2D grid and then connecting the cell centers in Morton code order. For a grid of size 2^n × 2^n, each cell has integer coordinates (x, y) where both x and y range from 0 to 2^n − 1. The Morton code for a cell is computed by interleaving the bits of x and y: the least significant bit of x becomes bit 0 of the Morton code, the least significant bit of y becomes bit 1, the next bit of x becomes bit 2, and so on. This bit-interleaving produces a unique integer for every cell, and the sequence of cells sorted by Morton code traces the characteristic Z-pattern.

At recursion depth n, the grid contains (2^n)² = 4^n cells, so the curve passes through 4 cells at depth 1, 16 cells at depth 2, 64 at depth 3, 256 at depth 4, and up to 65,536 cells at depth 8. The rendering engine calculates the center position of each cell in the grid, applies the user-specified scale, rotation, and padding parameters, and then draws line segments connecting consecutive cells in Morton order. The color of each segment is determined by the selected color theme, with the position along the curve mapped to color values using the same color interpolation functions used across the entire tool's color engine.

What makes our implementation particularly advanced is the suite of visualization overlays available. The grid overlay draws the cell boundaries so you can see exactly how the Z-curve traverses the subdivided space. The cell number overlay labels each cell with its Morton code index, making the ordering visually explicit and educational. The arrow overlay adds directional indicators to each segment, showing the traversal direction. And the fill mode colors each cell based on its Morton code value, creating a heat-map style visualization that reveals the spatial distribution of Morton codes across the grid.

What Color Themes Are Available for Morton Fractals?

Our custom Morton fractal tool provides seven distinct color themes designed to serve different visualization and aesthetic purposes. The gradient mode smoothly interpolates between two user-chosen colors based on position along the curve, creating a visual trace that shows the order of traversal from start to finish. This is the default mode and the most intuitive way to understand how the Z-curve fills space. The solid mode applies a uniform stroke color throughout, producing clean mathematical illustrations suitable for academic papers and technical documentation.

The rainbow mode cycles through the full hue spectrum, creating vibrant colorful Morton fractals where every portion of the curve is visually distinct. This mode is particularly useful at high recursion depths where the dense curve pattern might otherwise appear as a uniform mass. The depth map mode assigns colors based on the hierarchical recursion level of each segment, making the self-similar structure of the curve visually apparent. The ocean, neon, and fire themed modes each bring a distinctive atmospheric quality to the visualization, transforming mathematical curves into abstract fractal patterns suitable for digital art, prints, and design projects.

Can You Animate the Morton Curve Drawing Process?

Yes, the animated drawing feature is one of the most educational and visually compelling aspects of this interactive Morton curve tool. When you click the Animate button, the tool draws the Z-curve progressively, adding segments one batch at a time. You watch the curve trace its characteristic Z-pattern through the grid in real time, visiting each cell in Morton code order. The animation clearly demonstrates the recursive structure of the curve — you can see it complete the Z-pattern in one quadrant before jumping to the next, then completing the Z-pattern at the next level up, creating a nested hierarchy of Z-shapes that eventually covers the entire grid.

This animated visualization is particularly valuable for computer science educators teaching spatial data structures, cache-coherent algorithms, or computational geometry. Students can observe firsthand how the Morton curve maintains spatial locality — cells that are near each other in 2D space tend to be near each other in the linearized curve order, though with occasional jumps between quadrants that are inherent to the Z-order mapping. The animation uses requestAnimationFrame for smooth rendering performance and can be stopped at any point to freeze the partially-drawn curve for examination or screenshot capture.

How Do You Export a High-Resolution Morton Fractal?

The tool provides three export pathways for maximum flexibility. PNG export captures the canvas at its current resolution — set it to 4096×4096 for print-quality output with crisp details even at large physical sizes. The PNG file preserves all visual elements including the curve, grid overlay, cell numbers, fill colors, and glow effects exactly as displayed on screen. SVG export generates a scalable vector graphics file where every line segment is represented as a precise vector element. SVG files scale infinitely without quality loss, making them ideal for professional design workflows in tools like Adobe Illustrator, Figma, or Inkscape. The SVG preserves per-segment colors, line widths, and opacity values. JSON config export saves all parameter settings so you can recreate exact fractals later, share configurations with collaborators, or build a library of favorite designs.

What Makes the Morton Curve a Space-Filling Curve?

A space-filling Morton curve demonstrates the remarkable mathematical property that a one-dimensional line can be arranged to visit every point within a two-dimensional area. As the recursion depth increases, the Z-order curve passes through an exponentially growing number of cells in the grid, progressively filling more and more of the available space. At infinite recursion depth, the curve would theoretically pass through every point in the square, making it a true space-filling curve in the mathematical sense. This property, shared with other famous curves like the Hilbert curve and Peano curve, has profound implications for both pure mathematics and practical computing applications.

What distinguishes the Morton Z-order curve from other space-filling curves is its computational simplicity. While the Hilbert curve requires complex state-based generation rules, the Morton curve's ordering is determined entirely by bit-interleaving operations — simple, fast, and parallelizable. This computational efficiency is why Morton codes are the preferred spatial indexing method in high-performance computing applications including GPU texture sampling, octree traversal in ray tracing, and spatial database indexing. Our fractal visualization generator makes these algorithmic properties visually intuitive, bridging the gap between abstract mathematics and tangible understanding.

Who Benefits from Using a Morton Fractal Generator?

The audience for this free online fractal maker spans education, research, art, and software engineering. Computer science students and educators use Morton curve visualizations to teach spatial indexing, cache coherence, bit manipulation, and computational geometry concepts. The grid overlay and cell numbering features make the tool particularly effective as a teaching aid, allowing students to see exactly how 2D coordinates map to linear Morton codes and back. Researchers studying spatial data structures, geographic information systems, and parallel computing algorithms use visual Morton curve representations in papers, presentations, and documentation.

Digital artists and designers use the tool to create unique Z-order fractal art for prints, wallpapers, social media graphics, and product designs. The combination of geometric precision and artistic color themes produces patterns that are both mathematically meaningful and visually striking. Game developers and graphics programmers benefit from understanding Morton curve properties through visualization, as Z-order curves underpin many GPU optimization techniques including texture swizzling, sparse virtual texturing, and spatial acceleration structures used in modern rendering engines.

What Are the Best Settings for Different Morton Fractal Styles?

For a classic mathematical visualization, use depth 3-4 with solid white color on black background, grid enabled, cell numbers on, and arrows showing. This produces a clear, educational diagram perfect for presentations and documentation. For vibrant fractal art, increase depth to 5-7, choose rainbow or neon color theme, enable glow effect, disable grid and numbers, and use a dark background. The resulting dense, colorful pattern creates stunning abstract fractal art suitable for prints and digital displays. For a data visualization perspective, enable fill mode with a depth-based color theme and cell numbers, which creates a heat-map style representation that clearly shows how Morton codes distribute across 2D space.

The rotation parameter adds an interesting dimension to Morton fractal aesthetics. At 0 degrees, you see the standard Z-pattern orientation. Rotating by 45 degrees creates a diamond-shaped layout. At 90 degrees, the Z-patterns become rotated but maintain their recursive structure. Experimenting with rotation reveals different visual aspects of the same underlying mathematical curve, and the randomize button provides an excellent way to discover unexpected parameter combinations that produce striking results.

How Does the Morton Curve Compare to the Hilbert Curve?

Both the Morton Z-order curve and the Hilbert curve are space-filling curves used for spatial indexing, but they differ in important ways. The Hilbert curve provides better locality preservation — nearby points in 2D space are more consistently mapped to nearby positions in the linear order. However, the Morton curve is computationally simpler to generate and decode, requiring only bitwise operations rather than the recursive state transformations needed for Hilbert curve computation. This makes Morton codes significantly faster to compute in practice, which is why they are preferred in performance-critical applications like GPU computing.

Visually, the Morton curve's Z-shaped pattern is more angular and irregular than the Hilbert curve's smooth, continuous path. The Morton curve has large jumps between quadrants where the traversal order crosses quadrant boundaries, while the Hilbert curve maintains a continuous path that never makes such jumps. Our digital Morton curve creator makes these differences visible and explorable, helping users understand the tradeoffs between different space-filling curve designs for their specific applications.

Frequently Asked Questions

A Morton fractal, or Z-order curve, is a space-filling fractal that maps 2D grid cells to a 1D sequence by interleaving the binary bits of x and y coordinates, creating a recursive Z-shaped pattern.

Choose a preset or adjust depth, colors, and effects using the controls. The fractal renders automatically in real-time as you change settings.

Yes. Set canvas up to 4096×4096 for PNG, or export SVG for infinitely scalable vector output.

Completely free — no registration, no watermarks, no limits. Everything runs in your browser.

Depth sets grid subdivision level. Each level quadruples the cells: depth 1=4, depth 3=64, depth 5=1024, depth 8=65,536 cells.

Morton uses bit-interleaving (simpler, faster) producing Z-patterns with jumps. Hilbert uses recursive state transforms producing smoother continuous paths with better locality.

Yes. Click Animate to watch the Z-curve trace its path progressively through the grid.

Morton codes are used for GPU texture mapping, spatial database indexing, cache-coherent memory access, octree traversal, and collision detection.

Yes. Export Config saves all parameters as JSON. Import Config loads them back to recreate your fractal.

Yes. All rendering runs locally in your browser via Canvas API. Nothing is sent to any server.