Repository navigation
Expand file tree
/
Copy pathDrawNodeTSX.lua
More file actions
162 lines (162 loc) · 3.91 KB
/
Copy pathDrawNodeTSX.lua
File metadata and controls
162 lines (162 loc) · 3.91 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
-- [tsx]: DrawNodeTSX.tsx
local ____exports = {} -- 1
local ____DoraX = require("DoraX") -- 2
local React = ____DoraX.React -- 2
local toNode = ____DoraX.toNode -- 2
local ImGui = require("ImGui") -- 4
local ____Dora = require("Dora") -- 5
local App = ____Dora.App -- 5
local Vec2 = ____Dora.Vec2 -- 5
local threadLoop = ____Dora.threadLoop -- 5
local function CircleVertices(radius, verts) -- 7
local v = verts or 20 -- 8
local function newV(index, r) -- 9
local angle = 2 * math.pi * index / v -- 10
return Vec2( -- 11
r * math.cos(angle), -- 11
radius * math.sin(angle) -- 11
):add(Vec2(r, radius)) -- 11
end -- 9
local vs = {} -- 13
do -- 13
local index = 0 -- 14
while index <= v do -- 14
vs[#vs + 1] = newV(index, radius) -- 15
index = index + 1 -- 14
end -- 14
end -- 14
return vs -- 17
end -- 7
local function StarVertices(radius) -- 20
local a = math.rad(36) -- 21
local c = math.rad(72) -- 22
local f = math.sin(a) * math.tan(c) + math.cos(a) -- 23
local R = radius -- 24
local r = R / f -- 25
local vs = {} -- 26
do -- 26
local i = 9 -- 27
while i >= 0 do -- 27
local angle = i * a -- 28
local cr = i % 2 == 1 and r or R -- 29
vs[#vs + 1] = Vec2( -- 30
cr * math.sin(angle), -- 30
cr * math.cos(angle) -- 30
) -- 30
i = i - 1 -- 27
end -- 27
end -- 27
return vs -- 32
end -- 20
local themeColor = App.themeColor:toARGB() -- 35
toNode(React.createElement( -- 37
React.Fragment, -- 37
nil, -- 37
React.createElement( -- 37
"draw-node", -- 37
{x = 200, y = 200}, -- 37
React.createElement( -- 37
"polygon-shape", -- 37
{ -- 37
verts = StarVertices(60), -- 37
fillColor = 2164195456, -- 37
borderWidth = 1, -- 37
borderColor = 4294901888 -- 37
} -- 37
) -- 37
), -- 37
React.createElement( -- 37
"line", -- 37
{ -- 37
verts = CircleVertices(60), -- 37
lineColor = themeColor, -- 37
x = -200, -- 37
y = 200 -- 37
} -- 37
), -- 37
React.createElement( -- 37
"node", -- 37
{color3 = themeColor, scaleX = 2, scaleY = 2}, -- 37
React.createElement( -- 37
"draw-node", -- 37
{opacity = 0.5}, -- 37
React.createElement( -- 37
"polygon-shape", -- 37
{verts = { -- 37
Vec2(-20, -10), -- 48
Vec2(20, -10), -- 49
Vec2(20, 10), -- 50
Vec2(-20, 10) -- 51
}} -- 51
), -- 51
React.createElement( -- 51
"polygon-shape", -- 51
{verts = { -- 51
Vec2(20, 3), -- 54
Vec2(32, 10), -- 55
Vec2(32, -10), -- 56
Vec2(20, -3) -- 57
}} -- 57
), -- 57
React.createElement("dot-shape", {x = -11, y = 20, radius = 10}), -- 57
React.createElement("dot-shape", {x = 11, y = 20, radius = 10}) -- 57
), -- 57
React.createElement( -- 57
"line", -- 57
{ -- 57
verts = CircleVertices(10), -- 57
x = -21, -- 57
y = 10 -- 57
} -- 57
), -- 57
React.createElement( -- 57
"line", -- 57
{ -- 57
verts = CircleVertices(10), -- 57
x = 1, -- 57
y = 10 -- 57
} -- 57
), -- 57
React.createElement( -- 57
"line", -- 57
{verts = { -- 57
Vec2(20, 3), -- 66
Vec2(32, 10), -- 67
Vec2(32, -10), -- 68
Vec2(20, -3) -- 69
}} -- 69
) -- 69
) -- 69
)) -- 69
local windowFlags = { -- 75
"NoDecoration", -- 76
"AlwaysAutoResize", -- 77
"NoSavedSettings", -- 78
"NoFocusOnAppearing", -- 79
"NoMove" -- 80
} -- 80
threadLoop(function() -- 82
local ____App_visualSize_0 = App.visualSize -- 83
local width = ____App_visualSize_0.width -- 83
ImGui.SetNextWindowBgAlpha(0.35) -- 84
ImGui.SetNextWindowPos( -- 85
Vec2(width - 10, 10), -- 85
"Always", -- 85
Vec2(1, 0) -- 85
) -- 85
ImGui.SetNextWindowSize( -- 86
Vec2(240, 0), -- 86
"FirstUseEver" -- 86
) -- 86
ImGui.Begin( -- 87
"Draw Node", -- 87
windowFlags, -- 87
function() -- 87
ImGui.Text("Draw Node (TSX)") -- 88
ImGui.Separator() -- 89
ImGui.TextWrapped("Draw shapes and lines!") -- 90
end -- 87
) -- 87
return false -- 92
end) -- 82
return ____exports -- 82