본문 바로가기

javascript

이번엔 텍스트 회전시키기

<!--1. 아래의 스크립트를 <HEAD></HEAD>사이에 복사해 넣으세요-->
<script>

<!-- Beginning of JavaScript -

// CREDITS:
// TextRotor by Urs Dudli and Peter Gehrig
// Copyright (c) 2000 Peter Gehrig and Urs Dudli. All rights reserved.

// 메세지
var message = new Array()
message[0]="안녕하세요!"
message[1]="DO YOU HAVE A FRIEND?"
message[2]="THEN SHUT DOWN YOUR PC."
message[3]="반갑습니다"
message[4]="좋은 시간!!"

// 회전 범위
var scrollerheight=200
var scrollerwidth=700

// 글꼴
var font_family="굴림"

// 위치

var x_textposition=0
var y_textposition=0

// 여기까지,


var i_message=0
var i_loop=0
var max_loop=48
var timer
y_textposition=y_textposition-Math.floor(scrollerheight/1.5)+10
x_textposition=x_textposition-Math.floor(scrollerwidth/3)

function initiate() {
        if (document.all) {                
                document.all.rotationstyle.style.posLeft=x_textposition
                document.all.rotationstyle.style.posTop=y_textposition
        changemessage()
        }
}

function changemessage() {
                do_rotate="yes"
                rotationstyle.innerHTML=
                '<OBJECT ID="rotationobj" CLASSID="CLSID:369303C2-D7AC-11d0-89D5-00A0C90833E6" STYLE="position:relative;width:'+scrollerwidth+'px;height:'+2*scrollerheight+'px">'+
        '<PARAM NAME="Line0001" VALUE="SetLineStyle(0)">'+
        '<PARAM NAME="Line0002" VALUE="SetLineColor(255,0,0)">'+
                '<PARAM NAME="Line0003" VALUE="SetFillColor(255,0,0)">'+
                '<PARAM NAME="Line0004" VALUE="SetFont(\''+font_family+'\', '+5+', 400, 0, 0, 0)">'+
                '<PARAM NAME="Line0005" VALUE="Text(\''+message[i_message]+'\', 0, 0, 0)">'+
                '</OBJECT>'                
                startscroll()
}

function startscroll() {
        if (i_loop < max_loop) {
        rotationobj.Rotate(0,0,-30)
                rotationobj.Scale(1.04,1.04,1.04)
                i_loop++
                timer=setTimeout("startscroll()",50)
        }
   else {
        i_message++
                i_loop=0
        if (i_message>=message.length) {i_message=0}
                timer=setTimeout("changemessage()",2000)
        }
}

// - End of JavaScript - -->
</script>

</HEAD>

<!--2. <BODY> 태그내에 onload="" 혹은 onunload 부분이 있으면 복사해 넣으세요-->

<BODY BGCOLOR="#FFFFFF" onLoad="initiate()">

<!--3. <BODY></BODY> 부분에 아래의 스크립트를 복사해 넣으세요-->

<SPAN ID="rotationstyle" STYLE="position:absolute">
<OBJECT ID="rotationobj" CLASSID="CLSID:369303C2-D7AC-11d0-89D5-00A0C90833E6">
</OBJECT>
</SPAN>