61 sw =
bm->w < 79 ?
bm->w : 79;
62 sh =
bm->w < 79 ?
bm->h :
bm->h * sw * 44 / (79 *
bm->w);
64 for (yy = sh - 1; yy >= 0; yy--) {
65 for (xx = 0; xx < sw; xx++) {
67 for (
x = xx *
bm->w / sw;
x < (xx + 1) *
bm->w / sw;
x++) {
68 for (
y = yy *
bm->h / sh;
y < (yy + 1) *
bm->h / sh;
y++) {
74 fputc(d ?
'*' :
' ', f);
91 bm = (potrace_bitmap_t *)
MEM_mallocN(
sizeof(potrace_bitmap_t), __func__);
134 for (
y = 0;
y <
bm->h;
y++) {
136 for (i = 0; i < dy; i++) {
153 const float *frgba = &ibuf->
rect_float[idx * 4];
157 unsigned char *cp = (
unsigned char *)(ibuf->
rect + idx);
158 r_col[0] = (
float)cp[0] / 255.0f;
159 r_col[1] = (
float)cp[1] / 255.0f;
160 r_col[2] = (
float)cp[2] / 255.0f;
161 r_col[3] = (
float)cp[3] / 255.0f;
171 const potrace_bitmap_t *
bm,
172 const float threshold)
179 pixel = (ibuf->
x *
y) +
x;
183 float color = (rgba[0] + rgba[1] + rgba[2]) / 3.0f;
184 int32_t bw = (color > threshold) ? 0 : 1;
201 pt->
x = (
x - offset[0]) * scale;
203 pt->
z = (
y - offset[1]) * scale;
221 const float step = 1.0f / (
float)(resolution - 1);
224 for (
int32_t i = 0; i < resolution; i++) {
225 if ((!skip) || (i > 0)) {
228 add_point(gps, scale, offset, fpt[0], fpt[1]);
252 #define MAX_LENGTH 100.0f
257 const float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
259 if (mat_fill_idx == -1) {
267 mat_fill_idx = ob->
totcol - 1;
270 if (mat_mask_idx == -1) {
281 mat_mask_idx = ob->
totcol - 1;
284 potrace_path_t *path = st->plist;
286 potrace_dpoint_t(*
c)[3];
290 const float scalef = 0.008f * scale;
293 while (path !=
NULL) {
295 tag = path->curve.tag;
297 int mat_idx = path->sign ==
'+' ? mat_fill_idx : mat_mask_idx;
301 float start_point[2], last[2];
302 start_point[0] =
c[n - 1][2].x;
303 start_point[1] =
c[n - 1][2].y;
305 for (
int32_t i = 0; i < n; i++) {
307 case POTRACE_CORNER: {
309 add_point(gps, scalef, offset,
c[n - 1][2].
x,
c[n - 1][2].
y);
312 add_point(gps, scalef, offset, last[0], last[1]);
323 case POTRACE_CURVETO: {
324 float cp1[2], cp2[2], cp3[2], cp4[2];
326 cp1[0] = start_point[0];
327 cp1[1] = start_point[1];
typedef float(TangentPoint)[2]
struct bGPDstroke * BKE_gpencil_stroke_add(struct bGPDframe *gpf, int mat_idx, int totpoints, short thickness, const bool insert_at_head)
struct Material * BKE_gpencil_object_material_new(struct Main *bmain, struct Object *ob, const char *name, int *r_index)
void BKE_gpencil_free_stroke(struct bGPDstroke *gps)
int BKE_gpencil_material_find_index_by_name_prefix(struct Object *ob, const char *name_prefix)
float BKE_gpencil_stroke_length(const struct bGPDstroke *gps, bool use_3d)
void BKE_gpencil_stroke_geometry_update(struct bGPdata *gpd, struct bGPDstroke *gps)
bool BKE_gpencil_stroke_sample(struct bGPdata *gpd, struct bGPDstroke *gps, const float dist, const bool select)
General operations, lookup, etc. for materials.
void BLI_kdtree_nd_() free(KDTree *tree)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
void interp_v2_v2v2v2v2_cubic(float p[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2], const float u)
@ GP_MATERIAL_IS_STROKE_HOLDOUT
@ GP_MATERIAL_STROKE_SHOW
@ GP_MATERIAL_IS_FILL_HOLDOUT
Object is a sort of wrapper for general info.
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
#define MEM_recallocN(vmemh, len)
ATTR_WARN_UNUSED_RESULT BMesh * bm
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
#define bm_scanline(bm, y)
#define BM_PUT(bm, x, y, b)
void ED_gpencil_trace_data_to_strokes(Main *bmain, potrace_state_t *st, Object *ob, bGPDframe *gpf, int32_t offset[2], const float scale, const float sample, const int32_t resolution, const int32_t thickness)
static void add_point(bGPDstroke *gps, float scale, const int32_t offset[2], float x, float y)
void ED_gpencil_trace_bitmap_print(FILE *f, const potrace_bitmap_t *bm)
static void pixel_at_index(const ImBuf *ibuf, const int32_t idx, float r_col[4])
void ED_gpencil_trace_bitmap_free(const potrace_bitmap_t *bm)
static void add_bezier(bGPDstroke *gps, float scale, int32_t offset[2], int32_t resolution, float bcp1[2], float bcp2[2], float bcp3[2], float bcp4[2], const bool skip)
void ED_gpencil_trace_image_to_bitmap(ImBuf *ibuf, const potrace_bitmap_t *bm, const float threshold)
void ED_gpencil_trace_bitmap_invert(const potrace_bitmap_t *bm)
potrace_bitmap_t * ED_gpencil_trace_bitmap_new(int32_t w, int32_t h)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
static void sample(SocketReader *reader, int x, int y, float color[4])
struct MaterialGPencilStyle * gp_style