Canvas colour

Just starting out? Need help? Post your questions and find answers here.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Canvas colour

Post by collectordave »

Hi

I have some code that creates a canvas gadget and then sets the colour of the gadget to the background on which it is drawn.

Code: Select all

    ;Get background colour where gadget will be drawn
    StartDrawing(WindowOutput(ThisWindow))
      MyGadgetArray.MyGadget(CurrentGadget)\BackColour = Point(x, y)
    StopDrawing()
    
    ;Set Colour Of Canvas To Background
    StartDrawing(CanvasOutput(ThisGadget))
      DrawingMode(#PB_2DDrawing_AllChannels)
      Box(0, 0, OutputWidth(), OutputHeight(), MyGadgetArray.MyGadget(CurrentGadget)\BackColour)
    StopDrawing()
This works on windows but not on the MAC

Anyone have any ideas?

Regards

cd
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Canvas colour

Post by RASHAD »

Hi collectordave
I am a Windows user only
But I suggest

Code: Select all

;Get background colour where gadget will be drawn
    
    HideGadget(ThisGadget,1)
    StartDrawing(WindowOutput(ThisWindow))
      MyGadgetArray.MyGadget(CurrentGadget)\BackColour = Point(x, y)
      Delay(10)
    StopDrawing()
    HideGadget(ThisGadget,0)
   
    ;Set Colour Of Canvas To Background
    StartDrawing(CanvasOutput(ThisGadget))
      DrawingMode(#PB_2DDrawing_AllChannels)
      Box(0, 0, OutputWidth(), OutputHeight(), MyGadgetArray.MyGadget(CurrentGadget)\BackColour)
    StopDrawing()
Egypt my love
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Canvas colour

Post by Keya »

collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Canvas colour

Post by collectordave »

Thanks exactly what i was after.

Also found that using DrawingMode(#PB_2DDrawing_AllChannels) before drawing the box stops the back colour from being drawn as well.

Removed that line wherever I was using it and it all works.

Thanks again

cd
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Post Reply