68 int size = int(scalar * old_size);
70 if (
abs(old_size -
size) <
U.pixelsize) {
74 else if (scalar < 1) {
79 if (use_unified_size) {
90 float unprojected_size = scalar * (use_unified_size ?
94 unprojected_size = std::max(unprojected_size, 0.001f);
96 if (use_unified_size) {
114 ot->name =
"Scale Sculpt/Paint Brush Size";
115 ot->description =
"Change brush size by a scalar";
116 ot->idname =
"BRUSH_OT_scale_size";
124 RNA_def_float(
ot->srna,
"scalar", 1, 0, 2,
"Scalar",
"Factor to scale brush size by", 0, 2);
145 ot->name =
"Add New Palette";
146 ot->description =
"Add new palette";
147 ot->idname =
"PALETTE_OT_new";
204 ot->name =
"New Palette Color";
205 ot->description =
"Add new color to active palette";
206 ot->idname =
"PALETTE_OT_color_add";
232 ot->name =
"Delete Palette Color";
233 ot->description =
"Remove active color from palette";
234 ot->idname =
"PALETTE_OT_color_delete";
275 const int range = int(
pow(10.0f, threshold));
276 for (
int row = 0; row < ibuf->
y; row++) {
282 for (
int i = 0;
i < 3;
i++) {
283 color[
i] = truncf(color[
i] * range) / range;
312 ot->name =
"Extract Palette from Image";
313 ot->idname =
"PALETTE_OT_extract_from_image";
314 ot->description =
"Extract all colors used in Image and create a Palette";
324 prop =
RNA_def_int(
ot->srna,
"threshold", 1, 1, 1,
"Threshold",
"", 1, 1);
336 if (palette ==
nullptr) {
351 rgb_to_hsv(color->color[0], color->color[1], color->color[2], &h, &s, &
v);
352 col_elm = &color_array[t];
354 col_elm->
value = color->value;
364 else if (type == 2) {
367 else if (type == 3) {
380 for (
int i = 0;
i < totcol;
i++) {
381 col_elm = &color_array[
i];
402 {1,
"HSV", 0,
"Hue, Saturation, Value",
""},
403 {2,
"SVH", 0,
"Saturation, Value, Hue",
""},
404 {3,
"VHS", 0,
"Value, Hue, Saturation",
""},
405 {4,
"LUMINANCE", 0,
"Luminance",
""},
406 {0,
nullptr, 0,
nullptr,
nullptr},
410 ot->name =
"Sort Palette";
411 ot->idname =
"PALETTE_OT_sort";
412 ot->description =
"Sort Palette Colors";
432 if (palcolor ==
nullptr) {
450 {-1,
"UP", 0,
"Up",
""},
451 {1,
"DOWN", 0,
"Down",
""},
452 {0,
nullptr, 0,
nullptr,
nullptr},
456 ot->name =
"Move Palette Color";
457 ot->idname =
"PALETTE_OT_color_move";
458 ot->description =
"Move the active Color up/down in the list";
476 Palette *palette_join =
nullptr;
482 if ((palette ==
nullptr) || (
name[0] ==
'\0')) {
487 if (palette_join ==
nullptr) {
498 palcol->
value = color->value;
520 ot->name =
"Join Palette Swatches";
521 ot->idname =
"PALETTE_OT_join";
522 ot->description =
"Join Palette Swatches";
659#define PIXEL_MARGIN 5
662 const float mvalf[2] = {
float(mval[0]),
float(mval[1])};
723 switch (event->
type) {
791 {0,
nullptr, 0,
nullptr,
nullptr},
797 {0,
nullptr, 0,
nullptr,
nullptr},
800 ot->name =
"Stencil Brush Control";
801 ot->description =
"Control the stencil brush";
802 ot->idname =
"BRUSH_OT_stencil_control";
828 MTex *mtex =
nullptr;
837 float orig_area, stencil_area, factor;
841 aspx *= mtex->
size[0];
842 aspy *= mtex->
size[1];
850 orig_area =
fabsf(aspx * aspy);
859 factor =
sqrtf(stencil_area / orig_area);
880 ot->name =
"Image Aspect";
882 "When using an image texture, adjust the stencil size to fit the image aspect ratio";
883 ot->idname =
"BRUSH_OT_stencil_fit_image_aspect";
892 RNA_def_boolean(
ot->srna,
"use_repeat",
true,
"Use Repeat",
"Use repeat mapping values");
893 RNA_def_boolean(
ot->srna,
"use_scale",
true,
"Use Scale",
"Use texture scale values");
895 ot->srna,
"mask",
false,
"Modify Mask Stencil",
"Modify either the primary or mask stencil");
936 ot->name =
"Reset Transform";
937 ot->description =
"Reset the stencil transformation to the default";
938 ot->idname =
"BRUSH_OT_stencil_reset_transform";
948 ot->srna,
"mask",
false,
"Modify Mask Stencil",
"Modify either the primary or mask stencil");
959 "Add Curve Point and Slide",
960 "Add new curve point and slide it",
962 ot->description =
"Add new curve point and slide it";
float BKE_brush_unprojected_size_get(const Paint *paint, const Brush *brush)
const float * BKE_brush_color_get(const Paint *paint, const Brush *brush)
void BKE_brush_size_set(Paint *paint, Brush *brush, int size)
void BKE_brush_unprojected_size_set(Paint *paint, Brush *brush, float unprojected_size)
void BKE_brush_tag_unsaved_changes(Brush *brush)
int BKE_brush_size_get(const Paint *paint, const Brush *brush)
SpaceImage * CTX_wm_space_image(const bContext *C)
SpaceLink * CTX_wm_space_data(const bContext *C)
Main * CTX_data_main(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
bool BKE_image_has_ibuf(Image *ima, ImageUser *iuser)
ID * BKE_libblock_find_name(Main *bmain, short type, const char *name, const std::optional< Library * > lib=std::nullopt) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
PaletteColor * BKE_palette_color_add(Palette *palette)
void BKE_palette_sort_hsv(tPaletteColorHSV *color_array, int totcol)
void BKE_palette_sort_svh(tPaletteColorHSV *color_array, int totcol)
void BKE_palette_color_remove(Palette *palette, PaletteColor *color)
void BKE_palette_sort_vhs(tPaletteColorHSV *color_array, int totcol)
const Brush * BKE_paint_brush_for_read(const Paint *paint)
Paint * BKE_paint_get_active_from_context(const bContext *C)
Palette * BKE_palette_add(Main *bmain, const char *name)
bool BKE_palette_from_hash(Main *bmain, GHash *color_table, const char *name)
void BKE_palette_sort_luminance(tPaletteColorHSV *color_array, int totcol)
Brush * BKE_paint_brush(Paint *paint)
void BKE_paint_palette_set(Paint *paint, Palette *palette)
PaintMode BKE_paintmode_get_active_from_context(const bContext *C)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
bool BLI_ghash_haskey(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
GHash * BLI_ghash_int_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void void void bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL()
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
unsigned int rgb_to_cpack(float r, float g, float b)
void rgb_to_hsv(float r, float g, float b, float *r_h, float *r_s, float *r_v)
MINLINE float len_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void clamp_v2(float vec[2], float min, float max)
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void zero_v3(float r[3])
#define POINTER_FROM_INT(i)
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
@ OB_MODE_PAINT_GREASE_PENCIL
void ED_image_get_uv_aspect(Image *ima, ImageUser *iuser, float *r_aspx, float *r_aspy)
void ED_region_tag_redraw(ARegion *region)
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
BLI_INLINE void IMB_colormanagement_scene_linear_to_srgb_v3(float srgb[3], const float scene_linear[3])
void IMB_sampleImageAtLocation(ImBuf *ibuf, float x, float y, float scene_linear_rgb[3])
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void * MEM_mallocN(size_t len, const char *str)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
void modal_keymap(wmKeyConfig *keyconf)
void PAINT_OT_hide_show_polyline_gesture(wmOperatorType *ot)
void PAINT_OT_hide_show_masked(wmOperatorType *ot)
void PAINT_OT_hide_show_line_gesture(wmOperatorType *ot)
void PAINT_OT_visibility_invert(wmOperatorType *ot)
void PAINT_OT_hide_show_lasso_gesture(wmOperatorType *ot)
void PAINT_OT_visibility_filter(wmOperatorType *ot)
void PAINT_OT_hide_show_all(wmOperatorType *ot)
void PAINT_OT_hide_show(wmOperatorType *ot)
void PAINT_OT_mask_polyline_gesture(wmOperatorType *ot)
void PAINT_OT_mask_line_gesture(wmOperatorType *ot)
void PAINT_OT_mask_box_gesture(wmOperatorType *ot)
void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot)
void PAINT_OT_mask_flood_fill(wmOperatorType *ot)
bool curves_sculpt_poll(bContext *C)
void BRUSH_OT_asset_save(wmOperatorType *ot)
bool paint_supports_texture(PaintMode mode)
void BRUSH_OT_asset_delete(wmOperatorType *ot)
void BRUSH_OT_asset_edit_metadata(wmOperatorType *ot)
void BRUSH_OT_asset_load_preview(wmOperatorType *ot)
void BRUSH_OT_asset_revert(wmOperatorType *ot)
wmKeyMap * paint_stroke_modal_keymap(wmKeyConfig *keyconf)
void BRUSH_OT_asset_save_as(wmOperatorType *ot)
void BRUSH_OT_asset_activate(wmOperatorType *ot)
bool paint_curve_poll(bContext *C)
void PAINTCURVE_OT_new(wmOperatorType *ot)
void PAINTCURVE_OT_add_point(wmOperatorType *ot)
void PAINTCURVE_OT_delete_point(wmOperatorType *ot)
void PAINTCURVE_OT_draw(wmOperatorType *ot)
void PAINTCURVE_OT_cursor(wmOperatorType *ot)
void PAINTCURVE_OT_slide(wmOperatorType *ot)
void PAINTCURVE_OT_select(wmOperatorType *ot)
bool vert_paint_poll(bContext *C)
bool facemask_paint_poll(bContext *C)
bool image_texture_paint_poll(bContext *C)
void PAINT_OT_texture_paint_toggle(wmOperatorType *ot)
void PAINT_OT_brush_colors_flip(wmOperatorType *ot)
void PAINT_OT_grab_clone(wmOperatorType *ot)
void PAINT_OT_image_paint(wmOperatorType *ot)
void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot)
void PAINT_OT_add_simple_uvs(wmOperatorType *ot)
void PAINT_OT_project_image(wmOperatorType *ot)
void PAINT_OT_image_from_view(wmOperatorType *ot)
void SCULPT_OT_uv_sculpt_relax(wmOperatorType *ot)
void PAINT_OT_weight_set(wmOperatorType *ot)
void PAINT_OT_vertex_color_set(wmOperatorType *ot)
void PAINT_OT_face_select_more(wmOperatorType *ot)
void PAINT_OT_vert_select_less(wmOperatorType *ot)
void PAINT_OT_vertex_color_smooth(wmOperatorType *ot)
void PAINT_OT_weight_paint(wmOperatorType *ot)
void PAINT_OT_face_select_hide(wmOperatorType *ot)
void PAINT_OT_face_select_loop(wmOperatorType *ot)
void PAINT_OT_vertex_color_hsv(wmOperatorType *ot)
void PAINT_OT_vert_select_linked(wmOperatorType *ot)
void PAINT_OT_vertex_paint(wmOperatorType *ot)
void PAINT_OT_face_select_linked_pick(wmOperatorType *ot)
bool weight_paint_mode_poll(bContext *C)
void PAINT_OT_vert_select_linked_pick(wmOperatorType *ot)
void PAINT_OT_vert_select_ungrouped(wmOperatorType *ot)
void PAINT_OT_sample_color(wmOperatorType *ot)
void PAINT_OT_face_select_less(wmOperatorType *ot)
void PAINT_OT_weight_sample(wmOperatorType *ot)
void PAINT_OT_vert_select_all(wmOperatorType *ot)
void PAINT_OT_vertex_color_levels(wmOperatorType *ot)
void PAINT_OT_face_select_all(wmOperatorType *ot)
void PAINT_OT_vertex_color_from_weight(wmOperatorType *ot)
void PAINT_OT_face_select_linked(wmOperatorType *ot)
bool vertex_paint_mode_poll(bContext *C)
void PAINT_OT_weight_from_bones(wmOperatorType *ot)
void PAINT_OT_vertex_color_brightness_contrast(wmOperatorType *ot)
void PAINT_OT_weight_paint_toggle(wmOperatorType *ot)
void PAINT_OT_weight_gradient(wmOperatorType *ot)
void SCULPT_OT_uv_sculpt_pinch(wmOperatorType *ot)
void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot)
void PAINT_OT_vertex_color_invert(wmOperatorType *ot)
void PAINT_OT_vert_select_hide(wmOperatorType *ot)
void PAINT_OT_weight_sample_group(wmOperatorType *ot)
void PAINT_OT_vert_select_more(wmOperatorType *ot)
void SCULPT_OT_uv_sculpt_grab(wmOperatorType *ot)
void PAINT_OT_face_vert_reveal(wmOperatorType *ot)
static void BRUSH_OT_scale_size(wmOperatorType *ot)
static wmOperatorStatus palette_color_delete_exec(bContext *C, wmOperator *)
static void PALETTE_OT_join(wmOperatorType *ot)
static bool stencil_control_poll(bContext *C)
void ED_operatortypes_paint()
static void PALETTE_OT_extract_from_image(wmOperatorType *ot)
static void BRUSH_OT_stencil_reset_transform(wmOperatorType *ot)
static wmOperatorStatus palette_sort_exec(bContext *C, wmOperator *op)
static bool palette_poll(bContext *C)
static wmOperatorStatus palette_join_exec(bContext *C, wmOperator *op)
static wmOperatorStatus stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void BRUSH_OT_stencil_fit_image_aspect(wmOperatorType *ot)
static wmOperatorStatus palette_color_add_exec(bContext *C, wmOperator *)
static void stencil_control_calculate(StencilControlData *scd, const int mval[2])
static wmOperatorStatus stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void stencil_set_target(StencilControlData *scd)
static wmOperatorStatus palette_new_exec(bContext *C, wmOperator *)
void ED_operatormacros_paint()
static wmOperatorStatus palette_extract_img_exec(bContext *C, wmOperator *op)
static void PALETTE_OT_new(wmOperatorType *ot)
static void PALETTE_OT_color_delete(wmOperatorType *ot)
static void PALETTE_OT_color_move(wmOperatorType *ot)
static wmOperatorStatus brush_scale_size_exec(bContext *C, wmOperator *op)
static void PALETTE_OT_color_add(wmOperatorType *ot)
static wmOperatorStatus stencil_reset_transform_exec(bContext *C, wmOperator *op)
static void BRUSH_OT_stencil_control(wmOperatorType *ot)
static wmOperatorStatus palette_color_move_exec(bContext *C, wmOperator *op)
static void stencil_restore(StencilControlData *scd)
static bool palette_extract_img_poll(bContext *C)
static void PALETTE_OT_sort(wmOperatorType *ot)
static void stencil_control_cancel(bContext *, wmOperator *op)
static wmOperatorStatus stencil_fit_image_aspect_exec(bContext *C, wmOperator *op)
void ED_keymap_paint(wmKeyConfig *keyconf)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
int RNA_int_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
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)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
bool SCULPT_mode_poll(bContext *C)
float stencil_dimension[2]
float mask_stencil_pos[2]
struct BrushGpencilSettings * gpencil_settings
float mask_stencil_dimension[2]
ImBufByteBuffer byte_buffer
StencilConstraint constrain_mode
bool(* poll)(struct bContext *)
struct ReportList * reports
int WM_userdef_event_type_from_keymap_type(int kmitype)
void WM_main_add_notifier(uint type, void *reference)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
wmOperatorTypeMacro * WM_operatortype_macro_define(wmOperatorType *ot, const char *idname)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
wmOperatorType * WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag)