Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 6th, 2004, 09:49 AM
Rich's Avatar
Rich Rich is offline
Administrator
Developer Shed Admin.
 
Join Date: Sep 2003
Location: Fort Lauderdale, FL
Posts: 152 Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 11 h 47 m 28 sec
Reputation Power: 10
Drawing Graphics In ASP

A common issue with developing web sites for customers is sometimes the unfortunate inability to install server side components for performing specific tasks. A common question asked by beginners to ASP is how to draw graphics and send them to the browser. Normally, this task requires either client-side Java or server side COM objects to get the job done, and it has generally been accepted that th ... A common issue with developing web sites for customers is sometimes the unfortunate inability to install server side components for performing specific tasks. A common question asked by beginners to ASP is how to draw graphics and send them to the browser. Normally, this task requires either client-side Java or server side COM objects to get the job done, and it has generally been accepted that this will always be the case in pre-.NET environments.

The following class can change your attitude towards creating images

ASPCanvas

This is a self-extracting zip file, unzip into an area on your web server. There are two files that are needed to use this class:

canvas.asp (The main class)
font.asp (The font used for rendering text)

This class provides a simple canvas with which you draw things on, it is written in ASP and is initialised simply by:

<!--#include file="canvas.asp"-->
<%

Set objCanvas = New Canvas ' Create the object

objCanvas.GlobalColourTable(0) = RGB(255,255,255) ' First colour index to white
objCanvas.GlobalColourTable(1) = RGB(0,0,0) ' Second colour index to black

objCanvas.Resize 160,120,false ' Resize the canvas to 160x120, don't preserve the existing image

objCanvas.ForegroundColourIndex = 1 ' Set the drawing pen colour index to 1 (black)

objCanvas.Ellipse 100,100,30,20 ' Draw an ellipse in black, with two radii, 30 and 20 pixels
objCanvas.Circle 50,50,10 ' Draw a circle in black, radii of 10 pixels

objCanvas.Write ' Send the image to the browser
%>


Further instructions on using the class are included with the source files. This class supports the following drawing methods:

Copy X1,Y1,X2,Y2,X3,Y3 - Copy a region from X1,Y1,X2,Y2 to X3,Y3
Flood X,Y - Floodfill a region with the drawing pen colour, starting at X,Y
Line X1,Y1,X2,Y2 - Draw a line with the pen colour, from X1,Y1 to X2,Y2
Circle X,Y,Radius - Draw a circle at X,Y with a radius in pixels
Ellipse X,Y,Radius1,Radius2 - Draw an ellipse at X,Y with the two radii of Radius1 and Radius2
DrawTextWE X,Y,Text - Draw text from west to east at X,Y. Text is a string
DrawTextNS X,Y,Text - Draw text from north to south at X,Y. Text is a string
Clear - Clear the canvas to the current background colour index
Resize Width,Height,Preserve - Resize the canvas to Width and Height, set preserve to keep the current canvas image
Write - Send the image to the browser

And also the following properties:

Pixel(X,Y) - Sets or retrieves the current pixel colour index value
GlobalColourTable(Index) - Sets or retrieves the current global colour table RGB value
ForegroundColourIndex - Sets or retrieves the current drawing pen colour index
BackgroundColourIndex - Sets or retrieves the current background colour index
Version - Retrieves the current version of the class

Reply With Quote
  #2  
Old July 6th, 2004, 12:06 PM
eCommando eCommando is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 4 eCommando User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,
Where can I find the files, canvas.asp and font.asp? Where can I download it?

Thank you,

Reply With Quote
  #3  
Old August 3rd, 2005, 05:14 PM
cecirp cecirp is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Location: Lima, Peru
Posts: 1 cecirp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 31 m 25 sec
Reputation Power: 0
I have problems with aspcanvas - chart_graph

Hi, It's my first time in this forum, I don't know if i'm Ok, but I have a problem using Aspcanvas class.
I included a data_chart.asp page where i read my database and tried to show a linechart but It didn't show me anything.
My code is :

rs.Open str,cn,adOpenStatic,adLockReadOnly
RS.MoveFirst
cont = 0
acont = 0
do while not rs.EOF
if cont = 0 then
arr1 = cint(rs(0)) & "," & cdbl(rs(1))
arr2 = cint(rs(0)) & "," & cdbl(rs(2))
arr3 = cint(rs(0)) & "," & cdbl(rs(3))
arr4 = cint(rs(0)) & "," & cdbl(rs(4))
cont = 1
else
arr1 = arr1 & "," & cint(rs(0)) & "," & cdbl(rs(1))
arr2 = arr2 & "," & cint(rs(0)) & "," & cdbl(rs(2))
arr3 = arr3 & "," & cint(rs(0)) & "," & cdbl(rs(3))
arr4 = arr4 & "," & cint(rs(0)) & "," & cdbl(rs(4))
end if
acont = acont + 2
if wMaxX < rs(0) then wMaxX = rs(0)
if cdbl(wMinx) > cdbl(rs(0)) then wMinX = rs(0)
if wMaxY < cdbl(rs(1)) then wMaxY = cdbl(rs(1))
if wMaxY < cdbl(rs(2)) then wMaxY = cdbl(rs(2))
if wMaxY < cdbl(rs(3)) then wMaxY = cdbl(rs(3))
if wMaxY < cdbl(rs(4)) then wMaxY = cdbl(rs(4))
rs.MoveNext
loop

Then in the the page : graph_example.asp, I change this:
.
.
.
Set objSet = objChart.AddSet()
objSet.Name = " Prom. Velocidad"
objSet.DotColourIndex = 3
objSet.AddPoints array(Arr1)
objSet.LinePattern = "3"
objSet.DrawRoot = False
objSet.DrawValues = False
objSet.DrawName = False
objSet.DrawLines = True
objSet.DotCrossSize = 1
.
.
.

I'll appreciate so much if anybody could help me.

Thanks.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Drawing Graphics In ASP


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


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





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