473,387 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

circle tracing


Hi gurus,

I am trying to create a circle with different images.

var j = 0;
var degree30 = Math.PI/6;
var r_angle = 0;

function rotate(idy){
var x = parseInt(Math.cos(r_angle)*100);
var y = parseInt(Math.sin(r_angle)*100);

document.getElementById(idy).style.left = (x + 300);
document.getElementById(idy).style.top = (y + 186);
j++;
(r_angle < degree30 * 11) ? r_angle = degree30 * j : r_angle = 0;

( j < 12) ? setTimeout("rotate('reduit'+ j)", 400) : stop();
}

Here is my ... attempt:
http://www.jeanpierredaviau.com/sgagnon/oeil3.html
Thanks for your attention.

Jean Pierre Daviau
--
Easyphp1.8
Apache1.3.24
DEVC++, borland 5.5
windows Xp
asus p4 s533/333/133
Intel(R) Celeron (R) CPU 2.00 GHz
http://www.jeanpierredaviau.com
Feb 25 '06 #1
9 1740
"Jean Pierre Daviau" <On**@WasEno.ugh> writes:
I am trying to create a circle with different images.
You seem to be trying to place image elements at positions in a circle
with center 300,186 and radius 100. I assume those are pixels.

First of all, you are using "position:relative" on the images.
That means that they do take up space in the page flow, they are
just offset by the given values from their actual position.

For this to work, they should, preferably, all be offset from the
same point, so using "position:absolute" would probably be better.
Otherwise you have to compensate from the offset caused by the
earlier images.

If you do this, the script will "work", although it expects a browser
in quirks mode.

Here are some suggestions:
var j = 0;
var degree30 = Math.PI/6;
var r_angle = 0;

function rotate(idy){
var x = parseInt(Math.cos(r_angle)*100);
var y = parseInt(Math.sin(r_angle)*100);
Don't use parseInt for converting a potentially non-integer number
value to an integer. It involves converting the number to a string and
then parsing the string again. Just use Math.floor or Math.round:
var x = Math.round(Math.cos(r_angle)*100);
var y = Math.round(Math.sin(r_angle)*100);
document.getElementById(idy).style.left = (x + 300);
document.getElementById(idy).style.top = (y + 186);
The CSS properties "left" and "top" must have a unit on their values.
I assume pixels.
You could also store the img element reference in a variable instead
of looking it up twice, and you could use the "images" collection
that is more widely supported that getElementById:

var img = document.images[idy];
img.style.left = (x + 300) + "px";
img.style.top = (y + 186) + "px";
j++;
(r_angle < degree30 * 11) ? r_angle = degree30 * j : r_angle = 0;
Here I would prefer either an if-statment instead of a ?: expression:

if (r_angle < degree30 * 11) {
r_angle = degree * j;
} else {
r_angle = 0;
}

or moving the condition to the right side of the assignment:

r_angle = (r_angle < degree30 * 11) ? degree30*j : 0;

or just doing something arithmetically (not the same as your code, but
I can't see what the purpose of the code is):

r_angle = degree30 * (j % 12);
( j < 12) ? setTimeout("rotate('reduit'+ j)", 400) : stop();


Again, an if would be easier to read:

if (j < 12) {
setTimeout("rotate('reduit'+j)", 400);
} else {
stop();
}

Good luck
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Feb 25 '06 #2
Jean Pierre Daviau wrote on 25 feb 2006 in comp.lang.javascript:
var j = 0;
var degree30 = Math.PI/6;
var r_angle = 0;

function rotate(idy){
var x = parseInt(Math.cos(r_angle)*100);
var y = parseInt(Math.sin(r_angle)*100);

document.getElementById(idy).style.left = (x + 300);
document.getElementById(idy).style.top = (y + 186);
j++;
(r_angle < degree30 * 11) ? r_angle = degree30 * j : r_angle = 0;

( j < 12) ? setTimeout("rotate('reduit'+ j)", 400) : stop();
}


Try this in an empty file:

<script type='text/javascript'>

for (var x=0;x<12;x++)
document.write('<div id=reduit'+x+'>'+(+1+x)+'</div>')

var j = 0;
var degree30 = Math.PI/6;
var r_angle = -2*degree30;

function rotate(){
var x = parseInt(Math.cos(r_angle)*100);
var y = parseInt(Math.sin(r_angle)*100);
var idy = 'reduit'+ j
var d = document.getElementById(idy)
d.style.position='absolute'
d.style.left = x + 300;
d.style.top = y + 186;
r_angle += degree30
if (++j<12) setTimeout("rotate()", 400);
}

rotate()

</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 25 '06 #3
Lee I am the only one having problem with this :-)
Lassy Absolutely ... amazing.
Evertjan Symply astonished.

Thanks to all of you. May celestial flowers rain upon your heads.

n.b: it does not hurt ;-) ha!

Feb 25 '06 #4
I made the thing going fast for you to see the result of our work. See it
there for a while :

http://www.jeanpierredaviau.com/sgagnon/oeil4.html
Feb 25 '06 #5
Jean Pierre Daviau wrote:
I made the thing going fast for you to see the result of our work. See it
there for a while :

http://www.jeanpierredaviau.com/sgagnon/oeil4.html


All I see in Firefox is the images pile one on top of another.

Top and left should be given units - e.g. px.
--
Rob
Feb 26 '06 #6
>All I see in Firefox is the images pile one on top of another.
Mozilla too.
Top and left should be given units - e.g. px.

Done

Firefox and Mozilla does not play the code of Evertjan too

IE and Opera read it right.

Feb 26 '06 #7

Jean Pierre Daviau wrote:
All I see in Firefox is the images pile one on top of another.

Mozilla too.
Top and left should be given units - e.g. px.

Done

Firefox and Mozilla does not play the code of Evertjan too

IE and Opera read it right.


You must have changed some code, as the most recent Mozilla family
browsers (Firefox, Netscape, and Mozilla) are now showing your effect
nearly right. The only problem is that the tiny image that appears in
the center of the circle for a brief time is not displayed on these
browsers.

By the way, Opera supports some Microsoftese code, while the Mozilla
family browsers do not. When both IE6 and Opera display a page
correctly and Mozilla family browsers do not, the first thing to do is
to see if any Microsoftese code is used that is not part of official
code.

Feb 26 '06 #8

"cwdjrxyz" <sp*******@cwdjr.info> a écrit dans le message de news:
11*********************@v46g2000cwv.googlegroups.c om...

Jean Pierre Daviau wrote:
>All I see in Firefox is the images pile one on top of another. Mozilla too.
>Top and left should be given units - e.g. px.

Done

The only problem is that the tiny image that appears in the center of the circle for a brief time is not displayed on these
browsers.


yes indeed. The eye of the magnifyng glass is not there. humm.....

OEIL4 is still there for you to see the magnifyind design idee.
Ha! No genius but interesting.

Feb 26 '06 #9
I found it.

The tiny image had a z-index of -10
Feb 26 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Trace User | last post by:
Hello, I have a design question regarding Tracing and Trace Switches. I understand that Trace Switches can be configured through an application's .config file. When a switch is instantiated,...
1
by: rdeaton | last post by:
I need to design and code a Java program that calculates and prints the (D) diameter, the (C) circumference, or the (A) area of a circle, given the radius. The program inputs two data items: the...
6
by: serge calderara | last post by:
Dear all, I have an applicatin that generate a querry to an SQL server, then display results on a second webform. I try to see how tracing works, then I have notice that as soon as I...
2
by: deepukutty | last post by:
Hi all, I know tht we can do tracing in two ways.one in application level and the other is at Page level. I am able to see the details of trace either on the page itself or .../trace.axd page....
14
by: Pythor | last post by:
I wrote the following code for a personal project. I need a function that will plot a filled circle in a two dimensional array. I found Bresenham's algorithm, and produced this code. Please tell...
0
by: cnys | last post by:
We have an ASP.NET 2.0 (C#) app and we're trying to add tracing into it. The tracing functionality within .NET is great, but when we output this to a file, it's kind of sparse. So, we're looking...
0
by: rehto | last post by:
We have an ASP.NET 2.0 (C#) app and we want to enable tracing (see the code snippets below). The first time a user navigates to the app., the tracing works fine (the ASP.NET tracing appears on...
9
by: saraaana | last post by:
Given the center and a point on the circle, you can use this formula to find the radius of the circle. Write a program that prompts the user to enter the center and a point on the circle. The program...
14
by: DeadSilent | last post by:
I have this code and for some reason I keep getting an error where it says "exporting non-public type through public api ".. I'm not sure why this keeps happening but it does so for getCircleInfo /...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.