By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,146 Members | 1,820 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,146 IT Pros & Developers. It's quick & easy.

draw grid lines over an image in Javascript

P: n/a
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 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
ka******@hotmail.com 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.
Aug 3 '06 #2

P: n/a

ka******@hotmail.com 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

Aug 3 '06 #3

P: n/a

ka******@hotmail.com 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 '06 #4

P: n/a
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:
ka******@hotmail.com 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 '06 #5

P: n/a

kaczm...@hotmail.com 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 '06 #6

P: n/a
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:
kaczm...@hotmail.com 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 '06 #7

P: n/a
On Thursday 03 August 2006 22:02, ka******@hotmail.com
[ka******@hotmail.com] wrote in message
<11*********************@s13g2000cwa.googlegroups. com>
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!
Aug 3 '06 #8

P: n/a

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

Aug 3 '06 #9

P: n/a
On Friday 04 August 2006 00:37, bobzimuta [ej******@gmail.com] wrote in
message <11**********************@m73g2000cwd.googlegroups .com>
>
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!
Aug 4 '06 #10

P: n/a

ka******@hotmail.com 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.

Aug 4 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.