[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 12-26-2006, 05:42 PM   #1 (permalink)
Senior Member
 
RegisterRants's Avatar
 
Join Date: Oct 2006
Posts: 1,144
257.37 NP$ (Donate)

RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about


Javascript question

I would like to draw a spiral of words on-screen. Example: I want the word "Hi" to appear in a spiral, multiple times.
__________________
Web Development
RegisterRants is offline  
Old 12-26-2006, 06:58 PM   #2 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
 
Join Date: Feb 2006
Posts: 2,801
56.00 NP$ (Donate)

Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future

Autism Autism Autism Autism Autism Autism Autism
Code:
function spiral() {
	document.getElementById('spiral').style.top = (Math.sin(i)*10);
	document.getElementById('spiral').style.left = (Math.cos(i)*10);
	i += 1;
	setTimeout('spiral()',50)
}
That's the best I could do :x
Dan is offline  
Old 12-26-2006, 07:09 PM   #3 (permalink)
Senior Member
 
RegisterRants's Avatar
 
Join Date: Oct 2006
Posts: 1,144
257.37 NP$ (Donate)

RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about


Nope. Here is your code in action:

http://discussingtech.com/spiral.html
__________________
Web Development
RegisterRants is offline  
Old 12-26-2006, 07:16 PM   #4 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
 
Join Date: Feb 2006
Posts: 2,801
56.00 NP$ (Donate)

Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future

Autism Autism Autism Autism Autism Autism Autism
Code:
<div id="spiral" style="position: absolute; top: 0; padding-left: 30px;">yo</div>
<script type="text/javascript">
var i = 0;
function spiral() {
	document.getElementById('spiral').style.top = (Math.sin(i)*10);
	document.getElementById('spiral').style.left = (Math.cos(i)*10);
	i += 1;
	setTimeout('spiral()',50)
}

window.onload = function () { spiral(); }
</script>
Dan is offline  
Old 12-26-2006, 07:39 PM   #5 (permalink)
Senior Member
 
RegisterRants's Avatar
 
Join Date: Oct 2006
Posts: 1,144
257.37 NP$ (Donate)

RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about


Works. So far.

The problem is that I dont want the previous one to disappear when the next one is drawn.
__________________
Web Development
RegisterRants is offline  
Old 12-26-2006, 07:42 PM   #6 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
 
Join Date: Feb 2006
Posts: 2,801
56.00 NP$ (Donate)

Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future

Autism Autism Autism Autism Autism Autism Autism
Previous what and next what? :X
Dan is offline  
Old 12-26-2006, 07:45 PM   #7 (permalink)
Senior Member
 
RegisterRants's Avatar
 
Join Date: Oct 2006
Posts: 1,144
257.37 NP$ (Donate)

RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about


Your script makes the dancing word. I dont want it to dance, I want it to create a spiral. In other words, I want the text/images to stay still once it is generated.
__________________
Web Development
RegisterRants is offline  
Old 12-26-2006, 07:59 PM   #8 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
 
Join Date: Feb 2006
Posts: 2,801
56.00 NP$ (Donate)

Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future

Autism Autism Autism Autism Autism Autism Autism
Can you explain what you want?

You are saying barely anything and when I do what you ask for, there's a whole new part of something you want it to do that you've never said before.
Dan is offline  
Old 12-26-2006, 08:04 PM   #9 (permalink)
Senior Member
 
RegisterRants's Avatar
 
Join Date: Oct 2006
Posts: 1,144
257.37 NP$ (Donate)

RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about


Im trying to explain this...its a bit difficult to explain. Im sorry if it was phrased wrong before.

Your code, shown in action here, has the word 'yo' move around in what appears to be a spiral. However, your code is written so that the actual div moves. What I need is something that can create another <div> with this new positioning, and do that multiple times, so that the word 'yo' does not disappear every time.
__________________
Web Development
RegisterRants is offline  
Old 12-26-2006, 10:21 PM   #10 (permalink)
Senior Member
 
RegisterRants's Avatar
 
Join Date: Oct 2006
Posts: 1,144
257.37 NP$ (Donate)

RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about


I think I almost have it

Here is the code I have, the result can be viewed at http://www.domainrealty.info/forum/spiral.html

Code:
<center><div id="spiral0" style="position: absolute; top: 0; padding-left: 300px; padding-top: 300px;"><div id="contain"></div>yo</div></center>
<script type="text/javascript">
var i = 0;
var divs = new Array();
var x = 0;
function spiral() {
	for(x = 0;x <= divs.length;x++) {
		document.getElementById('spiral'+x).style.top = (Math.sin(divs[x])*100);
		document.getElementById('spiral'+x).style.left = (Math.cos(divs[x])*100);
	}
	y = x + 1;
	document.getElementById('contain').innerHTML += '<div id="spiral'+y+'">yo<\/div>';
	document.getElementById('spiral'+y).style.top = (Math.sin(i)*100);
	document.getElementById('spiral'+y).style.left = (Math.cos(i)*100);
	divs[y] = i;
	i += 1;
	setTimeout('spiral()',500)
}

window.onload = function () { spiral(); }
</script>
What am I doing wrong?
__________________
Web Development
RegisterRants is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 02:32 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85