언어 설정

Menu
Sites
Language
Draw a circle

Hi,

I am making a Tizen Native App, I want to draw a red color opaque circle on a Canvas. I know how to draw a rectangle using Evas_Object_Rectangle. Circle can drawn with the help of Evas_Object_Polygon, but i couldn't find a tutorial on how to do it...Can anybody guide me how to draw a circle on screen?

 

Responses

3 댓글
Jaismeen Kaur

Refer chapter 33 in the book - Native Tizen Application Development. (https://samsung.tizenforum.com/?topic=2884.0 )

Jeongsu Kim

I checked Evas Polygon Object and I saw this message.

Functions that operate on evas polygon objects.

Hint: as evas does not provide ellipse, smooth paths or circle, one can calculate points and convert these to a polygon.

Warning:
We don't guarantee any proper results if you create a Polygon object without setting the evas engine.

 

https://developer.tizen.org/dev-guide/latest/org.tizen.native.mobile.apireference/group__Evas__Object__Polygon.html

 

So I think it is not a good way to draw a circle.

I recommended these 2 methods.

1. If you just need circle with many colors, different sizes, just use one big white circle image.
You can resize it by evas_object_resize and you can colorize it by evas_object_color_set.

2. Or if you want to draw circle, ellipse or other things, use other libraries like cairo.

Evas_Object* image = eavs_object_image_add(evas);
evas_object_image_size_set(image, width, height);
evas_object_image_filled_set(image, EINA_TRUE);

void* buffer = evas_object_image_data_get(image);

cairo_surface_h surface = cairo_image_surface_crate_for_data(buffer, 
    CAIRO_FORMAT_ARGB32, 
    width, 
    height,
    evas_object_image_stride_get(image));
cairo_h cairo = cairo_create(surface);

// do something with cairo

evas_object_data_set(image, buffer);
evas_object_image_update_add(image, 0, 0, width, height);

evas_object_show(image);

Above code shows how evas works with cairo. It is not a full code but I think it is enough.

FYI, evas_object_image_size_set sets the size of buffer, not the object.

Alex Dem

Hi,
fyi,  If you want to use cairo to draw circle I think you could perform something like this:
 

cairo_set_source_rgba(ad->cairo, r, g, b, alpha);
cairo_arc (ad->cairo, x, y, radius, 0, 2 * M_PI);
cairo_fill(ad->cairo);

You could regulate opacity with alpha param.
Alexey.