Using JavaScript to imitate the feather effect code in PS _javascript tips

Source: Internet
Author: User
Tags rand

Copy Code code as follows:

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> use JavaScript to prevent the feather effect code in PS-www.jb51.net</title>
<body onload=setvalues () >
<center>
<script language=javascript>
<!--beginning of JavaScript-
var x,y
var marginbottom
var marginleft=0
var margintop=0
var marginright
var cliptop
var clipbottom
var clipleft
var clipright
var clippoints
var ballheight=150
var ballwidth=150
var imageheight=525
var imagewidth=457
var tempo=25
var stepx=12
var stepy=6
var timer
function Setvalues () {
if (document.all) {
MarginBottom = Imageheight-ballheight
MarginRight = Imagewidth-ballwidth
Document.all.ball.style.posleft=randommaker (400)
Document.all.ball.style.postop=0
Document.all.textcontent.style.posleft=0
Document.all.textcontent.style.postop=0
Document.all.ball.style.filter= "Alpha" (opacity=0,finishopacity=100,style=2,startx=0px,starty=0px,finishx=100px, finishy=100px) "
Moveball ()
}
}
Randomfunction
function Randommaker (range) {
Rand=math.floor (Range*math.random ())
return Rand
}
function Moveball () {
Checkposition ()
if (document.all) {
Document.all.ball.style.posleft+=stepx
Document.all.ball.style.postop+=stepy
Cliptop=document.all.ball.style.postop
Clipbottom=cliptop+ballheight
Clipleft=document.all.ball.style.posleft
Clipright=clipleft+ballwidth
clippoints= "Rect" ("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+") "
Document.all.textcontent.style.clip=clippoints
Timer=settimeout ("Moveball ()", tempo)
}
}
function Checkposition () {
if (document.all) {
if (document.all.ball.style.posleft>=marginright) {
Stepx=stepx*-1
document.all.ball.style.posleft-=10
}
if (document.all.ball.style.posleft<=marginleft) {
Stepx=stepx*-1
document.all.ball.style.posleft+=10
}
if (Document.all.ball.style.postop>=marginbottom) {
Stepy=stepy*-1
document.all.ball.style.postop-=10
}
if (document.all.ball.style.postop<=margintop) {
Stepy=stepy*-1
document.all.ball.style.postop+=10
}
}
}
-End of JavaScript--->
</SCRIPT>
<span id=textcontent style= "left: -5000px; Position:absolute; Top: -2000px "> </span>
<span id=ball style= "background-color:white; height:150px; Position:absolute; Top: -50px; width:150px "></span>
</center>
</body>

Related Article

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.