



| ¿øÇüÀ̵¿ ·¹À̾î ÀÚµ¿¹èÄ¡Çϱâ | go to ·¹ÀÌ¾î ¿øÇüÀ¸·Î À̵¿Çϱâ |
¿¹Á¦½ÃÀÛ
À§ÀÇ 4°³ÀÇ ·¹À̾îµéÀº ÆäÀÌÁö ¾Æ¹«µ¥³ª À§Ä¡½ÃÄ×½À´Ï´Ù. 4°³ÀÇ ·¹À̾ 360/4·Î ÆäÀÌÁö¿¡ À§Ä¡½Ã۰í
¿øÇüÀ¸·Î À̵¿À» ½Ãŵ´Ï´Ù. À̰ÍÀº °¢ ·¹À̾îµéÀÇ À§Ä¡¸¦ ÁöÁ¤ÇÏÁö ¾Ê°í ¿øÇüÀ¸·Î À̵¿ÇÒ °÷ÀÇ Áß½ÉÁ¡À» ÁöÁ¤ÇÏ¿©¼
ÀÌ·¸°Ô ÇÒ ¼ö ÀÖ½À´Ï´Ù. ¾ÕÀÇ ÆäÀÌÁö¿¡¼ ¾î¶² À§Ä¡¿¡ ÀÖ´Â ·¹À̾°Ô ¿øÇüÀ¸·Î À̵¿ÇÒ °¢µµ¸¦ ÁöÁ¤ÇÏ´Â °ÍÀ¸·Î
Áß½ÉÁ¡À» ÁöÁ¤ÇÒ ¼ö ÀÖ¾ú´Âµ¥ ¿©±â¼´Â ¹Ý´ë·Î Áß½ÉÁ¡À» ÁöÁ¤Çؼ ·¹À̾îµéÀ» Áß½ÉÁ¡¿¡ ¸Â°Ô À§Ä¡½Ãŵ´Ï´Ù.
#D1 { position:absolute; left:100; top:100; width:50; }
#D2 { position:absolute; left:200; top:100; width:50; }
#D3 { position:absolute; left:300; top:100; width:50; }
#D4 { position:absolute; left:400; top:100; width:50; }
<div id="D1"><IMG SRC="../../../images/img1.gif" WIDTH=50 HEIGHT=50 BORDER=0></div>
<div id="D2"><IMG SRC="../../../images/img2.gif" WIDTH=50 HEIGHT=50 BORDER=0></div>
<div id="D3"><IMG SRC="../../../images/img3.gif" WIDTH=50 HEIGHT=50 BORDER=0></div>
<div id="D4"><IMG SRC="../../../images/img4.gif" WIDTH=50 HEIGHT=50 BORDER=0></div>
4°³ÀÇ ¿øÇüÀ¸·Î À̵¿½Ãų ·¹À̾ ¿øÇüÀ¸·Î ¹èÄ¡ÇÏÁö ¾Ê°í ±×³É ¾Æ¹«·± ÁÂÇ¥¿¡ ¹èÄ¡¸¦ Çß½À´Ï´Ù.
¸ðµÎ left:0; top:0;¿¡ ¹èÄ¡¸¦ ÇØµµ »ó°ü¾ø½À´Ï´Ù.
function go() {
initCircleLoop();
alert("½ÃÀÛ")
moveCircleLoop()
}
<a href="javascript:go()">¿¹Á¦½ÃÀÛ</a>
¸µÅ©·Î ·¹À̾îÁ¤º¸¸¦ ÁöÁ¤ÇÒ ÇÔ¼ö initCircleLoop();¸¦ È£ÃâÇÏ°í ¿øÇüÀ̵¿ÇÔ¼öÀÎ moveCircleLoop()¸¦ ½ÃÀÛÇÕ´Ï´Ù.
function initCircleLoop() {
circleLayer = new Array();
if(n4) {
circleLayer[0] = 1 //°¢ ·¹À̾îµéÀÇ À̵¿ °£°Ý½Ã°£
circleLayer[1] = new circleLoopSet(document.D1, 3, 100, 100, 200, 200, 4, 1)
circleLayer[2] = new circleLoopSet(document.D2, 3, 100, 100, 200, 200, 4, 2)
circleLayer[3] = new circleLoopSet(document.D3, 3, 100, 100, 200, 200, 4, 3)
circleLayer[4] = new circleLoopSet(document.D4, 3, 100, 100, 200, 200, 4, 4)
}
else if(e4) {
circleLayer[0] = 1 //°¢ ·¹À̾îµéÀÇ À̵¿ °£°Ý½Ã°£
circleLayer[1] = new circleLoopSet(document.all.D1.style, 3, 100, 100, 200, 200, 4, 1)
circleLayer[2] = new circleLoopSet(document.all.D2.style, 3, 100, 100, 200, 200, 4, 2)
circleLayer[3] = new circleLoopSet(document.all.D3.style, 3, 100, 100, 200, 200, 4, 3)
circleLayer[4] = new circleLoopSet(document.all.D4.style, 3, 100, 100, 200, 200, 4, 4)
}
}
4°³ÀÇ ·¹À̾ µ¿½Ã¿¡ ¿øÇüÀ¸·Î À̵¿½Ã۱â À§ÇØ ÇϳªÀÇ ¹è¿¿¡ ÁöÁ¤À» ÇÕ´Ï´Ù. À§ÀÇ 200, 200 ÀÇ ±½Àº ±ÛÀÚ°¡
°¢ ·¹À̾îÀÇ Áß½ÉÁ¡ÀÔ´Ï´Ù. 200, 200À» Áß½ÉÀ¸·Î ·¹À̾ ¿øÇüÀ¸·Î À̵¿ÇÕ´Ï´Ù. ¿©±â¼´Â 4°³ÀÇ ·¹À̾ ¿øÇüÀ¸·Î
À̵¿½Ã۱â À§Çؼ °°ÀÌ 200, 200¸¦ ÁöÁ¤Çߴµ¥, 300, 300À» ÁöÁ¤ÇÑ ·¹À̾î´Â 300, 300À» Áß½ÉÀ¸·Î µ¹°ÔµË´Ï´Ù.
circleLoopSet(document.D1, 3, 100, 100, 200, 200, 4, 1)
À§ÀÇ ·¹À̾î À̵¿Á¤º¸¸¦ ÁöÁ¤ÇÒ circleLoopSet¿¡ ³Ö¾îÁØ ÀÎÀڴ ù¹øÂ° ÀÎÀÚ´Â À̵¿½Ãų ·¹À̾îÀÌ°í µÎ¹øÀç´Â À̵¿¾ç, ¼¼¹øÂ°´Â leftÀ̵¿Æø, ³×¹øÀç´Â topÀ̵¿Æø, ´Ù¼¸¹øÀç´Â left Áß½ÉÁ¡, ¿©¼¸¹øÂ°´Â top Áß½ÉÁ¡, Àϰö¹øÀç´Â ÃÑ ·¡ÀÌ¾î °¹¼ö, ¸¶Áö¸·¿¡´Â ÃÑ ·¡ÀÌ¾î °¹¼ö¿¡¼ À§Ä¡½Ãų ·¹ÀÌ¾î¼ø¼ÀÔ´Ï´Ù.
Àϰö¹øÂ°¿Í ¸¶Áö¸·ÀÇ ÀÎÀÚ´Â Áß½ÉÁ¡°ú ·¹À̾îµéÀÇ °¹¼ö¿Í ¼ø¼·Î ÆäÀÌÁö¿¡¼ À§Ä¡¸¦ ÁöÁ¤ÇÕ´Ï´Ù. ¿øÇü¿¡¼ °°Àº °Å¸®·Î ¹èÄ¡¸¦ ÇÕ´Ï´Ù.
function circleLoopSet(layer, angleIns, holizontalLength, verticalLength, circleLeftCenter, circleTopCenter, totalLayer, layerOrder) {
this.layer = layer
this.moveHol = holizontalLength
this.moveVer = verticalLength
this.moveAngleIns = angleIns
this.moveAngle = 360-(360/totalLayer*layerOrder)
if(n4) {
layer.left = circleLeftCenter + holizontalLength * Math.cos(this.moveAngle*Math.PI/180)
layer.top = circleTopCenter + verticalLength * Math.sin(this.moveAngle*Math.PI/180)
this.centerX = layer.left - holizontalLength * Math.cos(this.moveAngle*Math.PI/180)
this.centerY = layer.top - verticalLength * Math.sin(this.moveAngle*Math.PI/180)
}
else if(e4) {
layer.pixelLeft = circleLeftCenter + holizontalLength * Math.cos(this.moveAngle*Math.PI/180)
layer.pixelTop = circleTopCenter + verticalLength * Math.sin(this.moveAngle*Math.PI/180)
this.centerX = layer.pixelLeft - holizontalLength * Math.cos(this.moveAngle*Math.PI/180)
this.centerY = layer.pixelTop - verticalLength * Math.sin(this.moveAngle*Math.PI/180)
}
}
°¢ ·¹À̾î Á¤º¸¸¦ ÁöÁ¤ÇÏ´Â ÇÔ¼öÀÔ´Ï´Ù. À§ÀÇ ±½Àº ±ÛÀÚ°¡ circleLeftCenter, circleTopCenter Áß½ÉÁÂÇ¥¿Í
360-(360/ÃÑ·¹À̾¼ö*·¹ÀÌ¾î ¼ø¼) ·Î ·¹ÀÌ¾î °¹¼ö¿¡ µû¸¥ Áß½ÉÁ¡¿¡¼ÀÇ ÁÂÇ¥¸¦ ÁöÁ¤ÇÕ´Ï´Ù.
·¹À̾îµéÀ» ¿øÇüÀ¸·Î °°Àº °Å¸®·Î ¹èÄ¡¸¦ Çϴ°ÍÀÔ´Ï´Ù. (¼öÇÐÀ» ¸øÇؼ ÀÌ·¸°Ô Çß½À´Ï´Ù.)À̰ÍÀ¸·Î ÆäÀÌÁö¿¡¼ÀÇ ¿øÇüÀ¸·Î À̵¿½Ã °¢ ·¹À̾îÀÇ À§Ä¡¿¡ »ó°ü¾øÀÌ Áß½ÉÁ¡À» ÁöÁ¤ÇÏ´Â °ÍÀ¸·Î ¿øÇüÀ¸·Î ¿©·¯ ·¹À̾ ¹èÄ¡ÇÒ ¼ö ÀÖ½À´Ï´Ù. À̰ÍÀº ÆäÀÌÁö¿¡¼ ´Ù¸¥ ¿øÇüÈ¿°ú¿Í ¿¬°èÇϱ⵵ Æí¸®ÇÕ´Ï´Ù. Áï, À̵¿ÁßÀÎ ·¹À̾îÀÇ Áß½ÉÁ¡À» ¿Å±â¸é ¿øÇüÀ¸·Î À̵¿ÁßÀÎ ·¹À̾îµéÀÌ ±× Áß½ÉÁ¡À¸·Î À̵¿ÇÕ´Ï´Ù. ¿©·¯ È¿°ú¸¦ ¼³°è½Ã Á» ´õ ½±°Ô ¼³°èÇÒ ¼ö ÀÖ½À´Ï´Ù.
µÎ¹øÂ° ÀÎÀÚÀÎ angleIns´Â ·¹À̾ À̵¿ÇÒ ¹æÇâÀÔ´Ï´Ù. ¾ç¼ö°ªÀº ½Ã°è¹æÇâÀ¸·Î À̵¿Çϰí À½¼ö°ªÀº ¹Ý½Ã°è ¹æÇâÀ¸·Î À̵¿ÇÕ´Ï´Ù. ¼¼¹øÂ° holizontalLength¿Í ³×¹øÂ° verticalLength´Â ¿øÇüÀÇ Å©±âÀÔ´Ï´Ù. µÎ°³ÀÇ °ªÀÌ °°À¸¸é ¿øÇüÀÌ°í ´Ù¸£¸é Ÿ¿øÇüÀ¸·Î À̵¿ÇÕ´Ï´Ù.
ÀÌÁ¦ ÀÌ·¸°Ô ÁÂÇ¥¿Í Á¤º¸¸¦ ÁöÁ¤ÇÑ ·¹À̾îµéÀ» À̵¿½ÃŰ´Â ÇÔ¼ö¸¦ È£ÃâÇÕ´Ï´Ù.
function moveCircleLoop() {
for(var i=1; i < circleLayer.length; i++) {
if(n4) {
circleLayer[i].layer.left = circleLayer[i].centerX + circleLayer[i].moveHol * Math.cos(circleLayer[i].moveAngle*Math.PI/180)
circleLayer[i].layer.top = circleLayer[i].centerY + circleLayer[i].moveVer * Math.sin(circleLayer[i].moveAngle*Math.PI/180)
}
else if(e4) {
circleLayer[i].layer.pixelLeft = circleLayer[i].centerX + circleLayer[i].moveHol * Math.cos(circleLayer[i].moveAngle*Math.PI/180)
circleLayer[i].layer.pixelTop = circleLayer[i].centerY + circleLayer[i].moveVer * Math.sin(circleLayer[i].moveAngle*Math.PI/180)
}
circleLayer[i].moveAngle += circleLayer[i].moveAngleIns
}
moveCircleLoop_ID = setTimeout("clearTimeout(moveCircleLoop_ID); moveCircleLoop()", circleLayer[0]);
}
4°³ÀÇ ·¹À̾°Ô °¢µµ¸¦ Áõ°¡ ½ÃÄѼ À̵¿À» ÇÕ´Ï´Ù. ·¹À̾ À̵¿½ÃŰ´Â ÇÔ¼ö moveCircleLoop¿¡¼ À̵¿ÁßÀÎ
·¹À̾ È¿°ú¸¦ ÁÙ ¼ö ÀÖ´Â °ÍÀº Áß½ÉÁ¡°ú leftÀ̵¿Æø topÀ̵¿Æø ÀÔ´Ï´Ù. ÀÌ°Í 2°³¸¦ ¹Ù²Ù¾î ÁÙ ¼ö ÀÖ½À´Ï´Ù.
<script>
function moveCenter() {
for(var i=1; i < circleLayer.length; i++) {
circleLayer[i].centerX += 100
}
}
--
<a href="javascript:moveCenter()">Áß½ÉÁ¡ ÁÂÇ¥ ¿ÞÂÊÀ¸·Î 100px ´õ À̵¿½Ã۱â</a>
</script>
·Î Áß½ÉÁ¡À» À̵¿½Ãų ¼ö ÀÖ½À´Ï´Ù. Áß½ÉÁ¡ centerY³ª ¼öÆòÆø, ¼öÁ÷Æø, ¹æÇâ°ú À̵¿°£°Ý ½Ã°£µµ ¸¶Âù°¡Áö·Î ¹Ù²ãÁÙ ¼ö ÀÖ½À´Ï´Ù.
Áï, ·¹À̾îµéÀ» À̵¿½ÃŰ´Â moveCircleLoop() ¾È¿¡ ÀÖ´Â ÀÎÀÚµéÀ» Á¶Á¤Çؼ °¢ ±â´ÉÀ» Á¶Á¤ÇÒ ¼ö ÀÖ½À´Ï´Ù.
Áß½ÉÁ¡ ÁÂÇ¥ ¿ÞÂÊÀ¸·Î 100px ´õ À̵¿½Ã۱â
À§ÀÇ ¸µÅ©¸¦ ´©¸£°í µ¹°íÀÖ´Â ·¹À̾îµéÀ» º¸¸é Áß½ÉÁ¡ÀÌ ¿À¸¥ÂÊÀ¸·Î 100pxÀ̵¿ µÇ¾îÀÖ½À´Ï´Ù.