1 // Created with TexturePacker (http://www.codeandweb.com/texturepacker)
2 // DALi Exporter: nick.holland@partner.samsung.com
6 // For your application cut and paste either:
10 // 3. JavaScript property map for using with DALi JS.
12 // Note: If you use one option, then delete code for the other two
18 // 1. ------ lookup table method ------
20 // Handy if you want to get image with a postfix, e.g. image_1, image_2, image_3
21 // Or if some of the image names contain special characters which are not allowed
22 // in constant definitions ( e.g. spaces and full stops).
25 const char* ATLAS_FILE_NAME( "{{texture.fullName}}" ); ///< Atlas image filename
29 * Structure to hold image name and position within the atlas.
36 Dali::BlendingMode::Type blendMode; // only enable blending if image has alpha
42 const ImageInfo ImageAtlas[]=
44 {% for sprite in allSprites %} { "{{sprite.trimmedName}}", {{sprite.frameRect.x}}, {{sprite.frameRect.y}}, {{sprite.frameRect.width}}, {{sprite.frameRect.height}}, {%if sprite.isSolid %}BlendingMode::OFF{% else%}BlendingMode::ON{% endif %} }{% if not forloop.last %},{% endif %}
48 const unsigned int ATLAS_IMAGE_COUNT = sizeof(ImageAtlas)/sizeof(ImageAtlas[0]);
50 // Example function on how to get an image info from the table
52 // std::string fileName = std::string( DALI_IMAGE_DIR ) + ATLAS_FILE_NAME;
53 // Image imageAtlas = Image::New( fileName );
56 // const ImageInfo* info = GetImageInfo("left_icon");
60 // ImageActor myActor = ImageActor::New( imageAtlas, ImageActor::PixelArea( info->x, info->y, info->w, info->h) );
61 // myActor->SetBlendMode( info->blendMode );
65 const ImageInfo* GetImageInfo(const char* name)
67 typedef std::map< const char*, const ImageInfo* > LookupMap;
68 static LookupMap lookup;
71 for( unsigned int i = 0; i < ATLAS_IMAGE_COUNT; ++i)
73 lookup[ ImageAtlas[i].name ] = &ImageAtlas[i];
76 LookupMap::const_iterator iter = lookup.find(name);
77 if( iter != lookup.end() )
79 return (*iter).second;
81 DALI_ASSERT_ALWAYS(0 && "image name not found in atlas");
87 // 2. ------ constants code ------
91 const char* ATLAS_FILE_NAME( "{{texture.fullName}}" );
94 * Structure to hold position / blend mode within the atlas.
99 ImageInfo(unsigned int x,unsigned int y,unsigned int w,unsigned int h, Dali::BlendingMode::Type mode)
100 :pixelArea(x,y,w,h),blendMode(mode)
102 ImageActor::PixelArea pixelArea;
103 Dali::BlendingMode::Type blendMode; // only enable blending if image had alpha
106 {% for sprite in allSprites %}const ImageInfo {{ sprite.trimmedName|upper}}( {{sprite.frameRect.x}}, {{sprite.frameRect.y}}, {{sprite.frameRect.width}}, {{sprite.frameRect.height}} ,{%if sprite.isSolid %}BlendingMode::OFF{% else%}BlendingMode::ON{% endif %} );
110 // Example on using the Atlas, please delete this code.
111 void LoadAtlasImages()
113 std::string fileName = std::string(DALI_IMAGE_DIR) + ATLAS_FILE_NAME;
114 Image atlasImage = Image::New( fileName );
115 {% for sprite in allSprites %}ImageActor {{sprite.trimmedName|capfirst}} = ImageActor::New( atlasImage, {{sprite.trimmedName|upper}}.pixelArea);
116 {{sprite.trimmedName|capfirst}}.SetBlendMode( {{sprite.trimmedName|upper}}.blendMode );
123 // 3. ------ JavaScript key/value lookup table ------
129 {% for sprite in allSprites %} { name: "{{sprite.trimmedName}}", x: {{sprite.frameRect.x}}, y:{{sprite.frameRect.y}}, w:{{sprite.frameRect.width}}, h:{{sprite.frameRect.height}}, blendMode:{%if sprite.isSolid %}dali.BLENDING_OFF{% else%}dali.BLENDING_ON{% endif %} }{% if not forloop.last %},{% endif %}