Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- [[ Service Declarations ]] --
- local workspace = game:GetService("Workspace")
- -- [[ Prebuilt Library Declarations ]] --
- --// Variables
- local pi = math.pi
- --// Functions
- local cos = math.cos
- local sin = math.sin
- -- [[ Line Class Declarations ]] --
- local line = {}
- do
- --// Line Methods
- function line.new(positionA, positionB, lineWidth)
- local newLine = Instance.new("Part")
- local distance = (positionA - positionB).Magnitude
- newLine.Anchored = true
- newLine.Size = Vector3.new(lineWidth, lineWidth, distance)
- newLine.CFrame = CFrame.new(positionA, positionB) * CFrame.new(lineWidth / 2, 0, -distance / 2)
- newLine.Parent = workspace
- return newLine
- end
- end
- -- [[ Shape Class Declarations ]] --
- local shape = {}
- do
- --// Shape Methods
- function shape.new(pointCount, radius, lineWidth)
- local newShape = {}
- do
- --// Calculate Points
- local points = {}
- local angle = (pi * 2) / pointCount
- for i = 1, pointCount do
- local currentAngle = angle * i
- local xPosition = cos(currentAngle) * radius
- local zPosition = sin(currentAngle) * radius
- local position = Vector3.new(xPosition, 0, zPosition)
- do
- --// Render Point
- local newPoint = Instance.new("Part")
- newPoint.Anchored = true
- newPoint.Transparency = .5
- newPoint.Size = Vector3.new(1, 1, 1)
- newPoint.CFrame = CFrame.new(position)
- newPoint.Parent = workspace
- end
- points[#points + 1] = position
- end
- newShape.points = points
- end
- do
- --// Generate Lines
- local points = newShape.points
- for i = 1, #points do
- local index = (i % #points) + 1
- local nextIndex = ((i + 1) % #points) + 1
- local currentPoint = points[index]
- local nextPoint = points[nextIndex]
- line.new(currentPoint, nextPoint, lineWidth)
- end
- end
- return newShape
- end
- end
- -- [[ Init ]] --
- do
- --// Generate Shape
- shape.new(24, 50, 1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement