Page 1 of 1

Rectangle drawing command

Posted: Sat Oct 28, 2006 5:59 am
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() 

Posted: Sat Oct 28, 2006 10:09 am
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.

Posted: Sat Oct 28, 2006 11:18 am
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.

Posted: Sat Oct 28, 2006 11:41 am
by DarkDragon
<- will kill himself if the outlined mode works the inverted way.

Posted: Sat Oct 28, 2006 11:55 am
by PB
I wasn't requesting it; I only requested a rectangle command. :)