Advanced Web Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsWeb DesignAdvanced Web Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 2nd, 2007, 11:47 AM
kestrel kestrel is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 4 kestrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 54 sec
Reputation Power: 0
Automatically draw lines on web page

Is there a way to draw an image on a web page based on the visitors input into a form?

For example, could you ask a person the height and width of a rectangle they want, and how many of that size, and then have them all drawn on that page?

If so, what would you need to do it as far as application/language goes?

I think it can be done by flash but I would like to use something that we could do in house so that when we add new designs to draw we don't have to have the whole flash module redesigned.

Thanks,

Jim

Reply With Quote
  #2  
Old February 7th, 2007, 10:23 PM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 549 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 7 h 3 m
Reputation Power: 4
svg ?

Hi kestrel, welcome to the forums,
Some amazing things can be done with javascript and Scalable Vector Graphics (SVG). Depending on the browser, you may need the Adobe plugin, but it's worth a look into.
Code:
<html>
<head>
<!-- code by Mittineague, March 2003 -->
<script> 
function drawWaveLengths() { //adds element to DOM
var SVGDoc = this.document.viewarea.getSVGDocument();

function drawVertLine(Xstart, Ystart, Xend, Yend, strokecolor){
newElem = SVGDoc.createElement("line");
newElem.setAttribute('x1', Xstart);
newElem.setAttribute('y1', Ystart);
newElem.setAttribute('x2', Xend);
newElem.setAttribute('y2', Yend);
newElem.setAttribute('style', 'stroke-opacity: 0.6; stroke: '+strokecolor+'; stroke-width: 1; fill: none');
newElem.setAttribute('visibility', 'visible');
SVGDoc.getElementById("display").appendChild(newElem);
 }
drawVertLine('10','0','10','400','grey');// baseline 10 = 0
drawVertLine('48','0','48','400','grey');// endviolet 38 + 10
drawVertLine('86','0','86','400','grey');// endred 76 + 10
drawVertLine('10','50','55','50','violet');
drawVertLine('10','55','59','55','blue');
drawVertLine('10','60','66','60','green');
drawVertLine('10','65','69','65','yellow');
drawVertLine('10','70','73','70','orange');
drawVertLine('10','75','86','75','red');
}

function addWaveLengths(){
var SVGDoc = this.document.viewarea.getSVGDocument();
 var addXstart =10;
 var addYstart = document.data.yaxis.value;
 var endline = eval(document.data.length.value)/100;
 var addXend = 10 + endline;
 var addYend =  document.data.yaxis.value;
 var addstrokecolor = document.data.color.value;

function addVertLine(Xstart, Ystart, Xend, Yend, strokecolor){
newElem = SVGDoc.createElement("line");
newElem.setAttribute('x1', Xstart);
newElem.setAttribute('y1', Ystart);
newElem.setAttribute('x2', Xend);
newElem.setAttribute('y2', Yend);
newElem.setAttribute('style', 'stroke-opacity: 0.9; stroke: '+strokecolor+'; stroke-width: 2; fill: none');
newElem.setAttribute('visibility', 'visible');
SVGDoc.getElementById("display").appendChild(newElem);
 }
addVertLine(addXstart, addYstart, addXend, addYend, addstrokecolor);
}
</script>
</head>
<body bgcolor="#badbee" onLoad="drawWaveLengths()">
Angstrom = 10<sup>-10</sup>m &nbsp; 1 pixel = 100 angstroms
<!-- SVG document is embedded in HTML --> 
<center>
<embed name="viewarea" src="display.svg" width="700" height="400"/>
<table border="1" bordercolor="#000000"><tr><td>gamma-ray <.1, x-ray .1-100, ultra-violet 100-4000 = ultra-violet <3800,</td></tr><tr><td>violet 3800-4500, blue 4500-4900, green 4900-5600, yellow 5600-5900, orange 5900-6300, red 6300-7600,</td></tr><tr><td>infra-red >7600 = infra-red  7000-10,000,000, microwave 10,000,000-1,000,000,000, radio >1,000,000,000</td></tr></table> 
<form name="data">
<table border="1" bordercolor="#000000"><tr><td>
Y-axis location<br/> 
<input name="yaxis" type="text" value=""/>
</td><td>
Length in Angstroms<br/>
<input name="length" type="text" value=""/>
</td><td>
Color<br/>
<input name="color" type="text" value=""/>
</td><td>
<input type="button" value="add line" onClick="addWaveLengths()"/>
</td></tr></table>
</form>
</center>
</body>
</html>

Reply With Quote
  #3  
Old February 7th, 2007, 11:27 PM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 549 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 7 h 3 m
Reputation Power: 4
svg file

I just realized that other file won't be of much use to you without the "display.svg" file
Code:
<?xml version="1.0"?>
<svg>
<!--size of canvas-->
<g id="display" width="500" height="250" style="visibility:hidden"/>
</svg>
Of course this example is only lines, but SVG can do lots more.

Last edited by Mittineague : February 7th, 2007 at 11:30 PM.

Reply With Quote
  #4  
Old February 8th, 2007, 04:03 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 1,001 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 993446 Folding Title: Super Ultimate Folder - Level 2Folding Points: 993446 Folding Title: Super Ultimate Folder - Level 2Folding Points: 993446 Folding Title: Super Ultimate Folder - Level 2Folding Points: 993446 Folding Title: Super Ultimate Folder - Level 2Folding Points: 993446 Folding Title: Super Ultimate Folder - Level 2Folding Points: 993446 Folding Title: Super Ultimate Folder - Level 2Folding Points: 993446 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 15 h 6 m 59 sec
Reputation Power: 6
Send a message via ICQ to Itsacon
Alternatively, if your server is running PHP, see if the GD library is active. If it is , you can create all sorts of images using that.
__________________
This is my code. Is it not nifty?

"The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools."
---Douglas Adams


Join the Itsacon fanclub!    
Zero Tolerance: Spammers banned so far: 280

Reply With Quote
  #5  
Old February 8th, 2007, 10:17 AM
kestrel kestrel is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 4 kestrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 54 sec
Reputation Power: 0
Thank you! I will try both out. My concern about the java scripts and such is that about 20% (and growing) of those that use our site use Firefox. I was't sure how well it would work since you mention about trouble with some browsers.

Then again, would we run into the same problem with PHP?

I am chatting with a tech person for the hosting company to find out if te GD Library is available. I do know that we can install other applications so I don't think that will be a proble.

I had thought about using CSS like you would for tabs and break since the center of each image is "Stretchable"

Either way, thank you both very much!

Jim

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsWeb DesignAdvanced Web Development > Automatically draw lines on web page


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT