Hi,

As an aside I am testing in a small sample and opening inn the viewer.

if I use this line:

SVG_SET_TRANSFORM_TRANSLATE ($glyph;$inX;$inY)

it works great! Starts the draw exactly at the x and y.

But if I add this line:

SVG_SET_TRANSFORM_SCALE ($glyph;$_w/$width;$_w/$height)

Then it goes from it’s correct location and jumps to the 0,0 origin I think..

BTW, I am using 4D v16R4 if that matters.

Maybe there’s a better ay to scale? I need to to scale the images based upon 
their original size (width, height) down to what ever the end users selects. 
Usually (in pixels) 14, 16, 18, 20, 24, 28, etc. These need to transform based 
upon the original width and height (usually close to 1000) to a small 
percentage.

Is there another way? A better way?

Thanks,
John…



> Hi Miyako,
> 
>> translate offsets the x/y by the value specified. 
>> the x/y you pass are not absolute coordinates (unless, of course, the x/y in 
>> element are 0,0) 
> 
> Agree!
> 
> I have tested setting the x/y w/h to 0 thinking that it would apply correctly 
> but the svg looks like this:
> 
> <use height="0" transform="scale(0.02,0.02) translate(653,653)" width="0" 
> x="0" xlink:href="#S09" y="0”/>
> 
> and the image seems to be at x=0, y=0 even though the size seems to be 
> correct? Always!
> 
> Thanks,
> John…
> 
> 
>> Hi All,
>> 
>> Note: If I apply the transform immediately after I create the symbol:
>> 
>> $symbol:=DOM Create XML 
>> element($defs;"image";"id";$name;"xlink:href";$image;"x";0;"y";0;"width";$width;"height";$height)
>>             
>> SVG_SET_TRANSFORM_SCALE ($symbol;18/$width;18/$height)
>> 
>> That seems to work and would be fine if all I needed were uniform sizes in 
>> the doc. In this example I am resizing them so they are 18 by 18 pixels. But 
>> as indicated previously the end user can set a size property to enlarge or 
>> shrink these sizes for the same symbol in different parts of the doc. So I 
>> need to resize and reposition where they are actually used.
>> 
>> Not sure if this is a clue or…
>> 
>> John...
>> 
>> 
>>> Hi All,
>>> 
>>> I’m in the process of changing some SVG routines to be a bit more efficient 
>>> (I think).
>>> 
>>> Miyako showed me how to embed svg images as “defs”:
>>> 
>>> $defs:=SVG_Define_symbol ($domSvg_ptr->;"defs”) 
>>> 
>>> so I could reuse the graphics without reloading them several times. This 
>>> part works perfectly.
>>> 
>>> Previously I would read the image from disk and resize and place:
>>> 
>>> $tDom_Image:=SVG_New_image ($$domSvg_ptr->;$image_t;$x;$y;$w;$h)
>>> 
>>> Worked great! no matter the size of the original svg image on disk which 
>>> are in the neighborhood of 1000 pixels width/height (although there is 
>>> variation). And I can’t set the originals to a fixed size because the end 
>>> user can change the same image, in different places of the svg document, to 
>>> different sizes. So I need to managing the image sizes dynamically.
>>> 
>>> Anyway, now that I am accessing these “defs” images using:
>>> 
>>> $glyph:=SVG_Use ($domSvg_ptr->;$id;$inX;$inY;$size_IntrcG;$size_IntrcG)     
>>>                                                 
>>> 
>>> I have to both resize the image and make sure it stays at the x/y coords I 
>>> need.
>>> 
>>> But it’s not!
>>> 
>>> To reset the size I believe I have to use (0.02 being used for testing):
>>> 
>>> SVG_SET_TRANSFORM_SCALE ($glyph;0.02;0.02)                                  
>>>                 
>>> 
>>> To reposition at the x/y I believe I have to use:
>>> 
>>> SVG_SET_TRANSFORM_TRANSLATE ($glyph;$inX;$inY)
>>> 
>>> The scaling seems to scale BUT the translate is not placing the images at 
>>> the x/y location I need. Although, the attributes for the object look 
>>> correct:
>>> 
>>> height - 14
>>> transform - scale(0.02,0.02)
>>> width - 14
>>> x - 660
>>> xlink:href - #S09
>>> y - 660
>>> 
>>> I am assuming (until I know better) that these values are correct.
>>> 
>>> So I must be missing something? How do I control both the height/width (I 
>>> think I am) and the exact x/y placement when I am creating an image using 
>>> SVG_Use?
>>> 
>>> Anyone?
>>> 
>>> Thanks,
>>> John…
>>> 
>>> 
>> 
> 

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to