Search code examples
tizentizen-native-app

How to display SVG?


I have a simple SVG and want to display it with EDC:

<svg width="360" height="360" viewBox="0 0 360 360">
    <path d="M180 0 L80 300 L280 300 Z" fill="#ff0000"/>
</svg>

This is just as simple:

enter image description here

My EDC:

collections {
   group { 
      name: "main";

      images {
         vector: "simple.svg";
      }

      parts {
         vector { "test";
            desc { "default"; 
               image.normal: "simple.svg";
            }
         }         
      }
   }
}

Target is Tizen 5.5 wearable. Whole screen is black. How can I display this SVG (if I don't want to convert it to PNG)?


Solution

  • There are two ways to output SVG files. One way is to use the VECTOR part of EDC and the other is to use elm_animation_view (tizen 5.5 or higher). Refer to this https://docs.tizen.org/application/native/api/mobile/5.5/group__Elm__Animation__View.html

    [edc] Make a SWALLOW part

    collections {
       group { name: "main";
          parts {
             part {
                  name: "svgfile";
                  type: SWALLOW;
             }
          }
       }
    }
    

    [c code]

        char buf[255];
        sprintf(buf, /*Resource PATH*/);
        
        Evas_Object *anim = elm_animation_view_add(layout);
        elm_animation_view_file_set(anim, buf, NULL);
        evas_object_size_hint_weight_set(anim, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(anim, EVAS_HINT_FILL, EVAS_HINT_FILL);
        elm_object_part_content_set(layout, "svgfile", anim);
    

    enter image description here