nuklear icon indicating copy to clipboard operation
nuklear copied to clipboard

how draw a shape with holes?

Open letarg0 opened this issue 5 years ago • 9 comments

How draw char 'A' ? from points

letarg0 avatar Feb 15 '19 11:02 letarg0

  1. Using xor and unions between shapes ?

1.1. Draw a black triangle 1.2. draw a white trapeze at the bottom of the black triangle (entered of course) 1.3. draw a white triangle on top of the trapeze

And you're done.

  1. Other way (just using black lines) : define a "path" to draw the letter ? (rough description, just follow the points by number)
        2
     1      3
  6  <------  5                
7                4

ebachard avatar Mar 01 '19 14:03 ebachard

Look up some existing bitmap font and use it. That should be the easiest, proven to be readable and in the end gives the opportunity to use other characters in the future while being graphically compatible.

dumblob avatar Mar 01 '19 20:03 dumblob

I need draw any polygon not only A ;)

@ebachard @dumblob ok,simplest question how draw triangle? for example SDL2 or how draw bitmap?

letarg0 avatar Mar 04 '19 15:03 letarg0

You can try to use nk_draw_list_stroke_poly_line() - see nuklear.h for parameters and "examples of its usage":

        case NK_COMMAND_TRIANGLE: {
            const struct nk_command_triangle *t = (const struct nk_command_triangle*)cmd;
            nk_draw_list_stroke_triangle(&ctx->draw_list, nk_vec2(t->a.x, t->a.y),
                nk_vec2(t->b.x, t->b.y), nk_vec2(t->c.x, t->c.y), t->color,
                t->line_thickness);
        } break;

For bitmaps the following might help.

        case NK_COMMAND_IMAGE: {
            const struct nk_command_image *i = (const struct nk_command_image*)cmd;
            nk_draw_list_add_image(&ctx->draw_list, i->img, nk_rect(i->x, i->y, i->w, i->h), i->col);
        } break;

dumblob avatar Mar 11 '19 20:03 dumblob

@dumblob You code not working

main.c: In function ‘main’:
main.c:135:9: error: case label not within a switch statement
         case NK_COMMAND_TRIANGLE: {
         ^~~~
main.c:136:86: error: ‘cmd’ undeclared (first use in this function)
             const struct nk_command_triangle *t = (const struct nk_command_triangle*)cmd;
                                                                                      ^~~
main.c:136:86: note: each undeclared identifier is reported only once for each function it appears in
make: *** [Makefile:24: test] Błąd 1

Is possible draw on background window too?

here normal demo code: https://gist.github.com/letarg0/a931dc9b4599e6526ba3d1aaec7b7557 any diff or other way?

letarg0 avatar Mar 12 '19 09:03 letarg0

@dumblob You code not working

Please read again what I wrote - see nuklear.h for parameters and "examples of its usage": ... (do you see the suggestion to read the source code and find places with the cited source code?).

dumblob avatar Mar 12 '19 18:03 dumblob

@dumblob Ok, I cant reat source code correct. Please show me any working example. I ask because I cant do this himself.

Only draw one line in demo.

letarg0 avatar Mar 13 '19 16:03 letarg0

@letarg0 no demo will help you if you won't know what it does. Learn programming first, get a broader overview and come back to learn about libraries (analogue to "learn reading first and then come to a library to read complex books").

Or if you don't want to learn programming (which is perfectly OK), ask your friend who knows programming to help you achieve the results you're dreaming about.

dumblob avatar Mar 13 '19 19:03 dumblob

@dumblob i undestand. You have no idea how to do it and attack others to hide this fact

letarg0 avatar Mar 14 '19 10:03 letarg0