SoFunction
Updated on 2025-04-14

Zoom in and out VML

Since VML is vector, it becomes easy to zoom in and out. Let's first look at an example to see how VML can do it. Let’s take a flying saucer from the past as an example. It is a figure pieced together with shapes such as lines, circles, arcs, etc. I added the move event, and when zooming in too much, I can drag the image to view.













Did you feel that zooming in and out has not changed the image quality of VML? Because VML is vector. Just dynamically change its coordinatesize value. Note that the decrease value is equal to enlargement, and the increase value is equal to shrink. You can refer to the following script:

  var xx=6000;
  var yy=6000;
  function zoom(h)
  {
    =xx/h+","+yy/h;
  }

The above xx and yy refer to the coordsize value under the default state. When calling this function, use zoom(n) where n is the multiple to be enlarged.
When the VML contains text, the graphics are enlarged, but the text will not be enlarged automatically. This makes it very asymmetric. There is a trick, that is, the text is wrapped in a mark, and the magnification function needs to be improved:
  var xx=6000;
  var yy=6000;
  var fs=9;
  function zoom(h)
  {
    =xx/h+","+yy/h;
    for(var i=0;i<("DIV").length;i++)
      ("DIV").item(i).=fs*h+"pt";
  }

fs is the text size under the default state. ("DIV") will return all DIV elements on the page and then make their text size larger. Practice has proved that the ratio of amplified to VML remains unchanged.