Skip to content

Commit ff20831

Browse files
committed
add gradient rect to tinywl
1 parent 46f3c21 commit ff20831

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

include/scenefx/types/fx/gradient.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ struct gradient {
77
float origin[2]; // center of the gradient, { 0.5, 0.5 } for normal
88
bool is_linear; // else is conic
99
float should_blend;
10-
1110
int count;
1211
float *colors;
1312
};
1413

15-
1614
#endif // TYPES_FX_GRADIENT_H

render/fx_renderer/gles2/shaders/gradient.frag

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ vec4 gradient(vec4 colors[LEN], int count, vec2 size, vec2 grad_box,
1919
uv = vec2(uv.x * cos(rad) - uv.y * sin(rad),
2020
uv.x * sin(rad) + uv.y * cos(rad));
2121

22-
uv = vec2(-atan(uv.y, uv.x)/3.14159265 * 0.5 + 0.5, 0.0);
22+
uv = vec2(-atan(uv.y, uv.x) / 3.14159265 * 0.5 + 0.5, 0.0);
2323
step = uv.x;
2424
}
2525

2626
if (!should_blend) {
27-
float smooth = 1.0/float(count);
28-
int ind = int(step/smooth);
27+
float smooth = 1.0 / float(count);
28+
int ind = int(step / smooth);
2929

3030
return colors[ind];
3131
}
3232

33-
float smooth = 1.0/float(count - 1);
34-
int ind = int(step/smooth);
35-
float at = float(ind)*smooth;
33+
float smooth = 1.0 / float(count - 1);
34+
int ind = int(step / smooth);
35+
float at = float(ind) * smooth;
3636

3737
vec4 color = colors[ind];
3838
if(ind > 0) color = mix(colors[ind - 1], color, smoothstep(at - smooth, at, step));

tinywl/tinywl.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,22 +1145,25 @@ int main(int argc, char *argv[]) {
11451145

11461146
/* Add a bottom rect to demonstrate optimized blur */
11471147
float bottom_rect_color[4] = { 1, 1, 1, 1 };
1148-
wlr_scene_rect_create(server.layers.bottom_layer, 200, 200, bottom_rect_color);
1149-
/*
1148+
struct wlr_scene_rect *bottom_rect = wlr_scene_rect_create(server.layers.bottom_layer,
1149+
200, 200, bottom_rect_color);
11501150
wlr_scene_rect_set_gradient(
11511151
bottom_rect,
11521152
(struct gradient) {
11531153
.degree = 0.0,
11541154
.range = (struct wlr_box) {
1155+
.x = 0,
1156+
.y = 0,
1157+
.width = 200,
1158+
.height = 200,
11551159
},
1156-
.origin = {},
1160+
.origin = { 0.5, 0.5 },
11571161
.is_linear = true,
11581162
.should_blend = true,
1159-
.count = 0,
1160-
.colors = {},
1163+
.count = 1,
1164+
.colors = bottom_rect_color,
11611165
}
11621166
);
1163-
*/
11641167

11651168
/* Set the size later */
11661169
server.layers.blur_layer = wlr_scene_optimized_blur_create(&server.scene->tree, 0, 0);

0 commit comments

Comments
 (0)