BLF: use float vector passing color args
This commit is contained in:
@@ -153,7 +153,7 @@ void BLF_disable(int fontid, int option);
|
||||
* the other argument are the rgba color.
|
||||
* Take care that shadow need to be enable using BLF_enable!!!
|
||||
*/
|
||||
void BLF_shadow(int fontid, int level, float r, float g, float b, float a);
|
||||
void BLF_shadow(int fontid, int level, const float rgba[4]) ATTR_NONNULL(3);
|
||||
|
||||
/* Set the offset for shadow text, this is the current cursor
|
||||
* position plus this offset, don't need call BLF_position before
|
||||
@@ -174,7 +174,7 @@ void BLF_shadow_offset(int fontid, int x, int y);
|
||||
void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, struct ColorManagedDisplay *display);
|
||||
|
||||
/* Set the color to be used for text. */
|
||||
void BLF_buffer_col(int fontid, float r, float g, float b, float a);
|
||||
void BLF_buffer_col(int fontid, const float rgba[4]) ATTR_NONNULL(2);
|
||||
|
||||
/* Draw the string into the buffer, this function draw in both buffer, float and unsigned char _BUT_
|
||||
* it's not necessary set both buffer, NULL is valid here.
|
||||
|
@@ -849,16 +849,13 @@ void BLF_wordwrap(int fontid, int wrap_width)
|
||||
}
|
||||
}
|
||||
|
||||
void BLF_shadow(int fontid, int level, float r, float g, float b, float a)
|
||||
void BLF_shadow(int fontid, int level, const float rgba[4])
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
|
||||
if (font) {
|
||||
font->shadow = level;
|
||||
font->shadow_col[0] = r;
|
||||
font->shadow_col[1] = g;
|
||||
font->shadow_col[2] = b;
|
||||
font->shadow_col[3] = a;
|
||||
copy_v4_v4(font->shadow_col, rgba);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -886,12 +883,12 @@ void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int
|
||||
}
|
||||
}
|
||||
|
||||
void BLF_buffer_col(int fontid, float r, float g, float b, float a)
|
||||
void BLF_buffer_col(int fontid, const float rgba[4])
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
|
||||
if (font) {
|
||||
ARRAY_SET_ITEMS(font->buf_info.col_init, r, g, b, a);
|
||||
copy_v4_v4(font->buf_info.col_init, rgba);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1992,7 +1992,7 @@ void BKE_image_stamp_buf(
|
||||
BLF_wordwrap(mono, width - (BUFF_MARGIN_X * 2));
|
||||
|
||||
BLF_buffer(mono, rectf, rect, width, height, channels, display);
|
||||
BLF_buffer_col(mono, UNPACK4(scene->r.fg_stamp));
|
||||
BLF_buffer_col(mono, scene->r.fg_stamp);
|
||||
pad = BLF_width_max(mono);
|
||||
|
||||
/* use 'h_fixed' rather than 'h', aligns better */
|
||||
|
@@ -297,6 +297,9 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
|
||||
*/
|
||||
BLF_buffer(mono, rect_float, rect, width, height, 4, NULL);
|
||||
|
||||
const float text_color[4] = {0.0, 0.0, 0.0, 1.0};
|
||||
const float text_outline[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
|
||||
for (y = 0; y < height; y += step) {
|
||||
text[1] = '1';
|
||||
|
||||
@@ -306,7 +309,7 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
|
||||
pen_y = y + 44;
|
||||
|
||||
/* terribly crappy outline font! */
|
||||
BLF_buffer_col(mono, 1.0, 1.0, 1.0, 1.0);
|
||||
BLF_buffer_col(mono, text_outline);
|
||||
|
||||
BLF_position(mono, pen_x - outline, pen_y, 0.0);
|
||||
BLF_draw_buffer(mono, text, 2);
|
||||
@@ -326,7 +329,7 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
|
||||
BLF_position(mono, pen_x + outline, pen_y - outline, 0.0);
|
||||
BLF_draw_buffer(mono, text, 2);
|
||||
|
||||
BLF_buffer_col(mono, 0.0, 0.0, 0.0, 1.0);
|
||||
BLF_buffer_col(mono, text_color);
|
||||
BLF_position(mono, pen_x, pen_y, 0.0);
|
||||
BLF_draw_buffer(mono, text, 2);
|
||||
|
||||
|
@@ -3188,11 +3188,11 @@ static ImBuf *do_text_effect(const SeqRenderData *context, Sequence *seq, float
|
||||
fontx = BLF_width_max(mono);
|
||||
fonty = line_height;
|
||||
BLF_position(mono, x + max_ii(fontx / 25, 1), y + max_ii(fonty / 25, 1), 0.0f);
|
||||
BLF_buffer_col(mono, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
BLF_buffer_col(mono, (const float[4]){0.0f, 0.0f, 0.0f, 1.0f});
|
||||
BLF_draw_buffer(mono, data->text, BLF_DRAW_STR_DUMMY_MAX);
|
||||
}
|
||||
BLF_position(mono, x, y, 0.0f);
|
||||
BLF_buffer_col(mono, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
BLF_buffer_col(mono, (const float[4]){1.0f, 1.0f, 1.0f, 1.0f});
|
||||
BLF_draw_buffer(mono, data->text, BLF_DRAW_STR_DUMMY_MAX);
|
||||
|
||||
BLF_buffer(mono, NULL, NULL, 0, 0, 0, NULL);
|
||||
|
@@ -1679,7 +1679,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
|
||||
BLF_size(fontid, fstyle_points, U.dpi);
|
||||
|
||||
BLF_enable(fontid, BLF_SHADOW);
|
||||
BLF_shadow(fontid, 3, 1.0f, 1.0f, 1.0f, 0.25f);
|
||||
BLF_shadow(fontid, 3, (const float[4]){1.0f, 1.0f, 1.0f, 0.25f});
|
||||
BLF_shadow_offset(fontid, -1, -1);
|
||||
|
||||
BLI_assert(UI_panel_category_is_visible(ar));
|
||||
|
@@ -160,7 +160,8 @@ void UI_fontstyle_draw_ex(
|
||||
/* set the flag */
|
||||
if (fs->shadow) {
|
||||
font_flag |= BLF_SHADOW;
|
||||
BLF_shadow(fs->uifont_id, fs->shadow, fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha);
|
||||
const float shadow_color[4] = {fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha};
|
||||
BLF_shadow(fs->uifont_id, fs->shadow, shadow_color);
|
||||
BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
|
||||
}
|
||||
if (fs->kerning == 1) {
|
||||
@@ -251,7 +252,8 @@ void UI_fontstyle_draw_rotated(const uiFontStyle *fs, const rcti *rect, const ch
|
||||
|
||||
if (fs->shadow) {
|
||||
BLF_enable(fs->uifont_id, BLF_SHADOW);
|
||||
BLF_shadow(fs->uifont_id, fs->shadow, fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha);
|
||||
const float shadow_color[4] = {fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha};
|
||||
BLF_shadow(fs->uifont_id, fs->shadow, shadow_color);
|
||||
BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
|
||||
}
|
||||
|
||||
|
@@ -332,17 +332,21 @@ PyDoc_STRVAR(py_blf_shadow_doc,
|
||||
static PyObject *py_blf_shadow(PyObject *UNUSED(self), PyObject *args)
|
||||
{
|
||||
int level, fontid;
|
||||
float r, g, b, a;
|
||||
float rgba[4];
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iiffff:blf.shadow", &fontid, &level, &r, &g, &b, &a))
|
||||
if (!PyArg_ParseTuple(
|
||||
args, "iiffff:blf.shadow",
|
||||
&fontid, &level, &rgba[0], &rgba[1], &rgba[2], &rgba[3]))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (level != 0 && level != 3 && level != 5) {
|
||||
PyErr_SetString(PyExc_TypeError, "blf.shadow expected arg to be in (0, 3, 5)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BLF_shadow(fontid, level, r, g, b, a);
|
||||
BLF_shadow(fontid, level, rgba);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
@@ -3124,7 +3124,7 @@ static void radial_control_paint_cursor(bContext *C, int x, int y, void *customd
|
||||
|
||||
BLF_size(fontid, 1.5 * fstyle_points, 1.0f / U.dpi);
|
||||
BLF_enable(fontid, BLF_SHADOW);
|
||||
BLF_shadow(fontid, 3, 0.0f, 0.0f, 0.0f, 0.5f);
|
||||
BLF_shadow(fontid, 3, (const float[4]){0.0f, 0.0f, 0.0f, 0.5f});
|
||||
BLF_shadow_offset(fontid, 1, -1);
|
||||
|
||||
/* draw value */
|
||||
|
Reference in New Issue
Block a user