This whole thing started when I wanted to display list items in a circle...it just looked way too much like a clock. So for fun I started to create a JavaScript Analog clock.
I was wondering how to draw a line using JavaScript. Everything I've found so far seems to use some JavaScript library....is there an easier way to do this?
Here's what I have so far. I know the clock is Side Ways....but when I try to change the angle so that 12 is at the top (by setting it to -90 or 270 since it's in the 3 o'clock position) it isn't right. Maybe my math is wrong or something?
Thanks!
-Frinny
7 4977
but when I try to change the angle so that 12 is at the top (by setting it to -90 or 270 since it's in the 3 o'clock position) it isn't right.
well, it works for me. (OK, if I use it in rad, aka 270° = 1.5*Math.PI)
Thanks Dorm. Using 1.5*Math.PI properly set 12 at the 12 o'clock position.
-Frinny
mathematical note:
all trigonometric and exponential function use unit-less parameters by default.
in case of the circle, 2π represents the full circle (same as 360°).
reason: c = 2π·r, by dividing c by r (to make the circumference independent (and unit-less)) you get 2π for a full circle, always. q.e.d.
in case of exponential function you can argue, that the exponent is the number, a value is multiplied with itself and naturally this number (the repetition times) is unit-less.
extending trigonometric functions from exponential functions: complex numbers can be written either trigonometric or exponential style, which uses the angle as parameter.
r·cos(φ) + i·r·sin(φ) = r·exp(iφ)
thus, if the exponential style can’t use unit-bearing values, the trigonometric can’t either.
Thanks for the refresher Dorm. I actually had to look up all of that stuff yesterday because it's been such a long time since I've used trig.
I think I might be getting closer to finding an answer to my original question: "how do you draw a line".
I think the answer might be to use the HTML5 canvas.
:)
-Frinny
canvas seems like a good idea. JavaScript was not made for drawing to begin with. you may also think about using SVG graphics in XHTML. SVG/HTML @ MDC
*Sigh* Internet Explorer...
When will MS get their *stuff* together enough to keep up!
Whatever...I'm dedicating today to learning about the <canvas> and the rest of the new features offered in HTML 5.
I know JavaScript and HTML weren't actually supposed to be used for what I want to do (draw lines etc). I was toying with the idea of putting a whole bunch of <span>s or maybe some inner lists so that I could simulate drawing a line using these HTML elements....but I didn't like the idea. The other idea I had was to use images...but didn't like that idea either (my images would have to be angled properly and I don't think I have the graphics skills to do this using Paint or Gimp). So the <canvas> looks very appealing to me :)
-Frinny
Sign in to post your reply or Sign up for a free account.
Similar topics
by: James Harriman |
last post by:
Hi,
I need to be able to measure a time interval in milliseconds on a windows
machine. I have tried using time.clock() but it appears to measure time in
seconds...Is there a way to measure time...
|
by: Robert Brewer |
last post by:
Analog is a popular web log analyzer and report generator. I wrote a
small Python helper for it today for my Dev Manager, looked for similar
stuff via Google, and came up dry. Just curious if...
|
by: Pushkar Pradhan |
last post by:
I'm using clock() to time parts of my code
e.g.
clk1 = clock();
/* code */
clk2 = clock();
/* calculate time in secs */
......
clk1 = clock();
/* code */
clk2 = clock();
|
by: CoreyWhite |
last post by:
The following experiment is a demonstration of TIME TRAVEL. When
writing this program, and testing it out I found that sometimes the
program would engage itself in time travel but other times it...
|
by: cj |
last post by:
Any body know a neat trick to put a analog clock on a form that would be
updated by a timer?
Far out in the uncharted backwaters of the unfashionable end of the
Western Spiral arm of the Galaxy...
|
by: cenktarhancenk |
last post by:
is there a way to display a ticking clock in a web page using
javascript? but not in a textbox, rather as text that i can change the
style, font etc.
cenk tarhan
|
by: Ali Rizwan |
last post by:
Is any body knw how to make an analog clock in vb6.0
Thanks in Advance
|
by: fayazmd |
last post by:
Hi,
I am creating an analog clock on my form by paint method. By default it is displaying at top left corner of my form. i wanted to put that clock wherever i want, means i want to display that...
|
by: Jerry Spence1 |
last post by:
Strange request, but does anyone know of a conrol which is an analogue clock
face. I don't want it to work like a clock, I just want to be able to grab
the hands and set an alarm time for use in my...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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...
| |