Picture of the Searchlight effect

Source: Internet
Author: User

1. Overview

Use JavaScript to write a picture searchlight effect, when the page is loaded, the effects of the searchlight will be repeated on the diagram left and right scan, the part of the display as a bright state and the rest of the display as a gray state.

2. Technical Highlights

Using the light attribute in CSS filter technology, the Addpoint () and Movelight () methods are called through the Lights property to set the size of the lighting on the image and move the light.

3. Concrete implementation

(1) To achieve the searchlight effect in the picture scan, the JavaScript code is as follows:

<script language= "JavaScript" >if(document.all &&window.imagelight) {var x=NewArray (); var heading=NewArray (); var y=NewArray (); if(imagelight.length==NULL) {imagelight[0]=Document.all.imagelight; x[0]=0; heading[0]= "Right"; y[0]=imagelight[0].height; imagelight[0].filters.light.addpoint (100,50,100,255,255,255,90); }      Else             for(i=0;i<imagelight.length;i++) {X[i]=0; Heading[i]= "Right"; Y[i]=Imagelight[i].height; Imagelight[i].filters.light.addpoint (100,50,100,255,255,255,90); }}function Light (cur) {imagelight[cur].filters.light.movelight (0,x[cur],y[cur],200,-1); if(x[cur]<imagelight[cur].width+200&&heading[cur]== "Right") X[cur]+=10; Else if(x[cur]>imagelight[cur].width+200) {Heading[cur]= "Left"; X[cur]-=10; }      Else if(x[cur]>-200&&x[cur]<-185) {Heading[cur]= "Right"; X[cur]+=10; }      Else{X[cur]-=10; Heading[cur]= "Left"; }}if(document.all&&window.imagelight) {      if(imagelight.length==NULL) SetInterval ("Light (0)", imagelight[0].speed); Else             for(t=0;t<imagelight.length;t++) {var temp= ' SetInterval (' Light (' +t+ ') ', ' +imagelight[t].speed+ ') ';            eval (temp); }}</SCRIPT>

(2) write the CSS style in the page and mark a picture code as follows:

<style type=text/css>#imagelight {      filter:light}</style><center></center>

Picture of the Searchlight effect

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.