@Basicallypure : thanks for your procedure
.
I have added some lines, to not tint with a white color, which change the sprite in grey level ^^. And I think it's interesting to draw again the originale image to not tint over the last color, but with a new color each time :
Code: Select all
If IsSprite(SpriteId)
StartDrawing(SpriteOutput(Sprite))
; erase first the sprite
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0,0,OutputWidth(),OutputHeight(),RGBA(0,0,0,0))
; draw the original image, you need to know what is the sprite image
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawAlphaImage(ImageID(SpriteImg),0,0)
; then tint the sprite, only if color isn't white.
If color <> RGB(255,255,255)
xMax = OutputWidth() - 1
yMax = OutputHeight() - 1
For y = 0 To yMax
For x = 0 To xMax
c = Point(x, y)
i = (c & $FF) << 1 : c >> 8
i + (c & $FF) << 2 : c >> 8
i + (c & $FF) : c >> 8
Plot(x, y, RGBA(r*i, g*i, b*i, c))
Next x
Next y
EndIf
StopDrawing()
EndIf
I guess for faster transformation, we could use DrawingBuffer()
Edit :
Other ways, faster
!
Code: Select all
If IsSprite(SpriteId)
StartDrawing(SpriteOutput(Sprite))
; erase first the sprite
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0,0,OutputWidth(),OutputHeight(),RGBA(0,0,0,0))
; draw the original image, you need to know what is the sprite image
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawAlphaImage(ImageID(SpriteImg),0,0)
; then tint the sprite, only if color isn't white.
If color <> RGB(255,255,255)
DrawingMode(#PB_2DDrawing_AlphaClip)
; you can change the alpha of the rgba color, to get the effect you want.
Box(0,0,OutputWidth(),OutputHeight(),RGBA(Red(color),Green(color),Blue(color),120))
EndIf
StopDrawing()
EndIf
With a custom filter (you can use a multiply, add, screen, overlay... custom filter for interesting effect
):
The custom filter multiply :
Code: Select all
Procedure bm_multiply(x, y, SourceColor, TargetColor)
ProcedureReturn RGBA((Red(SourceColor)*Red(TargetColor))/255,(Green(SourceColor)*Green(TargetColor))/255,(Blue(SourceColor)*Blue(TargetColor))/255, Alpha(TargetColor)*Alpha(TargetColor)/255)
EndProcedure
Code: Select all
If IsSprite(SpriteId)
StartDrawing(SpriteOutput(Sprite))
; erase first the sprite
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0,0,OutputWidth(),OutputHeight(),RGBA(0,0,0,0))
; draw the original image, you need to know what is the sprite image
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawAlphaImage(ImageID(SpriteImg),0,0)
; then tint the sprite, only if color isn't white.
If color <> RGB(255,255,255)
DrawingMode(#PB_2DDrawing_CustomFilter)
CustomFilterCallback(@bm_multiply())
Box(0,0,OutputWidth(),OutputHeight(),Color)
EndIf
StopDrawing()
EndIf