Example vbscript for pixel processing
'Always include a main() function
function main()
' Always start with a main() function
'example of a way to access pixels from Howler via VBScript.
'since VBscript does not support byte arrays, we have a special class that uses arrays of variants.
'since VBScript is interpreted, it may be too slow for pixel processing. Use your judgement. Our lua compiler may be a 'better choice.
dogwaffle.dog_saveundo "Render pixels" 'always save an undo when changing the main image. Give your undo a name.
w=pixels.width
h=pixels.height
rbuf=pixels.getrbuf
gbuf=pixels.getgbuf
bbuf=pixels.getbbuf
for y=0 to h-1
for x=0 to w-1
r=rbuf(x,y)
g=gbuf(x,y)
b=bbuf(x,y)
r= rnd*r 'Howler does it clamping automatically
g= rnd*g
b= rnd*b
rbuf(x,y)=r
gbuf(x,y)=g
bbuf(x,y)=b
next
next
pixels.setrbuf rbuf
pixels.setgbuf gbuf
pixels.setbbuf bbuf
pixels.alphablend 'this blits the current image with the undo image, through the current selection, if any.
pixels.refresh
end function
Pixel class reference
Function GetRbuf() As Variant
Function GetGbuf() As Variant
Function GetBbuf() As Variant
Function Width() As Variant
Function Height() As Variant
Sub SetRbuf(buf As Variant)
Sub SetGbuf(buf As Variant)
Sub SetBbuf(buf As Variant)
'blend the current image with the undo image
Sub AlphaBlend()
'refresh the window
Sub Refresh()