Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_add_stroke.c
| Show All 13 Lines | |||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_gpencil.h" | #include "BKE_gpencil.h" | ||||
| #include "BKE_gpencil_geom.h" | #include "BKE_gpencil_geom.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BLT_translation.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "ED_gpencil.h" | #include "ED_gpencil.h" | ||||
| /* Definition of the most important info from a color */ | /* Definition of the most important info from a color */ | ||||
| typedef struct ColorTemplate { | typedef struct ColorTemplate { | ||||
| const char *name; | const char *name; | ||||
| float line[4]; | float line[4]; | ||||
| float fill[4]; | float fill[4]; | ||||
| } ColorTemplate; | } ColorTemplate; | ||||
| /* Add color an ensure duplications (matched by name) */ | /* Add color an ensure duplications (matched by name) */ | ||||
| static int gpencil_stroke_material(Main *bmain, | static int gpencil_stroke_material(Main *bmain, | ||||
| Object *ob, | Object *ob, | ||||
| const ColorTemplate *pct, | const ColorTemplate *pct, | ||||
| const bool fill) | const bool fill) | ||||
| { | { | ||||
| int index; | int index; | ||||
| Material *ma = BKE_gpencil_object_material_ensure_by_name(bmain, ob, pct->name, &index); | Material *ma = BKE_gpencil_object_material_ensure_by_name(bmain, ob, DATA_(pct->name), &index); | ||||
| copy_v4_v4(ma->gp_style->stroke_rgba, pct->line); | copy_v4_v4(ma->gp_style->stroke_rgba, pct->line); | ||||
| srgb_to_linearrgb_v4(ma->gp_style->stroke_rgba, ma->gp_style->stroke_rgba); | srgb_to_linearrgb_v4(ma->gp_style->stroke_rgba, ma->gp_style->stroke_rgba); | ||||
| copy_v4_v4(ma->gp_style->fill_rgba, pct->fill); | copy_v4_v4(ma->gp_style->fill_rgba, pct->fill); | ||||
| srgb_to_linearrgb_v4(ma->gp_style->fill_rgba, ma->gp_style->fill_rgba); | srgb_to_linearrgb_v4(ma->gp_style->fill_rgba, ma->gp_style->fill_rgba); | ||||
| if (fill) { | if (fill) { | ||||
| ▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | static const float data0[175 * GP_PRIM_DATABUF_SIZE] = { | ||||
| 1.169f, 0.0f, 0.671f, 0.236f, 1.0f, 1.207f, 0.0f, 0.693f, 0.202f, 1.0f, | 1.169f, 0.0f, 0.671f, 0.236f, 1.0f, 1.207f, 0.0f, 0.693f, 0.202f, 1.0f, | ||||
| 1.264f, 0.0f, 0.725f, 0.155f, 1.0f, | 1.264f, 0.0f, 0.725f, 0.155f, 1.0f, | ||||
| }; | }; | ||||
| /* ***************************************************************** */ | /* ***************************************************************** */ | ||||
| /* Color Data */ | /* Color Data */ | ||||
| static const ColorTemplate gp_stroke_material_black = { | static const ColorTemplate gp_stroke_material_black = { | ||||
| "Black", | N_("Black"), | ||||
| {0.0f, 0.0f, 0.0f, 1.0f}, | {0.0f, 0.0f, 0.0f, 1.0f}, | ||||
| {0.0f, 0.0f, 0.0f, 0.0f}, | {0.0f, 0.0f, 0.0f, 0.0f}, | ||||
| }; | }; | ||||
| static const ColorTemplate gp_stroke_material_white = { | static const ColorTemplate gp_stroke_material_white = { | ||||
| "White", | N_("White"), | ||||
| {1.0f, 1.0f, 1.0f, 1.0f}, | {1.0f, 1.0f, 1.0f, 1.0f}, | ||||
| {0.0f, 0.0f, 0.0f, 0.0f}, | {0.0f, 0.0f, 0.0f, 0.0f}, | ||||
| }; | }; | ||||
| static const ColorTemplate gp_stroke_material_red = { | static const ColorTemplate gp_stroke_material_red = { | ||||
| "Red", | N_("Red"), | ||||
| {1.0f, 0.0f, 0.0f, 1.0f}, | {1.0f, 0.0f, 0.0f, 1.0f}, | ||||
| {0.0f, 0.0f, 0.0f, 0.0f}, | {0.0f, 0.0f, 0.0f, 0.0f}, | ||||
| }; | }; | ||||
| static const ColorTemplate gp_stroke_material_green = { | static const ColorTemplate gp_stroke_material_green = { | ||||
| "Green", | N_("Green"), | ||||
| {0.0f, 1.0f, 0.0f, 1.0f}, | {0.0f, 1.0f, 0.0f, 1.0f}, | ||||
| {0.0f, 0.0f, 0.0f, 0.0f}, | {0.0f, 0.0f, 0.0f, 0.0f}, | ||||
| }; | }; | ||||
| static const ColorTemplate gp_stroke_material_blue = { | static const ColorTemplate gp_stroke_material_blue = { | ||||
| "Blue", | N_("Blue"), | ||||
| {0.0f, 0.0f, 1.0f, 1.0f}, | {0.0f, 0.0f, 1.0f, 1.0f}, | ||||
| {0.0f, 0.0f, 0.0f, 0.0f}, | {0.0f, 0.0f, 0.0f, 0.0f}, | ||||
| }; | }; | ||||
| static const ColorTemplate gp_stroke_material_grey = { | static const ColorTemplate gp_stroke_material_grey = { | ||||
| "Grey", | N_("Grey"), | ||||
| {0.358f, 0.358f, 0.358f, 1.0f}, | {0.358f, 0.358f, 0.358f, 1.0f}, | ||||
| {0.5f, 0.5f, 0.5f, 1.0f}, | {0.5f, 0.5f, 0.5f, 1.0f}, | ||||
| }; | }; | ||||
| /* ***************************************************************** */ | /* ***************************************************************** */ | ||||
| /* Stroke API */ | /* Stroke API */ | ||||
| void ED_gpencil_create_stroke(bContext *C, Object *ob, float mat[4][4]) | void ED_gpencil_create_stroke(bContext *C, Object *ob, float mat[4][4]) | ||||
| Show All 35 Lines | |||||