The common principles of creating images with SHOTgraph

SHOTgraph is an OLE automation server. Therefore, you need to have an OLE automation controller application to use it. There are a number of applications which can be used as Automation controllers. For example, you can use

Step by step

  1. First, create an object of type "shotgraph.image".
  2. Call CreateImage method.
  3. Call SetColor method one or several times to define the colors will be used to draw the image.
  4. Clear the painting area of your image, if required, by calling FillRect method.
  5. Call neccessary functions in accordance with logic of your application to draw image.
  6. Call GifImage function. Your image is ready!
The following simple example demonstrates how to create the image on the right-hand site with SHOTgraph
The size of the image is 201x201.

Code on VBScript

'Creating the object
set obj=CreateObject("shotgraph.image")

size=201
'Calling the CreateImage method
obj.CreateImage size,size,4

'Set 4 colors for drawing
obj.SetColor 0,255,255,255
obj.SetColor 1,0,0,0
obj.SetColor 2,255,108,0
obj.SetColor 3,0,0,204

'Crearing the painting area with color 0
obj.SetBgColor 0
obj.FillRect 0,0,size-1,size-1

'Color 0 will be used for drawing
obj.SetDrawColor 1
'Drawing the line
obj.Line size-1,0,0,size-1
'Color 2 will be used for filling
obj.SetBgColor 2
'Draw the big circle
obj.Ellipse 5,5,size-6,size-6
'Color 2 will be used for filling
obj.SetBgColor 3
'Draw the small circle
obj.Ellipse 5,(size-5)/4,size/2,(size-5)*3/4

'Create the image file named test.gif
obj.GifImage 0,1,"test.gif"
The same example are in ASP and in Perl:
ASP

Response.ContentType="image/gif"
set obj=Server.CreateObject("shotgraph.image")

size=201
obj.CreateImage size,size,4
obj.SetColor 0,255,255,255
obj.SetColor 1,0,0,0
obj.SetColor 2,255,108,0
obj.SetColor 3,0,0,204
obj.SetBgColor 0
obj.FillRect 0,0,size-1,size-1

obj.SetDrawColor 1
obj.Line size-1,0,0,size-1
obj.SetBgColor 2
obj.Ellipse 5,5,size-6,size-6
obj.SetBgColor 3
obj.Ellipse 5,(size-5)/4,size/2,(size-5)*3/4

img=obj.GifImage 0,1,""
Response.BinaryWrite img
Perl

$obj=CreateObject("shotgraph.image")

$size=201
$obj->CreateImage($size,$size,4)
$obj->SetColor(0,255,255,255)
$obj->SetColor(1,0,0,0)
$obj->SetColor(2,255,108,0)
$obj->SetColor(3,0,0,204)
$obj->SetBgColor(0)
$obj->FillRect(0,0,$size-1,$size-1)

$obj->SetDrawColor(1)
$obj->Line($size-1,0,0,$size-1)
$obj->SetBgColor(2)
$obj->Ellipse(5,5,$size-6,$size-6)
$obj->SetBgColor(3)
$obj->Ellipse(5,($size-5)/4,$size/2,($size-5)*3/4)

$obj->GifImage(0,1,"test.gif")