| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 |
|
#2
|
|||
|
|||
|
Hi,
Where can I find the files, canvas.asp and font.asp? Where can I download it? Thank you, |
|
#3
|
|||
|
|||
|
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. |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Drawing Graphics In ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|