• API
• FAQ
• Tools
• Trends
• Archive
daily pastebin goal
34%
SHARE
TWEET

# Untitled

a guest Aug 12th, 2017 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. --@author
2. --@shared
3. --@client
4.
5. --[[
6. function cerp(xd, yd, dd, x)
7.     local  i = 1
8.
9.     while xd[i] < x do
10.         i = i + 1
11.
12.         local t = (x - xd[i-1]) / (xd[i] - xd[i-1])
13.
14.         local a =  dd[i-1]*(xd[i]-xd[i-1]) - (yd[i]-yd[i-1])
15.         local b = -dd[i  ]*(xd[i]-xd[i-1]) + (yd[i]-yd[i-1])
16.
17.         return (1-t)*yd[i-1] + t*yd[i] + t*(1-t)*(a*(1-t)+b*t)
18.     end
19. end
20. --]]
21.
22. function cerp(p1, p2, p3, p4, x)
23.     local a = 2*p2 - 2*p3 + p1 + p4
24.     local b = -3*p2 + 3*p3 - 2*p1 - p4
25.     local c = p1
26.     local d = p2
27.
28.     return a*x^3 + b*x^2 + c*x + d
29. end
30.
31. function cerp(v0, v1, v2, v3, x)
32.     local v0, v1, v2, v3 = v0 or 0, v1 or 0, v2 or 0, v3 or 0
33.     local a = (v3 - v2) - (v0 - v1)
34.     local b = (v0 - v1) - a
35.     local c = v2 - v0
36.     local d = v1
37.     return a*x^3 + b*x^2 + c*x + d
38. end
39.
40. point = {Vector(0, 0), Vector(100, 256), Vector(200, 256), Vector(300, 500), Vector(400, 100), Vector(500, 500)}
41. render.createRenderTarget("test")
43.     local x, y = render.cursorPos(player())
44.     x, y = x or 0, y or 0
45.
46.     point[2] = Vector(x, y)
47.
48.
49.
50.     render.selectRenderTarget("test")
51.
52.     render.setColor(Color(0, 0, 0, 255))
53.     render.drawRect(0, 0, 1024, 1024)
54.     render.setColor(Color(255))
55.
56.     for i=1, 50 do
57.         local x1 = cerp(point[1], point[2], point[3], point[4], (1/50)*i-(1/50)).x
58.         local y1 = cerp(point[1], point[2], point[3], point[4], (1/50)*i-(1/50)).y
59.
60.         local x2 = cerp(point[1], point[2], point[3], point[4], (1/50)*(i+1)-(1/50)).x
61.         local y2 = cerp(point[1], point[2], point[3], point[4], (1/50)*(i+1)-(1/50)).y
62.
63.         render.drawLine(x1*2, y1*2, x2*2, y2*2)
64.
65.
66.         x1 = cerp(point[2], point[3], point[4], point[5], (1/50)*i-(1/50)).x
67.         y1 = cerp(point[2], point[3], point[4], point[5], (1/50)*i-(1/50)).y
68.
69.         x2 = cerp(point[2], point[3], point[4], point[5], (1/50)*(i+1)-(1/50)).x
70.         y2 = cerp(point[2], point[3], point[4], point[5], (1/50)*(i+1)-(1/50)).y
71.
72.         render.drawLine(x1*2, y1*2, x2*2, y2*2)
73.
74.
75.         x1 = cerp(point[3], point[4], point[5], point[6], (1/50)*i-(1/50)).x
76.         y1 = cerp(point[3], point[4], point[5], point[6], (1/50)*i-(1/50)).y
77.
78.         x2 = cerp(point[3], point[4], point[5], point[6], (1/50)*(i+1)-(1/50)).x
79.         y2 = cerp(point[3], point[4], point[5], point[6], (1/50)*(i+1)-(1/50)).y
80.
81.         render.drawLine(x1*2, y1*2, x2*2, y2*2)
82.     end
83.     render.selectRenderTarget(nil)
84.
85.     render.setRenderTargetTexture("test")
86.     render.drawTexturedRect(0, 0, 512, 512)
87.
88.     for k, v in pairs(point) do
89.         render.drawRect(v.x, v.y, 10, 10)
90.     end
91. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top