GooCanvas 라이브러리에서 툴팁 모양 Polygon 생성하기

Canvas 위에 정보를 표시하는 인터페이스로 Google map 과 비슷하게 툴팁 모양을 생각해 볼수 있는데 이를 위해서는 GooCanvasPolyline을 이용하면 됩니다. 예제에는 polyline을 그룹으로 관리하는 방식과 points 구조체를 이용하여 하나의 polyline을 구성하는 방식을 테스트 했습니다. 처음 방식은 툴팁내부의 색상을 “fill-color” 속성으로 영역을 채우지 못하고 pattern 등의 다른 방법을 이용해야 가능할 것으로 보입니다. 동작 여부는 아직 확인하지 못한 상태입니다. 두번째 방식으로는 쉽게 색상 표시가 가능 합니다.

GooCanvasItem *polyline_item, *polygon_item;
GooCanvasItem *group;
GooCanvasPoints *points;
 
group = goo_canvas_group_new (root,
                              "line-width", 2.0,
                              "line-cap", CAIRO_LINE_CAP_ROUND,
                              "stroke-color", "yellow",
                              NULL);
goo_canvas_item_translate (group, 100, 100);
 
polyline_item = goo_canvas_polyline_new_line (group, 1, 1, 1, 30, NULL);
polyline_item = goo_canvas_polyline_new_line (group, 1, 30, 20, 30, NULL);
polyline_item = goo_canvas_polyline_new_line (group, 20, 30, 15, 65, NULL);
polyline_item = goo_canvas_polyline_new_line (group, 15, 65, 30, 30, NULL);
polyline_item = goo_canvas_polyline_new_line (group, 30, 30, 50, 30, NULL);
polyline_item = goo_canvas_polyline_new_line (group, 50, 30, 50, 1, NULL);
polyline_item = goo_canvas_polyline_new_line (group, 50, 1, 1, 1, NULL);
 
points = goo_canvas_points_new (7);
points->coords[0] = 1.0;
points->coords[1] = 1.0;
points->coords[2] = 1.0;
points->coords[3] = 30.0;
points->coords[4] = 20.0;
points->coords[5] = 30.0;
points->coords[6] = 15.0;
points->coords[7] = 65.0;
points->coords[8] = 30.0;
points->coords[9] = 30.0;
points->coords[10] = 50.0;
points->coords[11] = 30.0;
points->coords[12] = 50.0;
points->coords[13] = 1.0;
 
polygon_item = goo_canvas_polyline_new (root, TRUE, 0,
                                        "line-width", 1.0,
                                        "points", points,
                                        "stroke_color", "red",
                                        "fill-color", "yellow",
                                        NULL);

goocanvas-polygon

Creative Commons License
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.0 Korea License.
This entry was posted in Development and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Notify me of followup comments via e-mail. You can also subscribe without commenting.