@@ -11,6 +11,251 @@ const sceneBackendType: phantom.scene.BackendType = @enumFromInt(@intFromEnum(op
1111const sceneBackend = phantom .scene .Backend (sceneBackendType );
1212
1313pub fn main () void {
14+ const colors : []const [17 ]vizops.color.Any = &.{
15+ .{
16+ .{
17+ .uint8 = .{
18+ .sRGB = .{
19+ .value = .{ 0xf7 , 0x76 , 0x8e , 0xff },
20+ },
21+ },
22+ },
23+ .{
24+ .uint8 = .{
25+ .sRGB = .{
26+ .value = .{ 0xff , 0x9e , 0x64 , 0xff },
27+ },
28+ },
29+ },
30+ .{
31+ .uint8 = .{
32+ .sRGB = .{
33+ .value = .{ 0xe0 , 0xaf , 0x68 , 0xff },
34+ },
35+ },
36+ },
37+ .{
38+ .uint8 = .{
39+ .sRGB = .{
40+ .value = .{ 0x9e , 0xce , 0x6a , 0xff },
41+ },
42+ },
43+ },
44+ .{
45+ .uint8 = .{
46+ .sRGB = .{
47+ .value = .{ 0x73 , 0xda , 0xca , 0xff },
48+ },
49+ },
50+ },
51+ .{
52+ .uint8 = .{
53+ .sRGB = .{
54+ .value = .{ 0xb4 , 0xf9 , 0xf8 , 0xff },
55+ },
56+ },
57+ },
58+ .{
59+ .uint8 = .{
60+ .sRGB = .{
61+ .value = .{ 0x2a , 0xc3 , 0xde , 0xff },
62+ },
63+ },
64+ },
65+ .{
66+ .uint8 = .{
67+ .sRGB = .{
68+ .value = .{ 0x7d , 0xcf , 0xff , 0xff },
69+ },
70+ },
71+ },
72+ .{
73+ .uint8 = .{
74+ .sRGB = .{
75+ .value = .{ 0x7a , 0xa2 , 0xf7 , 0xff },
76+ },
77+ },
78+ },
79+ .{
80+ .uint8 = .{
81+ .sRGB = .{
82+ .value = .{ 0xbb , 0x9a , 0xf7 , 0xff },
83+ },
84+ },
85+ },
86+ .{
87+ .uint8 = .{
88+ .sRGB = .{
89+ .value = .{ 0xc0 , 0xca , 0xf5 , 0xff },
90+ },
91+ },
92+ },
93+ .{
94+ .uint8 = .{
95+ .sRGB = .{
96+ .value = .{ 0xa9 , 0xb1 , 0xd6 , 0xff },
97+ },
98+ },
99+ },
100+ .{
101+ .uint8 = .{
102+ .sRGB = .{
103+ .value = .{ 0x9a , 0xa5 , 0xce , 0xff },
104+ },
105+ },
106+ },
107+ .{
108+ .uint8 = .{
109+ .sRGB = .{
110+ .value = .{ 0xcf , 0xc9 , 0xc2 , 0xff },
111+ },
112+ },
113+ },
114+ .{
115+ .uint8 = .{
116+ .sRGB = .{
117+ .value = .{ 0x56 , 0x5f , 0x89 , 0xff },
118+ },
119+ },
120+ },
121+ .{
122+ .uint8 = .{
123+ .sRGB = .{
124+ .value = .{ 0x41 , 0x48 , 0x68 , 0xff },
125+ },
126+ },
127+ },
128+ .{
129+ .uint8 = .{
130+ .sRGB = .{
131+ .value = .{ 0x1a , 0x1b , 0x26 , 0xff },
132+ },
133+ },
134+ },
135+ },
136+ .{
137+ .{
138+ .uint8 = .{
139+ .sRGB = .{
140+ .value = .{ 0xf7 , 0x76 , 0x8e , 0xff },
141+ },
142+ },
143+ },
144+ .{
145+ .uint8 = .{
146+ .sRGB = .{
147+ .value = .{ 0xff , 0x9e , 0x64 , 0xff },
148+ },
149+ },
150+ },
151+ .{
152+ .uint8 = .{
153+ .sRGB = .{
154+ .value = .{ 0xe0 , 0xaf , 0x68 , 0xff },
155+ },
156+ },
157+ },
158+ .{
159+ .uint8 = .{
160+ .sRGB = .{
161+ .value = .{ 0x9e , 0xce , 0x6a , 0xff },
162+ },
163+ },
164+ },
165+ .{
166+ .uint8 = .{
167+ .sRGB = .{
168+ .value = .{ 0x73 , 0xda , 0xca , 0xff },
169+ },
170+ },
171+ },
172+ .{
173+ .uint8 = .{
174+ .sRGB = .{
175+ .value = .{ 0xb4 , 0xf9 , 0xf8 , 0xff },
176+ },
177+ },
178+ },
179+ .{
180+ .uint8 = .{
181+ .sRGB = .{
182+ .value = .{ 0x2a , 0xc3 , 0xde , 0xff },
183+ },
184+ },
185+ },
186+ .{
187+ .uint8 = .{
188+ .sRGB = .{
189+ .value = .{ 0x7d , 0xcf , 0xff , 0xff },
190+ },
191+ },
192+ },
193+ .{
194+ .uint8 = .{
195+ .sRGB = .{
196+ .value = .{ 0x7a , 0xa2 , 0xf7 , 0xff },
197+ },
198+ },
199+ },
200+ .{
201+ .uint8 = .{
202+ .sRGB = .{
203+ .value = .{ 0xbb , 0x9a , 0xf7 , 0xff },
204+ },
205+ },
206+ },
207+ .{
208+ .uint8 = .{
209+ .sRGB = .{
210+ .value = .{ 0xc0 , 0xca , 0xf5 , 0xff },
211+ },
212+ },
213+ },
214+ .{
215+ .uint8 = .{
216+ .sRGB = .{
217+ .value = .{ 0xa9 , 0xb1 , 0xd6 , 0xff },
218+ },
219+ },
220+ },
221+ .{
222+ .uint8 = .{
223+ .sRGB = .{
224+ .value = .{ 0x9a , 0xa5 , 0xce , 0xff },
225+ },
226+ },
227+ },
228+ .{
229+ .uint8 = .{
230+ .sRGB = .{
231+ .value = .{ 0xcf , 0xc9 , 0xc2 , 0xff },
232+ },
233+ },
234+ },
235+ .{
236+ .uint8 = .{
237+ .sRGB = .{
238+ .value = .{ 0x56 , 0x5f , 0x89 , 0xff },
239+ },
240+ },
241+ },
242+ .{
243+ .uint8 = .{
244+ .sRGB = .{
245+ .value = .{ 0x41 , 0x48 , 0x68 , 0xff },
246+ },
247+ },
248+ },
249+ .{
250+ .uint8 = .{
251+ .sRGB = .{
252+ .value = .{ 0x24 , 0x28 , 0x3b , 0xff },
253+ },
254+ },
255+ },
256+ },
257+ };
258+
14259 const alloc = if (builtin .link_libc ) std .heap .c_allocator else if (builtin .os .tag == .uefi ) std .os .uefi .pool_allocator else std .heap .page_allocator ;
15260
16261 var display = displayBackend .Display .init (alloc , .compositor );
@@ -26,7 +271,7 @@ pub fn main() void {
26271 .scale = vizops .vector .Float32Vector2 .init (1.0 ),
27272 .name = "display-0" ,
28273 .manufacturer = "PhantomUI" ,
29- .format = try vizops .color .fourcc .Value .decode (vizops .color .fourcc .formats .argb16161616 ),
274+ .colorFormat = vizops .color .fourcc .Value .decode (vizops .color .fourcc .formats .argb16161616 ) catch | e | @panic ( @errorName ( e ) ),
30275 }) catch | e | @panic (@errorName (e ));
31276 }
32277
@@ -47,6 +292,31 @@ pub fn main() void {
47292 }
48293
49294 const scene = surface .createScene (@enumFromInt (@intFromEnum (sceneBackendType ))) catch | e | @panic (@errorName (e ));
50- _ = scene ;
51- // TODO: render something to the scene
295+
296+ var children : [17 ]* phantom.scene.Node = undefined ;
297+
298+ for (& children , colors [0 ]) | * child , color | {
299+ child .* = scene .createNode (.NodeRect , .{
300+ .color = color ,
301+ .size = vizops .vector .Float32Vector2 .init ([_ ]f32 { 100.0 / 17.0 , 100.0 }),
302+ }) catch | e | @panic (@errorName (e ));
303+ }
304+
305+ const flex = scene .createNode (.NodeFlex , .{
306+ .direction = phantom .painting .Axis .horizontal ,
307+ .children = & children ,
308+ }) catch | e | @panic (@errorName (e ));
309+ defer flex .deinit ();
310+
311+ var i : usize = 0 ;
312+ while (i < 5 ) : (i += 1 ) {
313+ _ = scene .frame (flex ) catch | e | @panic (@errorName (e ));
314+
315+ const currPalette = scene .seq % colors .len ;
316+ for (children , colors [currPalette ]) | child , color | {
317+ child .setProperties (.{ .color = color }) catch | e | @panic (@errorName (e ));
318+ }
319+
320+ flex .setProperties (.{ .children = & children }) catch | e | @panic (@errorName (e ));
321+ }
52322}
0 commit comments