2DDrawing Box

Just starting out? Need help? Post your questions and find answers here.
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 151
Joined: Thu Dec 28, 2023 9:04 pm

2DDrawing Box

Post by rndrei »

How to draw an unnecessary square?
You can draw lines, but I think maybe there is a built -in solution?

Code: Select all

#canvas=1
If Not OpenWindow(0, 0, 0, 1900, 900, "Gadget BOX", #PB_Window_SystemMenu)
   End
EndIf
CanvasGadget(#canvas, 0, 0, 1000, 900)  
If StartDrawing(CanvasOutput(#canvas))
    Box(0,0,100,200,#Black) 
    StopDrawing()
EndIf
Repeat 
   Gadget = EventGadget()
Until WaitWindowEvent() = #PB_Event_CloseWindow
User avatar
jacdelad
Addict
Addict
Posts: 1991
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: 2DDrawing Box

Post by jacdelad »

Code: Select all

DrawingMode(#PB_2DDrawing_Outlined)
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
miso
Enthusiast
Enthusiast
Posts: 409
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: 2DDrawing Box

Post by miso »

Code: Select all

#canvas=1
If Not OpenWindow(0, 0, 0, 1900, 900, "Gadget BOX", #PB_Window_SystemMenu)
   End
EndIf
CanvasGadget(#canvas, 0, 0, 1000, 900)  
If StartDrawing(CanvasOutput(#canvas))
  Box(0,0,100,200,#Black) 
  Box(10,10,80,180,#White)
  StopDrawing()
EndIf

If StartDrawing(CanvasOutput(#canvas))
  DrawingMode(#PB_2DDrawing_Outlined)
  Box(300,300,100,200,#Black) 
  StopDrawing()
EndIf

Repeat 
   Gadget = EventGadget()
Until WaitWindowEvent() = #PB_Event_CloseWindow
threedslider
Enthusiast
Enthusiast
Posts: 377
Joined: Sat Feb 12, 2022 7:15 pm

Re: 2DDrawing Box

Post by threedslider »

Code: Select all

#canvas=1
If Not OpenWindow(0, 0, 0, 1900, 900, "Gadget BOX", #PB_Window_SystemMenu)
   End
EndIf
CanvasGadget(#canvas, 0, 0, 1000, 900)  
If StartDrawing(CanvasOutput(#canvas))
  ;Box(0,0,100,200,#Black) 
  For y=0 To 200
    For x=0 To 100
      If y = 0
        Plot(x+50, y+50, #Black)
      ElseIf y <= 200 And x=0
        Plot(x+50, y+50, #Black)
      ElseIf y<= 200 And x=100
        Plot(x+50, y+50, #Black)
      ElseIf y=200
        Plot(x+50, y+50, #Black)
      EndIf      
    Next
  Next
  
  StopDrawing()
EndIf
Repeat 
   Gadget = EventGadget()
Until WaitWindowEvent() = #PB_Event_CloseWindow
I make the extra position for seeing the box in lines :)
Post Reply