function setup()
-- Change this
form = math.sin(x) - math.sqrt(x) / 5
-- Not!
yOFx = HEIGHT/2
xOFy = WIDTH/2
parameter.integer("size", 5, 100, 50)
parameter.integer("scaleY",1, 25, 1)
parameter.number("stepX", 0.2, 1, 1)
parameter.integer("MoveX", -1000, 1000, 0)
parameter.integer("MoveY", -1000, 1000, 0)
parameter.action("To Default", function()
MoveX = 0
MoveY = 0
scaleY = 1
size = 10
end)
end
function draw()
local MoveX = -MoveX
local MoveY = -MoveY
resetStyle()
background(40, 40, 50)
strokeWidth(1)
fill(255, 255, 255, 255)
stroke(255, 255, 255, 255)
line(0, yOFx + MoveY, WIDTH, yOFx + MoveY)
line(xOFy + MoveX, 0, xOFy + MoveX, HEIGHT)
local t = {}
for x = -250, 250, stepX do
local formula = form
formula = formula * scaleY
table.insert(t, {formula, x})
end
for a, b in ipairs(t) do
strokeWidth(0)
--[[fill(255, 255, 255, 255)
local k = 0
local m = {5, 10, 15, 20, 25, 30, 35, 50, 75, 120, 250}
for r, t in ipairs(m) do
if size > t then
k = k + 1
end
end
ellipse(xOFy + b[2] * size + MoveX, yOFx + b[1] * size + MoveY, k)]]
if b[1] * size > 0 then
fill(35, 255, 0, 255)
rect(xOFy + b[2] * size + MoveX - size/4, yOFx + MoveY, size * stepX, b[1] * size)
else
fill(255, 0, 0, 255)
rect(xOFy + b[2] * size + MoveX - size/4, yOFx + MoveY + b[1] * size, size * stepX, math.abs(b[1]) * size)
end
end
end
We had this in my math group. Helped me a lot Thanks Codea