SVG Script Programming Skills

Source: Internet
Author: User

1. How to debug scripts in SVG in IE

A. Remove "Disable script debugging" from iesettings"

B. Open the registry, find [HKEY_CURRENT_USER \ Software \ Microsoft \ Windows Script \ Settings], and set "jitdebug" = DWORD: 00000001

C. Then you can use vs.net for debugging.

2. Solve the problem that you need to click in IE to activate the SVG plug-in.

Compile a script file (embed. JS) and write the following code in the script file:

Document. write ("<embed id = 'mapobject' type = 'image/SVG-xml' src = '. /map. SVG 'height = '000000' width = '000000'/> ");

In the HTML code, insert the code of the SVG plug-in as follows:

<Div>
<SCRIPT src = "./JS/embed. js" Language = "JavaScript"> </SCRIPT>
</Div>

3. Draw HTML elements on SVG embed

Set the value of the "wmode" attribute of the EMBED element to "Transparent"

4. matrix change parameters (transform = "Matrix (a, B, c, d, e, f )")

Translation Transformation (translate): (, TX, Ty)

Scale: (sx, 0, 0, Sy, 0, 0)

Rotation Transformation (rotate): (COS (A), sin (A),-sin (A), cos (A),), A is the Rotation Angle

X axis skew (skewx): (, Tan (A), 0), A is the angle of skew

Y-axis skew (skewy): (1, Tan (A),), A is the skew angle

5. English name corresponding to the Chinese font

English name localized name
Simsun
Simhei
Fangsong_gb2312 _ gb2312
Kaiti_gb2312 _ gb2312
Youyuan
Stsong 文
Stzhongsong 文中
Stkaiti 文
Stfangsong 文
Stxihei 文
Stliti 文
Stxingkai
Stxinwei 文
Sthupo 文
Stcaiyun 文
Fzyaoti founder Yao simplified
Fzshuti 正 simplified
Nsimsun
Lisu statement

6. Determine the mouse event Source
In SVG, you may often encounter problems in determining the source of mouse events, such as mouse clicking, double-clicking, and scroll wheel events. Here is a simple

Introduction.

Determine whether the mouse is left or right?
In The onclick event, if (EVT. Button = 0) is left-click; otherwise, right-click
Whether you click or double-click EVT. Detail = 1
Determine whether the mouse is clicked or double-click?
In The onclick event, if (EVT. Detail = 2) is double-clicked; otherwise
Determine the scroll wheel event of the mouse?

Function mousewheel ()
{
Origscale = root. currentscale;
Origscale + = event. wheeldelta/1200;
If (origscale> 0)
{
Root. currentscale = origscale;
Root. currenttranslate. x = midx * root. currentscale + event. offsetx * (1-root.currentscale/midscale );
Root. currenttranslate. Y = midy * root. currentscale + event. offsety * (1-root.currentscale/midscale );

Midscale = root. currentscale;
Midx = root. currenttranslate. X/root. currentscale;
Midy = root. currenttranslate. Y/root. currentscale;
}
}

1. How to debug scripts in SVG in IE

A. Remove "Disable script debugging" from iesettings"

B. Open the registry, find [HKEY_CURRENT_USER \ Software \ Microsoft \ Windows Script \ Settings], and set "jitdebug" = DWORD: 00000001

C. Then you can use vs.net for debugging.

2. Solve the problem that you need to click in IE to activate the SVG plug-in.

Compile a script file (embed. JS) and write the following code in the script file:

Document. write ("<embed id = 'mapobject' type = 'image/SVG-xml' src = '. /map. SVG 'height = '000000' width = '000000'/> ");

In the HTML code, insert the code of the SVG plug-in as follows:

<Div>
<SCRIPT src = "./JS/embed. js" Language = "JavaScript"> </SCRIPT>
</Div>

3. Draw HTML elements on SVG embed

Set the value of the "wmode" attribute of the EMBED element to "Transparent"

4. matrix change parameters (transform = "Matrix (a, B, c, d, e, f )")

Translation Transformation (translate): (, TX, Ty)

Scale: (sx, 0, 0, Sy, 0, 0)

Rotation Transformation (rotate): (COS (A), sin (A),-sin (A), cos (A),), A is the Rotation Angle

X axis skew (skewx): (, Tan (A), 0), A is the angle of skew

Y-axis skew (skewy): (1, Tan (A),), A is the skew angle

5. English name corresponding to the Chinese font

English name localized name
Simsun
Simhei
Fangsong_gb2312 _ gb2312
Kaiti_gb2312 _ gb2312
Youyuan
Stsong 文
Stzhongsong 文中
Stkaiti 文
Stfangsong 文
Stxihei 文
Stliti 文
Stxingkai
Stxinwei 文
Sthupo 文
Stcaiyun 文
Fzyaoti founder Yao simplified
Fzshuti 正 simplified
Nsimsun
Lisu statement

6. Determine the mouse event Source
In SVG, you may often encounter problems in determining the source of mouse events, such as mouse clicking, double-clicking, and scroll wheel events. Here is a simple

Introduction.

Determine whether the mouse is left or right?
In The onclick event, if (EVT. Button = 0) is left-click; otherwise, right-click
Whether you click or double-click EVT. Detail = 1
Determine whether the mouse is clicked or double-click?
In The onclick event, if (EVT. Detail = 2) is double-clicked; otherwise
Determine the scroll wheel event of the mouse?

Function mousewheel ()
{
Origscale = root. currentscale;
Origscale + = event. wheeldelta/1200;
If (origscale> 0)
{
Root. currentscale = origscale;
Root. currenttranslate. x = midx * root. currentscale + event. offsetx * (1-root.currentscale/midscale );
Root. currenttranslate. Y = midy * root. currentscale + event. offsety * (1-root.currentscale/midscale );

Midscale = root. currentscale;
Midx = root. currenttranslate. X/root. currentscale;
Midy = root. currenttranslate. Y/root. currentscale;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.