-
Notifications
You must be signed in to change notification settings - Fork 26
/
matex.lua
61 lines (44 loc) · 1.37 KB
/
matex.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
-- TRIGON.IM 12 dec 2021
-- Упрощенная версия texture либы от dash
matex = matex or {}
file.CreateDir("matex")
function matex.url(url, useproxy)
local id = util.CRC(url)
local filepath = "matex/" .. id .. ".png"
local matpath = "../data/matex/" .. id .. ".png"
local def = {material = nil}
if file.Exists(filepath, "DATA") then
def.material = Material(matpath, "noclamp smooth")
return def
end
local baseurl = useproxy and "https://proxy.duckduckgo.com/iu/?u=" .. url or url
http.Fetch(baseurl, function(body)
file.Write(filepath, body)
def.material = Material(matpath, "noclamp smooth")
return def.material
end, function(error)
if useproxy then def.material = Material("nil") return def end
return matex.url(url, true)
end)
return def
end
-- function matex.imgur(id)
-- return matex.url("https://i.imgur.com/" .. id .. ".png")
-- end
-- local furl = fl.memoize(matex.url)
-- function matex.url_async(url)
-- return furl(url).material
-- end
-- function matex.imgur_async(id)
-- return furl("https://i.imgur.com/" .. id .. ".png").material
-- end
/* example
local mater = matex.imgur("TZcJ1CK")
hook.Add("HUDPaint", "mater", function()
if not mater.material then return end
surface.SetDrawColor(color_white)
surface.SetMaterial(mater.material)
surface.DrawTexturedRect(35, 35, 570, 460)
end)
-- hook.Remove("HUDPaint", "mater")
*/