41 {0,
nullptr, 0,
nullptr,
nullptr},
48 const bool use_selection_mask,
56 const IndexMask points = use_selection_mask ?
77 const IndexMask strokes = use_selection_mask ?
108 float delta = contrast / 2.0f;
117 if (contrast > 0.0f) {
118 gain = 1.0f - delta * 2.0f;
120 offset = gain * (brightness - delta);
124 gain =
math::max(1.0f - delta * 2.0f, 0.0f);
125 offset = gain * brightness + delta;
128 std::atomic<bool> any_changed;
144 any_changed.store(any_changed | changed, std::memory_order_relaxed);
157 ot->
name =
"Vertex Paint Brightness/Contrast";
158 ot->
idname =
"GREASE_PENCIL_OT_vertex_color_brightness_contrast";
159 ot->
description =
"Adjust vertex color brightness/contrast";
172 RNA_def_float(ot->
srna,
"brightness", 0.0f, -1.0f, 1.0f,
"Brightness",
"", -1.0f, 1.0f);
173 RNA_def_float(ot->
srna,
"contrast", 0.0f, -1.0f, 1.0f,
"Contrast",
"", -1.0f, 1.0f);
187 std::atomic<bool> any_changed;
203 hsv[0] += (hue - 0.5f);
207 else if (hsv[0] < 0.0f) {
217 any_changed.store(any_changed | changed, std::memory_order_relaxed);
230 ot->
name =
"Vertex Paint Hue/Saturation/Value";
231 ot->
idname =
"GREASE_PENCIL_OT_vertex_color_hsv";
232 ot->
description =
"Adjust vertex color HSV values";
248 prop =
RNA_def_float(ot->
srna,
"s", 1.0f, 0.0f, 2.0f,
"Saturation",
"", 0.0f, 2.0f);
264 std::atomic<bool> any_changed;
280 any_changed.store(any_changed | changed, std::memory_order_relaxed);
293 ot->
name =
"Vertex Paint Invert";
294 ot->
idname =
"GREASE_PENCIL_OT_vertex_color_invert";
319 std::atomic<bool> any_changed;
335 any_changed.store(any_changed | changed, std::memory_order_relaxed);
348 ot->
name =
"Vertex Paint Levels";
349 ot->
idname =
"GREASE_PENCIL_OT_vertex_color_levels";
350 ot->
description =
"Adjust levels of vertex colors";
364 ot->
srna,
"offset", 0.0f, -1.0f, 1.0f,
"Offset",
"Value to add to colors", -1.0f, 1.0f);
366 ot->
srna,
"gain", 1.0f, 0.0f,
FLT_MAX,
"Gain",
"Value to multiply colors by", 0.0f, 10.0f);
381 const ColorGeometry4f target_color(color_linear[0], color_linear[1], color_linear[2], 1.0f);
383 std::atomic<bool> any_changed;
408 any_changed.store(any_changed | changed, std::memory_order_relaxed);
421 ot->
name =
"Vertex Paint Set Color";
422 ot->
idname =
"GREASE_PENCIL_OT_vertex_color_set";
423 ot->
description =
"Set active color to all selected vertices";
435 RNA_def_float(ot->
srna,
"factor", 1.0f, 0.0f, 1.0f,
"Factor",
"Mix Factor", 0.0f, 1.0f);
446 std::atomic<bool> any_changed;
454 bool changed =
false;
455 if (use_selection_mask) {
464 any_changed.store(any_changed | changed, std::memory_order_relaxed);
470 changed |=
curves.attributes_for_write().remove(
"vertex_color");
473 changed |=
curves.attributes_for_write().remove(
"fill_color");
475 any_changed.store(any_changed | changed, std::memory_order_relaxed);
488 ot->
name =
"Reset Vertex Color";
489 ot->
idname =
"GREASE_PENCIL_OT_stroke_reset_vertex_color";
490 ot->
description =
"Reset vertex color for all or selected strokes";
Low-level operations for curves.
Low-level operations for grease pencil.
#define BLT_I18NCONTEXT_COLOR
bool contains(StringRef name) const
AttributeAccessor attributes() const
bke::CurvesGeometry & strokes_for_write()
const bke::CurvesGeometry & strokes() const
MutableSpan< ColorGeometry4f > fill_colors_for_write()
MutableSpan< ColorGeometry4f > vertex_colors_for_write()
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
IndexMask retrieve_editable_and_selected_strokes(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
IndexMask retrieve_editable_points(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
static const EnumPropertyItem prop_grease_pencil_vertex_mode[]
static void GREASE_PENCIL_OT_vertex_color_levels(wmOperatorType *ot)
bool grease_pencil_vertex_painting_poll(bContext *C)
static wmOperatorStatus grease_pencil_vertex_paint_set_exec(bContext *C, wmOperator *op)
static wmOperatorStatus grease_pencil_vertex_paint_invert_exec(bContext *C, wmOperator *op)
static wmOperatorStatus grease_pencil_vertex_paint_hsv_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_stroke_reset_vertex_color(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_vertex_paint_brightness_contrast_exec(bContext *C, wmOperator *op)
IndexMask retrieve_editable_and_selected_points(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
static void GREASE_PENCIL_OT_vertex_color_brightness_contrast(wmOperatorType *ot)
static void GREASE_PENCIL_OT_vertex_color_set(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_vertex_paint_reset_exec(bContext *C, wmOperator *op)
static wmOperatorStatus grease_pencil_vertex_paint_levels_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_vertex_color_invert(wmOperatorType *ot)
static void GREASE_PENCIL_OT_vertex_color_hsv(wmOperatorType *ot)
static bool apply_color_operation_for_mode(const VertexColorMode mode, Object &object, MutableDrawingInfo &info, const bool use_selection_mask, Fn &&fn)
IndexMask retrieve_editable_strokes(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
Vector< MutableDrawingInfo > retrieve_editable_drawings(const Scene &scene, GreasePencil &grease_pencil)
constexpr ParallelGrainSize grain_size(int grain_size)
T interpolate(const T &a, const T &b, const FactorT &t)
T max(const T &a, const T &b)
void parallel_for_each(Range &&range, const Function &function)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
int RNA_enum_get(PointerRNA *ptr, const char *name)
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void DEG_id_tag_update(ID *id, unsigned int flags)
void hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
BMesh const char void * data
bool ED_grease_pencil_any_vertex_mask_selection(const ToolSettings *tool_settings)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Paint * BKE_paint_get_active_from_context(const bContext *C)
void ED_operatortypes_grease_pencil_vertex_paint()
Brush * BKE_paint_brush(Paint *paint)
Scene * CTX_data_scene(const bContext *C)
float3 BKE_brush_color_get(const Paint *paint, const Brush *brush)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
Object * CTX_data_active_object(const bContext *C)
float RNA_float_get(PointerRNA *ptr, const char *name)
struct ToolSettings * toolsettings
bke::greasepencil::Drawing & drawing
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT