Book a Demo

Author Topic: Images and MDG Stereotypes  (Read 9049 times)

Amy_N

  • EA User
  • **
  • Posts: 28
  • Karma: +1/-0
    • View Profile
Images and MDG Stereotypes
« on: June 02, 2016, 09:06:36 pm »
I would like to use an alternative icon for elements in my MDG. I have saved my images as PNGs and when I manually change the image using 'select alternate image' (i.e. not using the MDG) on an element it shows fine. However when I try to incorporate this into my MDG using the below code (taken from Sparx User Guide) a black background is shown around my image and some of the colours change. I have written shape scripts for simple shapes successfully. However the icons I would like to use would require relatively complex scripts to define 'long hand' and I was hoping I could just reference an image. The only way I seem to be able to get anything usable is to save my images with coloured (or white) backgrounds.   

shape main
{
     addsubshape ("theimage", 100, 100);
     addsubshape ("namecompartment", 100, 100);
     shape theimage
     {
               image ("element image", 0, 0, 100, 100);
               // "element image" being the name of the image that is loaded into the Image Manager
     }
     shape namecompartment
     {
               h_align = "center";
               editablefield = "name";
               println ("#name#");
     }
}

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Images and MDG Stereotypes
« Reply #1 on: June 02, 2016, 09:23:20 pm »
Hi Amy,


Looks like you're adding the sub-shapes incorrectly.
The width and height are in per cent of the size of the outer shape, not in pixels (and yes, you can create sub-shapes in sub-shapes and get some pretty nifty-looking elements).

So for a TopDown layout, try
Code: (Shape Script) [Select]
     addsubshape ("theimage", 100, 75);
     addsubshape ("namecompartment", 100, 25);

The sum total of the height attributes don't have to add up to 100 -- EA will simply leave empty space below the last sub-shape -- but if you go over 100 I think the result's undefined.

HTH,


/Uffe
My theories are always correct, just apply them to the right reality.

Amy_N

  • EA User
  • **
  • Posts: 28
  • Karma: +1/-0
    • View Profile
Re: Images and MDG Stereotypes
« Reply #2 on: June 02, 2016, 09:36:55 pm »
Thank you that certainty helps with the proportions. However it is still putting a black background on the image when there should be 'no background' the images are not rectangular.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Images and MDG Stereotypes
« Reply #3 on: June 02, 2016, 11:13:22 pm »
Ah, could be the old transparent colour problem maybe?

In order for transparency to work, the tool creating the image and the tool rendering it (EA in this case) must agree on what constitutes a transparent pixel.

In EA the default transparent colour is RGB c0,c0,c0 / 192,192,192. So try setting the image background to that.

Depending on the image manipulation tool and file format you're using you might be able to specify a different one and get EA to pick up on it -- I seem to remember doing this with PowerPoint once, but I can't remember which format I used.

The other alternative is to save the image with nothing outside the image proper, so nothing transparent at all, and working with the shape script layout (sub-shapes in sub-shapes, remember) until the image is in the right place. This only works if the image is perfectly rectangular and there's nothing transparent inside the image itself, so getting the transparent colour right is the better solution.

/Uffe
My theories are always correct, just apply them to the right reality.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Images and MDG Stereotypes
« Reply #4 on: June 03, 2016, 08:33:23 am »
I was told recently that in the released version of EA alpha channels aren't handled when drawing images from shape scripts.

Amy_N

  • EA User
  • **
  • Posts: 28
  • Karma: +1/-0
    • View Profile
Re: Images and MDG Stereotypes
« Reply #5 on: June 09, 2016, 02:02:42 pm »
Thanks guys. Managed to solved it in the end by using Enhanced Metafiles