Please expand this article. You can help by adding more information if you are an editor. More information might be found in a section of the talk page. (December 2017)
For more information, see Lissajous curve on Wikipedia.

This tutorial explains how to make pen patterns that appear 3-dimensional in Scratch. Using trigonometry, curves can be graphed on the screen and by varying the parameters, animation and the appearance of 3D rotation is possible. This is not "true" 3D in that no third dimension is explicitly handled in the calculations.

Script

First of all, make some custom blocks as follows:

define Reset
define Draw

Afterwards, make this script,

when green flag clicked
set pen (color v) to (pick random (1) to (100))
Reset :: custom
forever
erase all
Draw :: custom
change [delta v] by (1)
end

The script above is the loop that will start everything up in the project.

Getting the Variables Ready

Next, get the variables ready. In the Reset :: custom custom block, make this script:

define Reset
set [angle v] to [0]
set [A v] to [220]
set [B v] to [160]
set [r1 v] to (pick random (1) to (100))
set [r2 v] to (pick random (1) to (100))
set [delta v] to (pick random (1) to (90))
go to x: ((A) * ([sin v] of (((angle) * (r1)) + (delta)))) y: ((B) * ([cos v] of (((angle) * (r2)) + (delta)))
pen down
set pen size to (50)

The Reset block will also make a pattern, so it will be useful.

Note Note: For easier access, make the r1 and r2 variables sliders.

Creating the Draw Script

Next, make the code for the Draw :: custom custom block. This block will be more complicated.

define Draw
show
erase all
pen down
repeat (360)
go to x: ((A) * ([sin v] of (((angle) * (r1)) + (delta)))) y: ((B) * ([cos v] of ((angle) * (r2))
set pen size to ([abs v] of ((((1000) - ((A) * ([sin v] of (((angle) * (r1)) + (delta))))) - ((B) * ([cos v] of ((angle) * (r2))))) / (150)))
set pen (brightness v) to ((-0.5) * (((A) * ([sin v] of (((angle) * (r1)) + (delta)))) - ((B) * ([cos v] of ((angle) * (r2))))
change [angle v] by (1)
move (10) steps

Example Project

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.