- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
// https://github.com/x42/darc.lv2/blob/7f1f42b879777e570c83fd566ac28cbfdd51e6fc/src/lv2.c#L508
static void
create_pattern (Darc* self, const double w)
{
const int x0 = floor (w * 0.05);
const int x1 = ceil (w * 0.95);
const int wd = x1 - x0;
#define DEF(x) ((x0 + wd * ((x) + 20.) / 60.) / w)
cairo_pattern_t* pat = cairo_pattern_create_linear (0.0, 0.0, w, 0);
/* clang-format off */
cairo_pattern_add_color_stop_rgba (pat, 1.0, .0, .5, .0, 0);
cairo_pattern_add_color_stop_rgba (pat, DEF (40), .0, .5, .0, 0.5);
cairo_pattern_add_color_stop_rgba (pat, DEF (5), .0, .5, .0, 0.5);
cairo_pattern_add_color_stop_rgba (pat, DEF (-5), .5, .0, .0, 0.5);
cairo_pattern_add_color_stop_rgba (pat, DEF (-20), .5, .0, .0, 0.5);
cairo_pattern_add_color_stop_rgba (pat, 0.0, .5, .0, .0, 0);
/* clang-format on */
self->mpat = pat;
pat = cairo_pattern_create_linear (0.0, 0.0, w, 0);
/* clang-format off */
cairo_pattern_add_color_stop_rgba (pat, 1.0, .1, .9, .1, 0);
cairo_pattern_add_color_stop_rgba (pat, DEF (40), .1, .9, .1, 1);
cairo_pattern_add_color_stop_rgba (pat, DEF (5), .1, .9, .1, 1);
cairo_pattern_add_color_stop_rgba (pat, DEF (-5), .9, .9, .1, 1);
cairo_pattern_add_color_stop_rgba (pat, DEF (-20), .9, .9, .1, 1);
cairo_pattern_add_color_stop_rgba (pat, 0.0, .9, .9, .1, 0);
/* clang-format on */
self->cpat = pat;
#undef DEF
}
Отключаем и включаем clang-формат, чтобы отступы красиво были. Да еще и такой вот локальный дефайн!