Drawing line using map coordinates

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kien

    #16
    Re: Drawing line using map coordinates

    Try this DHTML. Very crude but I hope it gives you some lead


    Kien

    atif@kics.edu.p k (Atif) wrote in message news:<6a0a3f23. 0312240536.43df 8f1a@posting.go ogle.com>...[color=blue]
    > Hello all,
    > In my html page I want to add an image say of 800x600. Now I want that
    > when ever I am given two coordinates on this image say (x1, y1)=(50,
    > 100) and (x2, y2)=(200, 300), the java script code will trace these
    > coordinates on the image and draw the line between these two points.
    > Can anyone please help me in writing the javascript code of this
    > problem?
    >
    > Thanks and Regards
    > Atif[/color]

    Comment

    • cwdjr

      #17
      Re: Drawing line using map coordinates

      If you can write a mathematical expression for a curve, you can usualy
      use JS to either display the selected path or move an object along it.
      The secret is that JS can write both css and html. An example is at
      http://www.cwdjr.net/dhtml/cuckoo.html . The curtain is built up of
      hundreds of narrow vertical lines. The background-color of each
      division is calculated as a function of x to produce the fold effect
      in the curtain. It is most convenient to work using (r,g,b) for this.
      For most computers a division must have some content to avoid
      distortion. A single period of 1 px size and about the same color as
      the background color usually works well enough. You can then use
      visibility to hide each of the curtain divisions in sequence to open
      the curtain. The circle is produced in much the same way, with the
      vertical strips making up the circle starting and ending on the locus
      of the circle. It is convenient to use polar coordinates for this.
      Another example is at http://www.cwdjr.net/geometric/curve_write.html
      .. Here some typical curves from analytical geometry are drawn. The
      code to do these things usually is not very long. You just use a few
      loops to generate the hundreds of document.write statements to create
      all of the small divisions. The code for the first cuckoo sample is
      very extreme. It validates as W3C xhtml 1.1. And how can that be, if
      it has no style sheet? Even the general style sheet is written using
      JS and document.write. But what does the W3C css validator think? It
      is satisfied. It finds no style sheet, but does not detect any illegal
      use of bgcolor, text, etc. in the code. In fact this page is nearly
      all JS. The one body statment is just a dummy, that does nothing
      useful, to keep the W3C xhtml 1.1 validator from complaining about no
      body content detected. At lower levels of html, you often can get away
      with writing the body statement itself with JS. One of the free hosts
      once was using detection of the body statement to indicate that the
      file was an html page suitable for their pop up ads. Some hackers
      found they could defeat the ads by using a document.write to write the
      body statement with "bo" and "dy" being combined in the document.write
      so there was no free "body" to view. Another approach that will allow
      you to do some drawing is SMIL. SMIL, the last I heard, is still not
      official, but it seems to be in the final stages at the W3C. The IE6
      will handle part of SMIL, but their code works only on IE6 - surprise,
      surprise. Real has been a strong supporter of SMIL and their Real One
      player supports most of the SMIL that the W3C has considered. It is
      fun to play with. Real has a huge amount of information on SMIL, but
      it takes considerable time to digest.

      Comment

      • Jim Ley

        #18
        Re: Drawing line using map coordinates

        On 25 Dec 2003 20:16:14 -0800, cwdjrxyz@yahoo. com (cwdjr) wrote:
        [color=blue]
        >Another approach that will allow
        >you to do some drawing is SMIL. SMIL, the last I heard, is still not
        >official, but it seems to be in the final stages at the W3C.[/color]

        SMIL 2.0 has been a REC since 2001.

        Jim.
        --
        comp.lang.javas cript FAQ - http://jibbering.com/faq/

        Comment

        • Mark Szlazak

          #19
          Re: Drawing line using map coordinates

          atif@kics.edu.p k (Atif) wrote in message news:<6a0a3f23. 0312240536.43df 8f1a@posting.go ogle.com>...[color=blue]
          > Hello all,
          > In my html page I want to add an image say of 800x600. Now I want that
          > when ever I am given two coordinates on this image say (x1, y1)=(50,
          > 100) and (x2, y2)=(200, 300), the java script code will trace these
          > coordinates on the image and draw the line between these two points.
          > Can anyone please help me in writing the javascript code of this
          > problem?
          >
          > Thanks and Regards
          > Atif[/color]

          OP, some posts have given a basic JavaScript only way to draw lines of
          any orientation by arranging many small colored layers in a straight
          line. Slow but speed may not matter.

          Another way that I haven't tried but maybe faster is to have gif's of
          full lines each with transparent backgrounds and of different
          orientation, say every 1 or 2 degrees. These gif's could all be in one
          layer. That one layer could then be scaled, moved, and the gif with
          the correct orientation shown. I have a page that works in IE and NN4
          that does most of this except the scaling for a different effect,
          rotating a pool cue based on mouse cursor position, but the ideas are
          similar.



          An alternative to many separate gif's is one large gif that has many
          images of the line in different orientations arranged in rows and
          columns. In this case you would also need to clip this large gif to
          the appropriate image after scaling and move it to the correct
          coordinates.

          Maybe these alternatives provide better ways to do lines than
          arranging many small individual colored layer squares.

          Comment

          • Dr John Stockton

            #20
            Re: Drawing line using map coordinates

            JRS: In article <bsf90l$245$1@n ews.eusc.inter. net>, seen in
            news:comp.lang. javascript, DU <drunclear@hotW IPETHISmail.com > posted at
            Thu, 25 Dec 2003 13:07:09 :-[color=blue]
            >Dr John Stockton wrote:[color=green]
            >> JRS: In article <bsdj6c$ldi$1@n ews.eusc.inter. net>, seen in
            >> news:comp.lang. javascript, DU <drunclear@hotW IPETHISmail.com > posted at
            >> Wed, 24 Dec 2003 21:48:37 :-[color=darkred]
            >>>As others mentioned, this is best done with SVG. SVG has all the
            >>>capabiliti es and more (much more) to satisfy your requirements.[/color]
            >>
            >>
            >> Such a recommendation is better accompanied by an indication of where to
            >> seek more information, and what is required to run SVG.[/color]
            >
            >
            >Google.com, searching for svg newsgroups, etc... was a start. I was in
            >no way preventing the original poster to ask back for more clues, hints,
            >etc. on how to achieve what he wants with SVG. My post was not imposing
            >any implicit constraint.[/color]

            This is a Usenet newsgroup. Many read it off-line, and do not have
            immediate access to Google. Authors should endeavour to make their
            pages understandable to such readers.

            This is a javascript newsgroup, and the default assumption in it is that
            the javascript is being used on Web pages, and is being run on a Web
            browser in its default state. If the technique recommended needs more
            than that, an explanation is called for; though it need only be brief.

            [color=blue][color=green]
            > > I have no recollection of the term, and suspect that SVG may not be
            > > available to me.[/color][/color]

            Responses should go after quoted material; see FAQ etc.


            For me, <URL: http://members.aol.com/_ht_a/hikksno.../graphit/index.
            html/> draws a blue rectangle on a white background, eventually. It
            shows not a word of explanation.

            --
            © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
            <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
            <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
            <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

            Comment

            Working...