Organic, blob-like shapes are widely used in modern design—backgrounds, hero sections, illustrations, and abstract UI elements. While these shapes are often drawn manually, JavaScript scripting in Adobe Illustrator allows you to generate them programmatically, with randomness, consistency, and speed.
This introductory article shows how to create random “blob” shapes using JavaScript and apply a smooth gradient fill automatically.
This example is beginner-friendly and designed as a foundation for more advanced generative design workflows.
A blob is essentially:
By controlling these parameters in code, you can generate endless variations.
Before running the script:
Save the following code as random-blob-gradient.jsx and run it from:
File → Scripts → Other Script…
Each execution produces a slightly different shape.
This approach blends creativity with logic—ideal for designers exploring generative design.
Once comfortable with this script, you can expand it by:
This introductory article shows how to create random “blob” shapes using JavaScript and apply a smooth gradient fill automatically.
What You’ll Learn
- How to generate organic shapes using anchor points
- How to randomize geometry for natural-looking blobs
- How to create paths programmatically in Illustrator
- How to apply linear or radial gradients via script
This example is beginner-friendly and designed as a foundation for more advanced generative design workflows.
Concept: How a Blob Is Created
A blob is essentially:
- A closed path
- With multiple anchor points arranged around a center
- Each point slightly randomized in distance and angle
- Smoothed using Bezier handles
- Filled with a gradient for visual depth
By controlling these parameters in code, you can generate endless variations.
Prerequisites
Before running the script:
- Open a document in Adobe Illustrator.
- Ensure the document is in RGB color mode.
- No selection is required—the script creates new shapes.
The Script: Create a Random Blob with Gradient Fill
Save the following code as random-blob-gradient.jsx and run it from:
File → Scripts → Other Script…
JavaScript:
#target illustrator
(function () {
if (app.documents.length === 0) {
alert("Please open a document.");
return;
}
var doc = app.activeDocument;
var layer = doc.activeLayer;
// --- Blob settings ---
var centerX = doc.width / 2;
var centerY = doc.height / 2;
var baseRadius = 120;
var pointCount = 8;
var randomness = 50;
// Create the path
var blob = layer.pathItems.add();
blob.closed = true;
blob.stroked = false;
blob.filled = true;
// Generate points around a circle
for (var i = 0; i < pointCount; i++) {
var angle = (Math.PI * 2 / pointCount) * i;
var radius = baseRadius + (Math.random() * randomness - randomness / 2);
var x = centerX + Math.cos(angle) * radius;
var y = centerY + Math.sin(angle) * radius;
var point = blob.pathPoints.add();
point.anchor = [x, y];
point.leftDirection = [
x - Math.cos(angle) * radius * 0.3,
y - Math.sin(angle) * radius * 0.3
];
point.rightDirection = [
x + Math.cos(angle) * radius * 0.3,
y + Math.sin(angle) * radius * 0.3
];
point.pointType = PointType.SMOOTH;
}
// --- Create gradient ---
var gradient = doc.gradients.add();
gradient.type = GradientType.RADIAL;
var stop1 = gradient.gradientStops[0];
stop1.color = new RGBColor();
stop1.color.red = 255;
stop1.color.green = 120;
stop1.color.blue = 200;
var stop2 = gradient.gradientStops.add();
stop2.rampPoint = 100;
stop2.color = new RGBColor();
stop2.color.red = 80;
stop2.color.green = 40;
stop2.color.blue = 160;
var gradientColor = new GradientColor();
gradientColor.gradient = gradient;
blob.fillColor = gradientColor;
})();
What This Script Does
- Calculates a circular distribution of anchor points.
- Randomizes the radius of each point for organic distortion.
- Uses smooth Bezier handles to create fluid curves.
- Builds a closed path (the blob).
- Creates a radial gradient programmatically.
- Applies the gradient as the fill color.
Each execution produces a slightly different shape.
Why This Technique Is Useful
- Generate abstract backgrounds quickly
- Create unique decorative elements for branding
- Prototype generative art concepts
- Avoid repetitive manual drawing
- Build reusable design automation tools
This approach blends creativity with logic—ideal for designers exploring generative design.
Ideas for Further Exploration
Once comfortable with this script, you can expand it by:
- Adding multiple blobs per run
- Randomizing gradient colors
- Animating blobs for motion design
- Supporting linear gradients
- Exporting blobs as SVG assets
- Adding noise-based (Perlin-like) distortion