tizentizen-native-app

How to draw a *curved* line?


Question is simple as title says.

Tizen's docs are truly unreliable regarding this topic (among others).

For example as they states here:

Drawing SVG Path. You can construct a path by using api in efl_gfx_utils.h

...

efl_gfx_path_append_circle(&path_cmd, &points);

efl_gfx_utils.h is not found in Tizen5.5's SDK.

They also removed these functions: evas_vg_shape_append_move_to, evas_vg_shape_append_line_to.

So the question is still up, how can I draw a curved line onto preferrably an Evas_Object?


Solution

  • In 6.0 you can use those APIs. How about developing in 6.0?

    Another way to suggest is to use Cairo. See here for more details. https://docs.tizen.org/application/native/guides/graphics/cairo/

    I tested the code below in 5.5. And I checked that this code works.

    int w = 360, h = 360;
    Evas_Object *img = evas_object_image_filled_add(evas_object_evas_get(ad->win));
    elm_win_resize_object_add(ad->win, img);
    evas_object_image_content_hint_set(img, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
    evas_object_image_size_set(img, w, h);
    evas_object_image_colorspace_set(img, EVAS_COLORSPACE_ARGB8888);
    evas_object_image_alpha_set(img, 0);
    evas_object_show(img);
    
    cairo_surface_t *cairo_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
    cairo_t *cairo = cairo_create(cairo_surface);
    /* Cairo drawing */
    cairo_set_source_rgba(cairo, 1.0, 0.0, 0.0, 1.0);
    cairo_arc(cairo, 30, 150, 100 * sqrt(2), -0.25 * M_PI, 0.25 * M_PI);
    cairo_close_path(cairo);
    cairo_stroke(cairo);
    cairo_surface_flush(cairo_surface);
    unsigned char *imageData = cairo_image_surface_get_data(cairo_surface);
    if(imageData){
        evas_object_image_data_set(img, imageData);
        evas_object_image_data_update_add(img, 0, 0, w, h);
    }
    

    enter image description here

    I hope this way helps you.