Simulate “scribbling” by joining random points using smooth curves.
Run the code to make a line joining 30 random points. Try more than 30 points:
This draws a line through the points at coordinates {0,0}, {1,1}, and {2,0}:
Turn on axes with AxesTrue in order to see the numeric coordinate positions:
Use RandomReal to draw a line with random coordinates.
This gives a random number between 0 and 1. Each time you run the code, you get a different number:
This gives a pair of numbers between 0 and 1. Each time you run the code, you get a different pair:
This gives four pairs of random numbers:
Use RandomReal to draw a line with 30 random coordinates:
Join the points with a Bezier curve instead. Try more than 30 points:
Make a smooth curve by replacing Line with BezierCurve.
Here’s a Line through 6 random points (you can ignore SeedRandom for the moment; we’ll explain it later):
Here’s a BezierCurve based on the same 6 points:
Here are the Line and BezierCurve drawn together so you can see how they correspond. The Bezier curve doesn’t pass through all of the points, but is guided by them:
Make the curve thicker. Try thicknesses other than 5—for example, 10:
AbsoluteThickness specifies how thick to draw lines and curves. The thickness is measured in “points”, a standard measure used by printers (one point is 1/72 inch):
Make an interactive scribble, with a seed to determine the random choices. Drag the sliders to get different scribbles:
This makes a random scribble with 30 points:
You can make an interactive interface to control the number of points in the scribble using Manipulate.
Wrap the scribble expression with Manipulate[...], replace 30 with the variable length, and specify that length varies from 10 to 200 in steps of 1. Drag the slider to get random scribbles of various lengths:
The scribble jumps around as you drag the slider because RandomReal gives different coordinate positions each time.
If you add SeedRandom[12345] to the code, the scribble stays the same as you drag the slider, but gets longer and shorter. That’s because SeedRandom resets the random number generator to the same point each time the scribble is drawn, so that you get the same sequence of random numbers:
You can give SeedRandom a different number—54321 instead of 12345—to reset the random number generator to a different point, and get a different scribble:
You might as well make the seed interactive too, so that you have a control that chooses the scribble:
Draw a random line in 3D. Try more than 30 points:
If you know how to draw scribbles in 2D, it’s easy to do the same thing in 3D.
Here’s a 2D scribble:
Replace Graphics with Graphics3D and RandomReal[1,{30,2}] with RandomReal[1,{30,3}] so the line has 3D coordinates instead of 2D. That’s it. You can rotate the scribble with the mouse:
Draw a Bezier curve “scribble” in 3D. Try more than 30 points, or thicknesses other than 5:
Make a smooth 3D curve by replacing Line with BezierCurve:
Make it interactive. Drag the sliders to get different 3D scribbles. Rotate the scribbles with the mouse:
Share It—Make an interactive scribble website:
Deploy the Manipulate to the Wolfram Cloud where anyone with a browser can use it:
Click on the link in the output to visit the site.
Tell the world about your creation by sharing the link via email, tweet, or other message.