why DrawVectorImage() color(here is #red) is (blend,mixed,va

Just starting out? Need help? Post your questions and find answers here.
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

why DrawVectorImage() color(here is #red) is (blend,mixed,va

Post by gurj »

why DrawVectorImage() color(here is #red) is (blend,mixed,varied)?

Code: Select all

;why DrawVectorImage() color(here is #red) is (blend,mixed,varied)?
If OpenWindow(0, 0, 0, 900, 100, "DrawAddBorder", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 
 LoadFont(0, "Tahoma", 0,#PB_Font_Bold)
 CreateImage(0, 900, 100,32,$ffffffff)
 If StartVectorDrawing(ImageVectorOutput(0))
  
  VectorFont(FontID(0), 60)
  ;***********#red:
  VectorSourceColor(RGBA(255, 0, 0, 255))
  Text$ = "The quick 框是左键按下 jumped over the lazy doc"
  
   MovePathCursor(0,0)
   DrawVectorText(Text$)
  For x= 1 To 3
   MovePathCursor(x,0)
   DrawVectorImage(ImageID(0), 255)
  Next
     MovePathCursor(4,0)
   DrawVectorText(Text$)

  For y= 1 To 3
   MovePathCursor(0,y)
   DrawVectorImage(ImageID(0), 255)
  Next
       MovePathCursor(0,1)
   DrawVectorImage(ImageID(0), 255)

;   VectorSourceColor(RGBA(0, 0, 0, 255))
;   MovePathCursor(3,3)
;   DrawVectorText(Text$)
   StopVectorDrawing()
  ImageGadget(2, 0, 0, 900, 100,ImageID(0))
 EndIf
 
 Repeat
  Event = WaitWindowEvent()
 Until Event = #PB_Event_CloseWindow
EndIf
my pb for chinese:
http://ataorj.ys168.com
infratec
Always Here
Always Here
Posts: 6874
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: why DrawVectorImage() color(here is #red) is (blend,mixe

Post by infratec »

Maybe it's a bug:

Works:

Code: Select all

CreateImage(0, 900, 100, 32, RGBA(255,255,255,254))
Fully transparent:

Code: Select all

CreateImage(0, 900, 100, 32, RGBA(255,255,255,255))
-1 as color results in a transparent image instead of a white one.

Code: Select all

If OpenWindow(0, 0, 0, 900, 100, "DrawAddBorder", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  CreateImage(0, 450, 100, 32, RGBA(255,255,255,255))
  ImageGadget(0, 0, 0, 0, 0, ImageID(0))
  
  CreateImage(1, 450, 100, 32, RGBA(255,255,255,254))
  ImageGadget(1, 450, 0, 0, 0, ImageID(1))
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
Bernd
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: why DrawVectorImage() color(here is #red) is (blend,mixe

Post by gurj »

if first has code:
AddPathBox(0,0, 900, 100)
VectorSourceColor($ffffffff)
FillPath()

will not transparent, when use DrawVectorImage()
my pb for chinese:
http://ataorj.ys168.com
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: why DrawVectorImage() color(here is #red) is (blend,mixe

Post by netmaestro »

Identifying your OS is important for vector questions as vastly different libraries are used.
BERESHEIT
User avatar
Demivec
Addict
Addict
Posts: 4091
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: why DrawVectorImage() color(here is #red) is (blend,mixe

Post by Demivec »

gurj wrote:why DrawVectorImage() color(here is #red) is (blend,mixed,varied)?
It is because you repeatedly draw an alphablended color onto a background. The mixture is the result of the 'edges' that are being blended with the previous background.

In your sample code you draw the images with alpha colors at least 9 times.
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: why DrawVectorImage() color(here is #red) is (blend,mixe

Post by gurj »

the result of the 'edges'
-----
why?
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: why DrawVectorImage() color(here is #red) is (blend,mixe

Post by gurj »

by pb's chm to know:
now, only can use CreateImage(..., ..., ...,32,#PB_Image_Transparent) To Transparent

Debug #PB_Image_Transparent;-1
Debug RGBA(255, 255, 255, 255);-1
the RGB(255, 255, 255) is Transparent color in CreateImage() here

so
If first has code:

AddPathBox(0,0, 900, 100)
VectorSourceColor(RGBA(255, 255, 255, 255));draw true white
FillPath()

will Not transparent, when use DrawVectorImage()
because
the RGB(255, 255, 255) is white color in draw here, As draw other color.
it also can covering other color
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: why DrawVectorImage() color(here is #red) is (blend,mixe

Post by gurj »

Draw Remarks for Topic
see line12 and line17

Code: Select all

;Draw Remarks for Topic
;see line12 and line17
If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 CanvasGadget(0, 0, 0, 400, 200)
 LoadFont(0, "Times New Roman", 20, #PB_Font_Bold)
 
 If StartVectorDrawing(CanvasVectorOutput(0))
  VectorFont(FontID(0), 150)
  VectorSourceColor(RGBA(250, 0, 0, 255))
  MovePathCursor(1, 1)
  AddPathBox(0,0,400,200)
FillPath();1 try use ';'
  
  VectorSourceColor(RGBA(0, 0, 0, 255))
  MovePathCursor(1, 1)
  AddPathText("Text")
FillPath();2 try use ';'
  MovePathCursor(50, 25)
  AddPathText("Text")
FillPath()
  
  StopVectorDrawing()
 EndIf
 
 Repeat
  Event = WaitWindowEvent()
 Until Event = #PB_Event_CloseWindow
EndIf

my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: why DrawVectorImage() color(here is #red) is (blend,mixe

Post by gurj »

pb should add SetTransparentColor(Color=#White) For draw ,also see this:
Procedure WinTransparentColor(Win,TransparentColor=#White);user may change Default Color
SetWindowColor(Win,TransparentColor)
SetWindowLongPtr_(WindowID(Win), #GWL_EXSTYLE,$00080000)
SetLayeredWindowAttributes_(WindowID(Win),TransparentColor, 0, #LWA_COLORKEY);#LWA_COLORKEY=1
EndProcedure
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: why DrawVectorImage() color(here is #red) is (blend,mixe

Post by gurj »

add TransparentLevel

Code: Select all

Procedure WinTransparent(Win,TransparentColor=#Green,TransparentLevel=127)
 ;if TransparentLevel=255,=WinTransparentColor()
 SetWindowColor(Win,TransparentColor)
 Win=WindowID(Win)
 SetWindowLongPtr_(Win, #GWL_EXSTYLE,$00080000)
 SetLayeredWindowAttributes_(Win, TransparentColor,TransparentLevel, 3);3=#LWA_COLORKEY|#LWA_ALPHA
EndProcedure
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: why DrawVectorImage() color(here is #red) is (blend,mixe

Post by gurj »

for box to transparent, this is right:
AddPathBox(0,0, 900, 100)
VectorSourceColor(0);$00ffffff)
FillPath()
my pb for chinese:
http://ataorj.ys168.com
Post Reply