draw grid lines over an image in Javascript

J

Jonas Geiregat

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.
 
K

kaczmar2

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
 
B

bobzimuta

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
 
B

bobzimuta

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.
 
K

kaczmar2

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
 
B

bobzimuta

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.
 
K

kaczmar2

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.
 
P

PDannyD

On Thursday 03 August 2006 22:02, (e-mail address removed)
[[email protected]] 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!
 
B

bobzimuta

PDannyD said:
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
 
P

PDannyD

On Friday 04 August 2006 00:37, bobzimuta [[email protected]] wrote in
message said:
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!
 
C

cwdjrxyz

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top