Use VML for radar-like scanning

Source: Internet
Author: User
Tags radar
Solution:

Use VML to render several concentric circles, and then use the Light filter to add ambient Light (for background color), conical Light (for scanning speed of Light), and point Light (for animal objects) to the top ), then regularly move the focal point and the origin point of the conical light.

Sample Code: <Html xmlns: x = "urn: schemas-microsoft-com: vml "> <br/> <pead> <br/> <title> radar-like scanning effects of VML and Light </title> <br/> <mce: script type = "text/javascript"> <! -- </P> <p> var cX, cY <br/> var pX = 10 <br/> var pY = 20 <br/> var radius = 100 <br/> var degree = 230 <br/> var rate = math. PI/180 <br/> function scan () {<br/> // calculates the X coordinate of the new focal point of the conical light <br/> cX = radius * (1 + Math. cos (degree * rate) <br/> // calculates the Y coordinate of the new focal point of the conical light. <br/> cY = radius * (1 + Math. sin (degree * rate) <br/> // if degree can be divisible by 30 (equivalent to executing the following statement every 300 milliseconds) <br/> if (! Degree % 30) {<br/> if (pX + = 5, pX> = 200) pX = 0 // processing when the point-to-point origin point exceeds the boundary <br/> if (pY + = 5, pY> = 200) pY = 0 <br/>}< br/> degree + = 10 // Rotation Angle of conical light <br/> if (degree = 360) degree = 0 // processing of conical light after one week of rotation <br/> with (radar. filters. light) {<br/> movelight (1, cX, cY,) // move the conical light <br/> movelight (2, pX, pY) // move the cursor <br/>}< br/> function window. onload () {// after loading the page, run <br/> // Add a Light filter to the radar object. <br/> radar. style. filter = "light ()" <B R/> with (radar. filters. light) {<br/> addambient (0,225, 100,100) // Add ambient light <br/> addcone (, 60, 15) // Add a conical light <br/> addpoint (pX, pY, 5, 0, 100,) // Add a vertex light <br/>}< br/> setInterval ("scan () ", 100) // execute the scan () function once every 100 milliseconds <br/>}< br/> // --> </mce: script> <br/> <mce: style> <! -- </P> <p> x/: * {behavior: url (# default # vml); position: absolute} <br/> --> </mce: style> <style mce_bogus = "1"> <br/> x/: * {behavior: url (# default # vml); position: absolute} </style> <br/> </pead> <br/> <body> <br/> <div id = "radar" style = "position: absolute; width: 200px; height: 200px; "> <br/> <mce: script type =" text/javascript "> <! -- </P> <p> for (var I = 0; I <100; I ++ = 10) // output 10 concentric circles <br/> document. write ("<x: oval style ="/"mce_style ="/"" left: iP; top: iP; width: iC; height: iC/"//> ". replace (/iP/g, I ). replace (/iC/g, 200-2 * I) </p> <p> // --> </mce: script> <br/> </div> <br/> </body> <br/> </ptml>

Tip:

In this example, VML is used to output concentric circles. If it is troublesome, you can use images instead. VML is the abbreviation of Vector Markup Language. For more information about VML, visit: http://blog.csdn.net/hemingwang0902/archive/2009/06/27/4303369.aspx

As shown in figure 2.3.11, the green spot in the figure moves slowly from the upper left corner to the right, while the beam moves clockwise at a fixed speed.

Figure 2.3.11 radar-like scanning Effect

Note:

This example mainly applies several methods of Light filter. VML is used to output 10 concentric circles. The effect of concentric circles can also be replaced by images.

 

Blog Source: http://www2.flash8.net/teach/4007.htm

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.