Page 1 of 1

TransparentSprite with color : 0

Posted: Mon Nov 10, 2025 8:49 pm
by SPH
Hi,

I'm banging my head against the wall because the transparency system has become so complicated.
Could you please correct this code so that transparency is applied to the black color (RGB(0,0,0))?
This was the usual color when we coded in PB6.12 or earlier.

Many thanks

Code: Select all

InitSprite()

OpenScreen(1920,1080,32,"Sprite")

 ;Création du sprite
CreateSprite(1,1920,1080)
StartDrawing(SpriteOutput(1))
r=Random(55)
v=Random(55)
b=Random(55)
r2=Random(1)*2-1
v2=Random(1)*4-2
b2=Random(1)*6-3

For i=0 To 1079
  LineXY(0,i,1920,i,RGB(r,v,b))
  r+r2
  If r>100 Or r<0
    r2*-1
    r+r2
  EndIf
  v+v2
  If v>100 Or v<0
    v2*-1
    v+v2
  EndIf
  b+b2
  If b>100 Or b<0
    b2*-1
    b+b2
  EndIf
Next
  StopDrawing()
  
  
  CreateSprite(0,201,201,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(0))
DrawingMode(#PB_2DDrawing_Gradient)      
BackColor(RGB(255,255,255))
FrontColor(RGB(255,255,0))     
CircularGradient(100, 100, 100)     
Circle(100, 100, 100)
CircularGradient(350, 100, 75)
Circle(300, 100, 100)
StopDrawing()


 ;Affichage du sprite
  
  DisplaySprite(1,0,0)
  DisplayTransparentSprite(0, 210, 160)

FlipBuffers()
Delay(3000)


Re: TransparentSprite with color : 0

Posted: Mon Nov 10, 2025 9:10 pm
by idle

Code: Select all

InitSprite()

OpenScreen(1920,1080,32,"Sprite")

 ;Création du sprite
CreateSprite(1,1920,1080)
StartDrawing(SpriteOutput(1))
r=Random(55)
v=Random(55)
b=Random(55)
r2=Random(1)*2-1
v2=Random(1)*4-2
b2=Random(1)*6-3

For i=0 To 1079
  LineXY(0,i,1920,i,RGB(r,v,b))
  r+r2
  If r>100 Or r<0
    r2*-1
    r+r2
  EndIf
  v+v2
  If v>100 Or v<0
    v2*-1
    v+v2
  EndIf
  b+b2
  If b>100 Or b<0
    b2*-1
    b+b2
  EndIf
Next
  StopDrawing()
  
  
CreateSprite(0,201,201, #PB_Sprite_AlphaBlending | #PB_Sprite_Transparent )
StartDrawing(SpriteOutput(0))
DrawingMode(#PB_2DDrawing_Gradient | #PB_2DDrawing_AlphaBlend )      
BackColor(RGBA(255,255,255,255))
FrontColor(RGBA(255,255,0,255))     
CircularGradient(100, 100, 100)     
Circle(100, 100, 100)
CircularGradient(350, 100, 75)
Circle(300, 100, 100)
StopDrawing()


 ;Affichage du sprite
  
  DisplaySprite(1,0,0)
  DisplayTransparentSprite(0, 210, 160)

FlipBuffers()
Delay(3000)



Re: TransparentSprite with color : 0

Posted: Mon Nov 10, 2025 9:13 pm
by pf shadoko
Yeah, that's new.
Now you have to specify “#PB_Sprite_Transparent”
and the default drawing mode set the alpha to 0.
I don't know why Fred did that.
:shock:

I think you can file a bug report.
That will at least clarify the issue.

Code: Select all

InitSprite()

Debug OpenScreen(1600,900,32,"Sprite")

 ;Création du sprite
CreateSprite(1,1600,900)
StartDrawing(SpriteOutput(1))
r=Random(55)
v=Random(55)
b=Random(55)
r2=Random(1)*2-1
v2=Random(1)*4-2
b2=Random(1)*6-3

For i=0 To 1079
  LineXY(0,i,1920,i,RGB(r,v,b))
  r+r2
  If r>100 Or r<0
    r2*-1
    r+r2
  EndIf
  v+v2
  If v>100 Or v<0
    v2*-1
    v+v2
  EndIf
  b+b2
  If b>100 Or b<0
    b2*-1
    b+b2
  EndIf
Next
  StopDrawing()
  
  
CreateSprite(0,201,201,#PB_Sprite_AlphaBlending|#PB_Sprite_Transparent)
StartDrawing(SpriteOutput(0))
DrawingMode(#PB_2DDrawing_AllChannels|#PB_2DDrawing_Gradient)      
BackColor(RGBA(255,255,255,255))
FrontColor(RGBA(255,255,0,255))     
CircularGradient(100, 100, 100)     
Circle(100, 100, 100)
CircularGradient(350, 100, 75)
Circle(300, 100, 100)
StopDrawing()


 ;Affichage du sprite
  
  DisplaySprite(1,0,0)
  DisplayTransparentSprite(0, 210, 160)

FlipBuffers()
Delay(3000)


Re: TransparentSprite with color : 0

Posted: Mon Nov 10, 2025 9:46 pm
by SPH
"Not clear" doesn't mean "bug."
But there are several parameters to manage, and it's not intuitive...

Thanks, guys, for your reply.

Re: TransparentSprite with color : 0

Posted: Mon Nov 10, 2025 9:54 pm
by SPH
The problem is slightly different, but this time it's a color issue. Specifically, I'm drawing lines in several different colors:

Code: Select all

  LineXY(Random(1920),400+Random(1080),Random(1920),400+Random(1080),RGB(Random(255),Random(255),Random(255)))  
Yet, they come out in white! That too is very counter-intuitive and incredibly frustrating...

Code: Select all

InitSprite()

OpenScreen(1920,1080,32,"Sprite")

;Création du sprite
CreateSprite(1,1920,1080)
StartDrawing(SpriteOutput(1))
r=Random(55)
v=Random(55)
b=Random(55)
r2=Random(1)*2-1
v2=Random(1)*4-2
b2=Random(1)*6-3

For i=0 To 1079
  LineXY(0,i,1920,i,RGB(r,v,b))
  r+r2
  If r>100 Or r<0
    r2*-1
    r+r2
  EndIf
  v+v2
  If v>100 Or v<0
    v2*-1
    v+v2
  EndIf
  b+b2
  If b>100 Or b<0
    b2*-1
    b+b2
  EndIf
Next
StopDrawing()

;;;;;;;;;;;
CreateSprite(0,1920,1080,#PB_Sprite_AlphaBlending | #PB_Sprite_Transparent )
StartDrawing(SpriteOutput(0))
DrawingMode(#PB_2DDrawing_Gradient | #PB_2DDrawing_AlphaBlend )      
For i=1 To 100
  LineXY(Random(1920),400+Random(1080),Random(1920),400+Random(1080),RGB(Random(255),Random(255),Random(255)))  
Next
StopDrawing()

;;;;;;;;;;;



;Affichage du sprite

DisplaySprite(1,0,0)
DisplayTransparentSprite(0, 0, 0)

FlipBuffers()
Delay(2400)

Re: TransparentSprite with color : 0

Posted: Mon Nov 10, 2025 10:10 pm
by idle
that's the gradient flag causing the issue

Code: Select all

;;;;;;;;;;;
CreateSprite(0,1920,1080,#PB_Sprite_AlphaBlending | #PB_Sprite_Transparent )
StartDrawing(SpriteOutput(0))
DrawingMode( #PB_2DDrawing_AlphaBlend )      
For i=1 To 100
  LineXY(Random(1920),400+Random(1080),Random(1920),400+Random(1080),RGBA(Random(255),Random(255),Random(255),255))  
Next
StopDrawing()

;;;;;;;;;;;

Re: TransparentSprite with color : 0

Posted: Wed Nov 12, 2025 7:13 pm
by SPH
Thx. All codes is OK now