ASP Painter
Home
Home
Samples
Samples
Purchase
Purchase
Download
Download
Documentation
Documentation


ASPPainter Samples

Sample 1 - Create a chart. 

Filled rectangles, copying images
 



Sub MakeCoord(s,coords,x,y,w,t,h,a)
Dim c(2,8)

'bottom
c(1,1) = x
c(2,1) = y
c(1,2) = CInt(x+t*cos(a))
c(2,2) = CInt(y-t*sin(a))
c(1,3) = CInt(x+w+t*cos(a))
c(2,3) = CInt(y-t*sin(a))
c(1,4) = x+w
c(2,4) = y

c(1,5) = x
c(2,5) = y-h
c(1,6) = CInt(x+t*cos(a))
c(2,6) = CInt(y-h-t*sin(a))
c(1,7) = CInt(x+w+t*cos(a))
c(2,7) = CInt(y-h-t*sin(a))
c(1,8) = x+w
c(2,8) = y-h


Select case s
    case 1 'bottom
	coords(0) = c(1,1)
	coords(1) = c(2,1)
	coords(2) = c(1,2)
	coords(3) = c(2,2)
	coords(4) = c(1,3)
	coords(5) = c(2,3)
	coords(6) = c(1,4)
	coords(7) = c(2,4)

   case 2 'top
	coords(0) = c(1,5)
	coords(1) = c(2,5)
	coords(2) = c(1,6)
	coords(3) = c(2,6)
	coords(4) = c(1,7)
	coords(5) = c(2,7)
	coords(6) = c(1,8)
	coords(7) = c(2,8)
   case 3   'back
	coords(0) = c(1,2)
	coords(1) = c(2,2)
	coords(2) = c(1,6)
	coords(3) = c(2,6)
	coords(4) = c(1,7)
	coords(5) = c(2,7)
	coords(6) = c(1,3)
	coords(7) = c(2,3)
   case 4 'left
	coords(0) = c(1,1)
	coords(1) = c(2,1)
	coords(2) = c(1,5)
	coords(3) = c(2,5)
	coords(4) = c(1,6)
	coords(5) = c(2,6)
	coords(6) = c(1,2)
	coords(7) = c(2,2)
   case 5   'right
	coords(0) = c(1,3)
	coords(1) = c(2,3)
	coords(2) = c(1,4)
	coords(3) = c(2,4)
	coords(4) = c(1,8)
	coords(5) = c(2,8)
	coords(6) = c(1,7)
	coords(7) = c(2,7)

   case 6   'front
	coords(0) = c(1,1)
	coords(1) = c(2,1)
	coords(2) = c(1,5)
	coords(3) = c(2,5)
	coords(4) = c(1,8)
	coords(5) = c(2,8)
	coords(6) = c(1,4)
	coords(7) = c(2,4)
end select

end Sub

'====================================
'background
'====================================
Function background(x,y,w,t,h,a)


Dim coords(100)


'bottom
MakeCoord 1,coords,x,y,w,t,h,a
im.SetColor 127,255,255,alpha
im.DrawFilledPolygon coords, 8
im.SetColor 127,127,255,255
	im.DrawLine coords(0),coords(1),coords(6),coords(7)
        im.DrawLine coords(0),coords(1),coords(2),coords(3)
        im.DrawLine coords(4),coords(5),coords(2),coords(3)
        im.DrawLine coords(4),coords(5),coords(6),coords(7)

'back
im.SetColor 215,215,215,alpha
MakeCoord 3,coords,x,y,w,t,h,a
'im.DrawFilledPolygon coords, 8
'im.SetColor 0,0,0,255
im.SetColor 127,127,255,255
'im.DrawLine coords(6),coords(7),coords(0),coords(1)
im.DrawLine coords(4),coords(5),coords(6),coords(7)
im.DrawLine coords(0),coords(1),coords(6),coords(7)
im.DrawLine coords(0),coords(1),coords(2),coords(3)
im.DrawLine coords(4),coords(5),coords(2),coords(3)


'left
im.SetColor 215,215,215,alpha
MakeCoord 4,coords,x,y,w,t,h,a
'im.DrawFilledPolygon coords, 8
'im.SetColor 0,0,0,255
im.SetColor 127,127,255,255
im.DrawLine coords(4),coords(5),coords(6),coords(7)
im.DrawLine coords(0),coords(1),coords(6),coords(7)
im.DrawLine coords(0),coords(1),coords(2),coords(3)
im.DrawLine coords(4),coords(5),coords(2),coords(3)


end function
'================================================



'========================================
'Draw chart
'========================================
Function cub(x,y,w,h,t,a)
Dim coords(100)

for s=1 to 6
MakeCoord s,coords,x,y,w,t,h,a
'im.SetColor colors(1,i), colors(2,i),colors(3,i),196
im.SetColor colors(1,j), colors(2,j),colors(3,j),127
im.DrawFilledPolygon coords, 8
im.SetColor 0,0,0,255


im.SetBlendingMode 0
Select case s

	case 2,5,6:

	im.DrawLine coords(0),coords(1),coords(6),coords(7)
        im.DrawLine coords(0),coords(1),coords(2),coords(3)
        im.DrawLine coords(4),coords(5),coords(2),coords(3)
        im.DrawLine coords(4),coords(5),coords(6),coords(7)

	
end select
im.SetBlendingMode 1

next


end function

'================================================
'  main 
'================================================
Dim im
Set im = CreateObject("ASPPainter.Pictures.1")

alpha = 255
angle = 3.14*61/180
w = 24
h = 20
t = 18
st = w + 6

im.SetBKColor 255,255,255,0
im.Create 200,100

im.SetFontName "Verdana"
im.SetFontBold 1
im.SetFontSize 16
im.SetColor 49, 16, 106,255
im.TextOut  40, 0 ,"ASPPainter"

im.SetColor 127,255,255,alpha



'background 25,148,200,55,90,angle
background 0,99,180,39,65,angle


Dim d(4,8)
Dim colors(3,8)
colors(1,1) = 255
colors(2,1) = 0
colors(3,1) = 0

colors(1,2) = 0
colors(2,2) = 0
colors(3,2) = 255

colors(1,3) = 255
colors(2,3) = 255
colors(3,3) = 0

colors(1,4) = 255
colors(2,4) = 0
colors(3,4) = 255

colors(1,5) = 0
colors(2,5) = 255
colors(3,5) = 0




Randomize
For i = 1 to 5
d(1,i) = CInt(RND*40)
d(2,i) = CInt(RND*40)
d(3,i) = CInt(RND*40)
d(4,i) = CInt(RND*40)
next 

'im.SetBlendingMode 0
for j = 1 to 5
	im.SetColor colors(1,j), colors(2,j),colors(3,j),127
	cub j*st-15,92,w,d(1,j),t,angle
next

im.SaveToFile "C:\chart.png"
im.SetFormat 3
im.SaveToFile "C:\chart.gif"


im.DestroyALL
Set im = Nothing


Figure 1. chart.gif (size - 2.4 Kb)



home samples purchase documentation download