FillArea() ; Useless function ?

Everything else that doesn't fall into one of the other PB categories.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

FillArea() ; Useless function ?

Post by Psychophanta »

FillArea() function is useless because it takes more than 20 millisecs when filling less than 1/5 of screen area, at least in my pc (Ati 9600) :x
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3943
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Post by wilbert »

I don't know what you are trying to accomplish but if you use windows and want to create a custom filled shape, use paths. It's a lot faster.

If you wish you can use my lib ( http://www.geboortegrond.nl/pb/wb_Lib.zip ) but using api calls will also work fine.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: FillArea() ; Useless function ?

Post by PB »

> FillArea() function is useless because it takes more than 20 millisecs when
> filling less than 1/5 of screen area, at least in my pc (Ati 9600)

Why don't you post some test code here so we can test it ourselves? Then
we can decide if it's really a bug, or, as you said, just your PC. Thanks!
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Code: Select all

bitplanes.b=32:RX.w=1024:RY.w=768
If InitMouse()=0 Or InitSprite()=0 Or InitSprite3D()=0 Or InitKeyboard()=0
  MessageRequester("Error","Can't access DirectX",0):End
EndIf
OpenScreen(RX.w,RY.w,bitplanes.b,"Masses")

Procedure Box1()
  DrawingMode(4)
  Box(111,111,333,333,$aaaaaa)
  DrawingMode(0)
  FillArea(222,222,$aaaaaa,$111111)
EndProcedure

Repeat
  ExamineKeyboard():ExamineMouse()
  StartDrawing(ScreenOutput())
  Box1()
  StopDrawing()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
Test speed yourself.

It's not a bug, but a notable deficiency.
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Post by sec »

...and this function (FillArea() is not avail for PB Linux Version.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> Test speed yourself

Yep, I agree, it does seem very slow (>150 ms on my old PC). :(
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Of course fill area is slow for filling a square, that's not what its for.

Fill area is for filling arbitary shapes, not regular ones. When you have an arbitary shape it is invaluable.

Try doing this rather sickening effect without it

Code: Select all

bitplanes.b=32:RX.w=1024:RY.w=768
If InitMouse()=0 Or InitSprite()=0 Or InitSprite3D()=0 Or InitKeyboard()=0
  MessageRequester("Error","Can't access DirectX",0):End
EndIf
OpenScreen(RX.w,RY.w,bitplanes.b,"Masses")

Procedure Box1()
  DrawingMode(4)
  For i = 1 To 5
    Circle(Random(300) + 100, Random(300) + 100, Random(100), $AAAAAA)
  Next i
  Box(111,111,333,333,$AAAAAA)
  DrawingMode(0)
  FillArea(120,120,$AAAAAA,$FFFFFF)
  FillArea(120,300,$AAAAAA,$FF0000)
  FillArea(300,120,$AAAAAA,$00FF00)
  FillArea(222,222,$AAAAAA,$0000FF)
EndProcedure

Repeat
  ExamineKeyboard():ExamineMouse()
  StartDrawing(ScreenOutput())
  Box1()
  StopDrawing()
  FlipBuffers()
  ClearScreen(0,0,0)
Until KeyboardPushed(#PB_Key_Escape)
A more practical example would be if you had irregular colors around the border of an image and you wanted to set it all to a sinlge transparantly masked color.

It isn't a good idea to use it in your main drawing loop. You'd probably want to set up any images in buffers first.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

-First:
Fill area is for filling arbitary shapes, not regular ones
mathematically "regular shapes" are inside the joint of "arbitrary shapes" :wink:

-Second:
Your example demonstrates very good the truth of this post-thread. Comment the 4 lines with FillArea(), then uncomment it and compare speed.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

mathematically "regular shapes" are inside the joint of "arbitrary shapes"
Yes, regular shapes is a set of all arbitary shapes where a fast fill method exists. You can do it the slow way if you want, but its stupid.

What does suprise me is that there doesn't appear to be a method for filled circles.

Having to use FillArea for circles, that is wrong.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Filled circles?

Use DrawingMode(0)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

It just uses the windows API, I don't know why it's reported under bug reports..
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Post by sec »

Fred wrote: I don't know why it's reported under bug reports..
...and this function (FillArea() is not avail for PB Linux Version.
maybe?
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Good point, I overlooked this reply :)
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Fred wrote
I don't know why it's reported under bug reports..
Sorry, i didn't put here because Linux question, but as i wrote below it is not a real bug, but a not useful function in many cases, a notable deficient function. It's impossible to work with it in real time graphics.
Perhaps i should put it in General Discussion or so :?
Anyway the sec appointment came well :wink:

Simply, if it is too difficult to implement a fast funtion to fill a 2D area, I would eliminate this function from windows version too.
Or at least print a notice in the explanation of this function in PBhelp, saying that it is too slow for use in realtime rendering.

Besides, this funny function eats 100% CPU. Coz it can't eat more. :o
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply