ClearCanvasGadget(gadget, colour)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
marcoagpinto
Addict
Addict
Posts: 1045
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

ClearCanvasGadget(gadget, colour)

Post by marcoagpinto »

@Fred

Someday will you have the chance to add the command:
ClearCanvasGadget(gadget, colour)
?

Thanks!
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: ClearCanvasGadget(gadget, colour)

Post by Bisonte »

What is wrong with

Code: Select all

Box(0, 0, OutputWidth(), OutputHeight(), Color)
???
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
BarryG
Addict
Addict
Posts: 4128
Joined: Thu Apr 18, 2019 8:17 am

Re: ClearCanvasGadget(gadget, colour)

Post by BarryG »

He tried Box() and said it's too slow: viewtopic.php?f=13&t=72106
User_Russian
Addict
Addict
Posts: 1519
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: ClearCanvasGadget(gadget, colour)

Post by User_Russian »

Code: Select all

  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)
      
      MovePathCursor(50, 25)
      AddPathText("Text")
      
      VectorSourceColor(RGBA(255, 0, 0, 255))
      DashPath(3, 6)
    
      StopVectorDrawing()
    EndIf
    
    SetGadgetColor(0, #PB_Gadget_BackColor, RGB(0, 250, 0)) ; <-- Clear CanvasGadget.
    
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
  EndIf
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: ClearCanvasGadget(gadget, colour)

Post by Josh »

I have posted something to this in the main thread:
viewtopic.php?p=542107#p542107
sorry for my bad english
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Re: ClearCanvasGadget(gadget, colour)

Post by kenmo »

Josh, your snippet looks like a bug to report... EXCEPT that SetGadgetColor() doesn't officially support the CanvasGadget so it's not supposed to work.

That's what this feature request should be (no offense). Not a new, very specific command, but just add CanvasGadget support to either SetGadgetColor() or add a new #PB_Canvas_Color attribute to SetGadgetAttribute().


In the meantime, I just use the Box() method. For me it's fast enough for canvas GUIs even back to Windows XP. If you need high canvas framerates, you should use an accelerated Screen.
Post Reply