Rectangle drawing command

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Rectangle drawing command

Post by PB »

I just had need to draw a single-pixel red border around an image, but was
surprised to see that PureBasic had no "rectangle" command to do it. :shock: So
I ended up doing it like this, but perhaps a "rectangle" command could be
put in for a future release? ("Box" is no use here because it's filled in).

Code: Select all

; w and h are image width/height.
StartDrawing(ImageOutput(#MyImage))
  LineXY(0,0,w,0,#Red) ; Top.
  LineXY(w-1,0,w-1,h,#Red) ; Right.
  LineXY(w,h-1,0,h-1,#Red) ; Bottom.
  LineXY(0,h,0,0,#Red) ; Left.
StopDrawing() 
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Hi PB, for now the Box command will do it if you precede it with DrawingMode(#PB_2DDrawing_Outlined), but I agree it would be better for the basic shapes to be able to specify a pen and brush, with #PB_2ddrawing_transparent one of the brush options.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> DrawingMode(#PB_2DDrawing_Outlined)

Ah, I didn't even notice that (never done much graphics before). But I still
think a basic rectangle shape should be included. In fact, I think it may have
been Blitz Basic (or AMOS?) where you do the normal outlined shapes, but if
you wanted them filled it was just a flag added, which I think is a better way.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

<- will kill himself if the outlined mode works the inverted way.
bye,
Daniel
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

I wasn't requesting it; I only requested a rectangle command. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Post Reply