draw grid lines over an image in Javascript

Discussion in 'Javascript' started by Jonas Geiregat, Aug 3, 2006.

  1. wrote:
    > Hey there,
    >
    > I have a large image in a browser window, and I would like a way to
    > overlay grid lines on top of the image, so a user can show the grid or
    > hide the grid lines. The grid would cover 100% of the image, and all I
    > would need is a set of horizontal and vertical lines over the image to
    > create a grid overlay
    >
    > Is there a way I can leverage some functionality in Javascript to do
    > this? I can't use any server side 3rd party components, and I would
    > rather not do this using something on the server side like GDI+ through
    > ASP.NET.
    >
    > Thanks,
    >
    > Christian
    >


    I don't think javascript will be able to do the job, but seems possible
    with css.
    Jonas Geiregat, Aug 3, 2006
    #1
    1. Advertising

  2. Jonas Geiregat

    Guest

    Hey there,

    I have a large image in a browser window, and I would like a way to
    overlay grid lines on top of the image, so a user can show the grid or
    hide the grid lines. The grid would cover 100% of the image, and all I
    would need is a set of horizontal and vertical lines over the image to
    create a grid overlay

    Is there a way I can leverage some functionality in Javascript to do
    this? I can't use any server side 3rd party components, and I would
    rather not do this using something on the server side like GDI+ through
    ASP.NET.

    Thanks,

    Christian
    , Aug 3, 2006
    #2
    1. Advertising

  3. Jonas Geiregat

    bobzimuta Guest

    wrote:
    > Hey there,
    >
    > I have a large image in a browser window, and I would like a way to
    > overlay grid lines on top of the image, so a user can show the grid or
    > hide the grid lines. The grid would cover 100% of the image, and all I
    > would need is a set of horizontal and vertical lines over the image to
    > create a grid overlay
    >
    > Is there a way I can leverage some functionality in Javascript to do
    > this? I can't use any server side 3rd party components, and I would
    > rather not do this using something on the server side like GDI+ through
    > ASP.NET.
    >
    > Thanks,
    >
    > Christian


    Here's a 'proof of concept' type page - firefox tested only
    http://em.hopto.org/code/test/javascript/grid.html
    bobzimuta, Aug 3, 2006
    #3
  4. Jonas Geiregat

    bobzimuta Guest

    wrote:
    > Hey there,
    >
    > I have a large image in a browser window, and I would like a way to
    > overlay grid lines on top of the image, so a user can show the grid or
    > hide the grid lines. The grid would cover 100% of the image, and all I
    > would need is a set of horizontal and vertical lines over the image to
    > create a grid overlay
    >
    > Is there a way I can leverage some functionality in Javascript to do
    > this? I can't use any server side 3rd party components, and I would
    > rather not do this using something on the server side like GDI+ through
    > ASP.NET.
    >
    > Thanks,
    >
    > Christian


    Now that I think of it: best to create a table and overlay it on the
    image. You get a nice grid pattern, and it would be easier to work with
    if you want to start manipulating the grids or filling them in with
    colors. Hope that gives you some ideas.
    bobzimuta, Aug 3, 2006
    #4
  5. Jonas Geiregat

    Guest

    Thank you very much for the feedback and example.

    The grid will be used so that users can align objects correctly on the
    underlying image, so two requirements would be to turn the grid "on"
    and "off", and set the spacing between the lines. Width and color of
    the lines in the grid will stay constant.

    Christian


    bobzimuta wrote:
    > wrote:
    > > Hey there,
    > >
    > > I have a large image in a browser window, and I would like a way to
    > > overlay grid lines on top of the image, so a user can show the grid or
    > > hide the grid lines. The grid would cover 100% of the image, and all I
    > > would need is a set of horizontal and vertical lines over the image to
    > > create a grid overlay
    > >
    > > Is there a way I can leverage some functionality in Javascript to do
    > > this? I can't use any server side 3rd party components, and I would
    > > rather not do this using something on the server side like GDI+ through
    > > ASP.NET.
    > >
    > > Thanks,
    > >
    > > Christian

    >
    > Now that I think of it: best to create a table and overlay it on the
    > image. You get a nice grid pattern, and it would be easier to work with
    > if you want to start manipulating the grids or filling them in with
    > colors. Hope that gives you some ideas.
    , Aug 3, 2006
    #5
  6. Jonas Geiregat

    bobzimuta Guest

    wrote:
    > Thank you very much for the feedback and example.
    >
    > The grid will be used so that users can align objects correctly on the
    > underlying image, so two requirements would be to turn the grid "on"
    > and "off", and set the spacing between the lines. Width and color of
    > the lines in the grid will stay constant.
    >


    Will you be 'snapping' the objects to the grid? i.e. once an object is
    dragged within a couple pixels of a gridline, it is brought up against
    it. That would be pretty cool.
    bobzimuta, Aug 3, 2006
    #6
  7. Jonas Geiregat

    Guest

    Not sure yet :) My immediate task is to come up with a proof of
    concept implementation just involving the grid, but that sounds like a
    really good idea. Omly two requirements so far: show/hide the grid,
    and adjust the spacing of the grid lines.

    bobzimuta wrote:
    > wrote:
    > > Thank you very much for the feedback and example.
    > >
    > > The grid will be used so that users can align objects correctly on the
    > > underlying image, so two requirements would be to turn the grid "on"
    > > and "off", and set the spacing between the lines. Width and color of
    > > the lines in the grid will stay constant.
    > >

    >
    > Will you be 'snapping' the objects to the grid? i.e. once an object is
    > dragged within a couple pixels of a gridline, it is brought up against
    > it. That would be pretty cool.
    , Aug 3, 2006
    #7
  8. Jonas Geiregat

    PDannyD Guest

    On Thursday 03 August 2006 22:02,
    [] wrote in message
    <>

    > Hey there,
    >
    > I have a large image in a browser window, and I would like a way to
    > overlay grid lines on top of the image, so a user can show the grid or
    > hide the grid lines. The grid would cover 100% of the image, and all I
    > would need is a set of horizontal and vertical lines over the image to
    > create a grid overlay


    A table with thin cell borders over the top? Or maybe just use <div>
    elements to form a grid?

    There might be something[1] server-side which you could install that would
    render an on-the-fly overlay grid as a transparent GIF/PNG image.

    > Is there a way I can leverage some functionality...<snip>


    <big smiley for the following>

    I *hate* that use of "leverage". What's wrong with "use"
    "Is there a way I can use some functionality..."
    or
    "Is there some function to give me greater leverage..."

    but I would have written the second paragraph like this:
    "Is there a built-in javascript function to do this?"

    See? Simple, quick, clear.


    [1] I have speel chucking switchd om nd ths wurd wasnnt higligted when the
    'h' was omited. Odd!
    PDannyD, Aug 3, 2006
    #8
  9. Jonas Geiregat

    bobzimuta Guest

    PDannyD wrote:
    > There might be something[1] server-side which you could install that would
    > render an on-the-fly overlay grid as a transparent GIF/PNG image.


    Negates the abillity to move the gridlines around
    bobzimuta, Aug 4, 2006
    #9
  10. Jonas Geiregat

    PDannyD Guest

    On Friday 04 August 2006 00:37, bobzimuta [] wrote in
    message <>

    >
    > PDannyD wrote:
    >> There might be something[1] server-side which you could install that
    >> would render an on-the-fly overlay grid as a transparent GIF/PNG image.

    >
    > Negates the abillity to move the gridlines around


    And missed the bit about not wanting to use anything server-side. Doh!
    PDannyD, Aug 4, 2006
    #10
  11. Jonas Geiregat

    cwdjrxyz Guest

    wrote:
    > Hey there,
    >
    > I have a large image in a browser window, and I would like a way to
    > overlay grid lines on top of the image, so a user can show the grid or
    > hide the grid lines. The grid would cover 100% of the image, and all I
    > would need is a set of horizontal and vertical lines over the image to
    > create a grid overlay
    >
    > Is there a way I can leverage some functionality in Javascript to do
    > this? I can't use any server side 3rd party components, and I would
    > rather not do this using something on the server side like GDI+ through
    > ASP.NET.


    It is quite possible to draw both vertical and horizontal lines using
    script to write the necessary CSS. Then the divisions, each with a
    unique id, holding the lines can be turned on or off using visibility
    as visible or hidden. I have an example that writes extremely fine
    lines that can be so controlled, but it is much more elaborate than
    what you likely need. Anyway, you can see the page and look at the
    source at http://www.cwdjr.info/dhtml/7veilsDance3.html . My lines are
    automatically being turned on and off in a sequence to simulate a
    curtain pull. You would need to use a button to turn lines on and off
    by controlling visibility instead.
    cwdjrxyz, Aug 4, 2006
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer
    Replies:
    0
    Views:
    375
    Kevin Spencer
    Jun 30, 2004
  2. Matt Melchert
    Replies:
    7
    Views:
    423
    Chris Smith
    Oct 3, 2003
  3. Kevin
    Replies:
    3
    Views:
    438
    =?ISO-8859-15?Q?R=E9mi?= Bastide
    Feb 28, 2006
  4. Matt
    Replies:
    2
    Views:
    542
    Pete Becker
    Oct 5, 2003
  5. Josef Moellers

    How to draw thin lines with Image::Magick?

    Josef Moellers, Jan 31, 2011, in forum: Perl Misc
    Replies:
    7
    Views:
    383
    Josef Moellers
    Feb 2, 2011
Loading...

Share This Page