Ref: Resize SVG_Use

2017-12-06 Thread truegold via 4D_Tech
Hi Miyako,

I think if the image size were uniform in the document I could do that. But the 
same images can be size to different sizes in different parts of the svg doc.

I might just decide to keep things as they were and laid an image as I need it. 
The worst case is that the same image is loaded many times and I cannot use 
SVG_USE.

Thanks,
John...


> it depends on the document,
> but I would create a group in "defs" and apply the scaling and/or translation 
> factor at the "defs" level.
> 
> you can "use" a "g" in SVG.
> 
> 2017/12/06 10:56、truegold via 4D_Tech 
> <4d_tech@lists.4d.com> のメール:
> Are you say that I need to wrap each occurrence of the SVG_Use within a group 
> ?

**
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
**

Re: Ref: Resize SVG_Use

2017-12-05 Thread Keisuke Miyako via 4D_Tech
it depends on the document,
but I would create a group in "defs" and apply the scaling and/or translation 
factor at the "defs" level.

you can "use" a "g" in SVG.

2017/12/06 10:56、truegold via 4D_Tech 
<4d_tech@lists.4d.com> のメール:
Are you say that I need to wrap each occurrence of the SVG_Use within a group 
?


**
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
**

Ref: Resize SVG_Use

2017-12-05 Thread truegold via 4D_Tech
Hey Miyako,

> hurts your brain, doesn't it?

Ah a joke! And yes it’s never quite as simple as it seems. Change one thing and 
effects things downstream. But it does appear hat the svg is working as it’s 
designed to. I’m just not quite skilled enough yet.

> by the way,
> your SVG is not wrong,
> but the standard practice is to wrap the element in a  and add the 
> translate attribute to the group,
> as opposed to the graphic element itself.

Anyway, I have learned via many web examples that wrapping in a  is the 
suggested strategy.

A question please? following the technique you showed me to load the images as 
refs:

$defs:=SVG_Define_symbol ($domSvg_ptr->;"defs") to group all the 

Loop…
$symbol:=DOM Create XML 
element($defs;"image";"id";$name;"xlink:href";$image;"x";0;"y";0;"width";$width;"height";$height)
   
And then to access in later places in code:

$glyph:=SVG_Use ($domSvg_ptr->;$whichAspect;0;0;0;0) 

And here are hundred of them in this svg document.

Are you say that I need to wrap each occurrence of the SVG_Use within a group 
?

Thanks,
John…


> From: Keisuke Miyako <keisuke.miy...@4d.com>
> Subject: Re: Ref: Resize SVG_Use
> Date: December 5, 2017 at 5:08:16 PM PST
> To: 4D iNug Technical <4d_tech@lists.4d.com>
> 
> 
> this is an SVG question, not a 4D question, but the answer is "yes".
> 
> if you change the scale in transform then it applies to the coordinates you 
> pass to translate and rotate.
> it also inherits the scaling resulting from scaling on parent elements as 
> well as the viewBox/viewPort ratio at the top level.
> 
> hurts your brain, doesn't it?
> 
> by the way,
> your SVG is not wrong,
> but the standard practice is to wrap the element in a  and add the 
> translate attribute to the group,
> as opposed to the graphic element itself.
> 
> 2017/12/05 9:51、truegold via 4D_Tech 
> <4d_tech@lists.4d.com<mailto:4d_tech@lists.4d.com>> のメール:
> Does the SVG_SET_TRANSFORM_SCALE  change the image size and also the the area 
> size? In others words (even though the xml in the 4D SVG Viewer doesn’t show 
> it) is 500 pixel width still 500 pixels after the size transform? Or is 500 * 
> scale?

**
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
**

Re: Ref: Resize SVG_Use

2017-12-05 Thread Keisuke Miyako via 4D_Tech
this is an SVG question, not a 4D question, but the answer is "yes".

if you change the scale in transform then it applies to the coordinates you 
pass to translate and rotate.
it also inherits the scaling resulting from scaling on parent elements as well 
as the viewBox/viewPort ratio at the top level.

hurts your brain, doesn't it?

by the way,
your SVG is not wrong,
but the standard practice is to wrap the element in a  and add the translate 
attribute to the group,
as opposed to the graphic element itself.

2017/12/05 9:51、truegold via 4D_Tech 
<4d_tech@lists.4d.com> のメール:
Does the SVG_SET_TRANSFORM_SCALE  change the image size and also the the area 
size? In others words (even though the xml in the 4D SVG Viewer doesn’t show 
it) is 500 pixel width still 500 pixels after the size transform? Or is 500 * 
scale?


**
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
**

Ref: Resize SVG_Use

2017-12-04 Thread truegold via 4D_Tech
Hi,

Does the SVG_SET_TRANSFORM_SCALE  change the image size and also the the area 
size? In others words (even though the xml in the 4D SVG Viewer doesn’t show 
it) is 500 pixel width still 500 pixels after the size transform? Or is 500 * 
scale?

I'm asking because as soon as I change the scale then the x and y begins 
shifting in the picture.

When the scale is 1 things move and align pretty well.

When the scale is .90 then the image shifts to the left and top as the image 
also shrinks

When the scale is .75 (and so on) then the image shifts to the left and top as 
the image also shrinks.

Perhaps that is the problem and I have a setting that needs t be set 
differently?

Thanks,
John...


> 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:
>> 
>> > 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…
 
 
>>> 
>> 
> 


Re: Ref: Resize SVG_Use

2017-12-04 Thread truegold via 4D_Tech
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:
> 
>  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
**

Re: Ref: Resize SVG_Use

2017-12-04 Thread truegold via 4D_Tech
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:

  
> 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
**

Ref: Resize SVG_Use

2017-12-04 Thread truegold via 4D_Tech
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
**