Im having problems with the blending - cant seem to get my head around it.
Beaker helped me with the gradient but im still a little stuck.
Here is my code (with some rgb functions from Rob Farley)
It should blend the first tile into black (my idea is to blend 2 tiles together but i need to get this right first) - It isn't working - it seems to start ok then turns into a rainbow pattern!?!?!
Any help appreciated Thanks
;### Initialise
graphics 800, 600, 16
transition=loadanimimage("D:\Projects\Game Graphics\tileset2.bmp",64,64,0,50)
drawimage transition,0,0,1
drawimage transition,128,0,2
trans1=createimage(64,64)
trans2=createimage(64,64)
grabimage trans1,0,0
grabimage trans2,128,0
scratch=createimage(64,64)
;### Main Loop
for y=0 to 63
for x= 0 to 63
red1=read_r(x,y,trans1)
green1=read_g(x,y,trans1)
blue1=read_b(x,y,trans1)
; red2=read_r(x,y,trans2)
; green2=read_g(x,y,trans2)
; blue2=read_b(x,y,trans2)
gradient1#=float(x)/63*255
compred#=float(red1/gradient1#)*255
compgreen#=Float(green1/gradient1#)*255
compblue#=float(blue1/gradient1#)*255
write_rgb x,y,compred#,compgreen#,compblue#,scratch
next
next
drawimage scratch,64,0
while not keyhit(1)
wend
;### Functions
;####################################################################
;ARGB Functions by Rob Farley 2003
;rob@...
;http://www.mentalillusion.co.uk
Function read_r(x,y,image_name)
argb=ReadPixel(x,y,ImageBuffer(image_name))
Return (ARGB Shr 16) And $ff
End Function
Function read_g(x,y,image_name)
argb=ReadPixel(x,y,ImageBuffer(image_name))
Return (ARGB Shr 8) And $ff
End Function
Function read_b(x,y,image_name)
argb=ReadPixel(x,y,ImageBuffer(image_name))
Return ARGB And $ff
End Function
Function write_rgb(x,y,r,g,b,image_name)
argb=(b Or (g Shl 8) Or (r Shl 16) Or ($ff000000))
WritePixel x,y,argb,ImageBuffer(image_name)
End Function
Beaker helped me with the gradient but im still a little stuck.
Here is my code (with some rgb functions from Rob Farley)
It should blend the first tile into black (my idea is to blend 2 tiles together but i need to get this right first) - It isn't working - it seems to start ok then turns into a rainbow pattern!?!?!
Any help appreciated Thanks
;### Initialise
graphics 800, 600, 16
transition=loadanimimage("D:\Projects\Game Graphics\tileset2.bmp",64,64,0,50)
drawimage transition,0,0,1
drawimage transition,128,0,2
trans1=createimage(64,64)
trans2=createimage(64,64)
grabimage trans1,0,0
grabimage trans2,128,0
scratch=createimage(64,64)
;### Main Loop
for y=0 to 63
for x= 0 to 63
red1=read_r(x,y,trans1)
green1=read_g(x,y,trans1)
blue1=read_b(x,y,trans1)
; red2=read_r(x,y,trans2)
; green2=read_g(x,y,trans2)
; blue2=read_b(x,y,trans2)
gradient1#=float(x)/63*255
compred#=float(red1/gradient1#)*255
compgreen#=Float(green1/gradient1#)*255
compblue#=float(blue1/gradient1#)*255
write_rgb x,y,compred#,compgreen#,compblue#,scratch
next
next
drawimage scratch,64,0
while not keyhit(1)
wend
;### Functions
;####################################################################
;ARGB Functions by Rob Farley 2003
;rob@...
;http://www.mentalillusion.co.uk
Function read_r(x,y,image_name)
argb=ReadPixel(x,y,ImageBuffer(image_name))
Return (ARGB Shr 16) And $ff
End Function
Function read_g(x,y,image_name)
argb=ReadPixel(x,y,ImageBuffer(image_name))
Return (ARGB Shr 8) And $ff
End Function
Function read_b(x,y,image_name)
argb=ReadPixel(x,y,ImageBuffer(image_name))
Return ARGB And $ff
End Function
Function write_rgb(x,y,r,g,b,image_name)
argb=(b Or (g Shl 8) Or (r Shl 16) Or ($ff000000))
WritePixel x,y,argb,ImageBuffer(image_name)
End Function