Advertisement
KrYn0MoRe

cool math shapes lol v1

Jul 27th, 2020 (edited)
1,888
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.08 KB | None | 0 0
  1. function donut(s)
  2.     local r = s/2
  3.     local l = 100 + s*10
  4.     local center = CFrame.new(0,s*2,-50)
  5.     for i = 1,l do
  6.         local x2 = r*math.cos(i*l/r)
  7.         local y2 = r*math.sin(i*l/r)
  8.         local scale = s/((s-s/4)-math.cos(2*i))
  9.         local z2 = math.sin(x2-y2)+math.cos(x2+y2)+math.cos(x2/y2)
  10.         local xy = CFrame.new(x2,y2,0)
  11.         local part = Instance.new("Part")
  12.         part.Color = Color3.fromHSV(math.abs(x2),255,255)
  13.         part.Size = Vector3.new(1,1,1)
  14.         part.CFrame = xy*center
  15.         part.Anchored = true
  16.         part.Parent = script
  17.     end
  18. end
  19.  
  20. function infinity(s)
  21.     game:GetService("RunService").Stepped:Connect(function(t)
  22.         local center = CFrame.new(0,s*2,-50)
  23.         local scale = s/((s-s/4)-math.cos(2*t))
  24.         local x = scale*math.cos(t)
  25.         local y = scale*math.sin(2*t)/2
  26.         local z = scale*math.sin(2/t)*2
  27.         local x2 = ((x+1)*s)
  28.         local y2 = ((y-1)*s)
  29.         local z2 = (x2+y2)
  30.         local xy = CFrame.new(x2,y2,0)
  31.         local part = Instance.new("Part")
  32.         part.Material = Enum.Material.Neon
  33.         part.Color = Color3.fromHSV(math.abs(x),255,255)
  34.         part.Size = Vector3.new(1,1,1)
  35.         part.CFrame = xy*center
  36.         part.Anchored = true
  37.         part.Parent = script
  38.     end)
  39. end
  40.  
  41. function infinity2(s)
  42.     local part = Instance.new("Part")
  43.     part.Material = Enum.Material.Neon
  44.     part.Size = Vector3.new(1,1,1)
  45.     part.Anchored = true
  46.     part.Parent = script
  47.     local att1,att2 = Instance.new("Attachment"),Instance.new("Attachment")
  48.     att1.Position = Vector3.new(0,-0.5,0)
  49.     att2.Position = Vector3.new(0,0.5,0)
  50.     att1.Parent = part
  51.     att2.Parent = part
  52.     local trail = Instance.new("Trail")
  53.     trail.Parent = part
  54.     trail.Attachment0 = att1
  55.     trail.Attachment1 = att2
  56.     trail.FaceCamera = true
  57.     trail.LightInfluence = 1
  58.     trail.Transparency = NumberSequence.new(0,1)
  59.     trail.MinLength = 0
  60.     trail.Lifetime = 10
  61.     game:GetService("RunService").Stepped:Connect(function(t)
  62.         local center = CFrame.new(0,s*2,-50)
  63.         local scale = s/((s-s/4)-math.cos(2*t))
  64.         local x = scale*math.cos(t)
  65.         local y = scale*math.sin(2*t)/2
  66.         local z = scale*math.sin(2/t)*2
  67.         local x2 = ((x+1)*s)
  68.         local y2 = ((y-1)*s)
  69.         local z2 = (x2+y2)
  70.         local xy = CFrame.new(x2,y2,0)
  71.         game:GetService("TweenService"):Create(part,TweenInfo.new(1),{CFrame = xy*center}):Play()
  72.         trail.Color = ColorSequence.new(Color3.fromHSV(math.abs(x),255,255))
  73.     end)
  74. end
  75.  
  76. function mandelbrot(s)
  77.     local z = 0
  78.     local x = 0.5
  79.     local y = 0.5
  80.     local c = (x+y)
  81.     local i = 0
  82.     game:GetService("RunService").Stepped:Connect(function(t)
  83.         i += 1
  84.         z = z^2+c
  85.         x = z^2+x
  86.         y = z*i^2+y*i
  87.         local center = CFrame.new(0,s*2,-50)
  88.         local part = Instance.new("Part")
  89.         part.Size = Vector3.new(1,1,1)
  90.         part.CFrame = CFrame.new(x,y,0)*center
  91.         part.Anchored = true
  92.         part.Parent = script
  93.     end)
  94. end
  95.  
  96. owner.Chatted:Connect(function(msg)
  97.     if msg:lower():sub(1,5) == 'inf2/' then
  98.         local s = msg:sub(6)
  99.         if tonumber(s) then
  100.             infinity2(tonumber(s))
  101.         end
  102.     elseif msg:lower():sub(1,4) == 'inf/' then
  103.         local s = msg:sub(5)
  104.         if tonumber(s) then
  105.             infinity(tonumber(s))
  106.         end
  107.     elseif msg:lower():sub(1,6) == 'donut/' then
  108.         local s = msg:sub(7)
  109.         if tonumber(s) then
  110.             donut(tonumber(s))
  111.         end
  112.     end
  113. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement