Problems with LINE

Just starting out? Need help? Post your questions and find answers here.
fjmangas
New User
New User
Posts: 3
Joined: Thu Dec 15, 2022 7:51 pm

Problems with LINE

Post by fjmangas »

I was playing with 2dgraphics, wanted to make a triangle and couldn't make it if I put 0 in y increment. It works fine if I put 1 or -1 (see last lines of code)
I copy the code
Is there a problem with the language or am I doing something wrong?

If I put a 0 I can't see any line (it doesn't close the triangle. Perhaps is something that happens just in my system.

Any comments will be appreciated

Code: Select all

;MessageRequester("BARRA DE TÍTULOS","CUERPO DEL TEXTO QUE SE QUIERE VER",5);SI CAMBIO NUMERO SE CAMBIAN BOTONES
;ColorRequester()
If InitSprite() = 0 
  MessageRequester("ERROR", "NO SE PUEDE INICIALIZAR GRÁFICOS", 0)
  End
EndIf

If InitKeyboard() = 0 
  MessageRequester("ERROR", "NO SE PUEDE INICIALIZAR TECLADO", 0)
  End
EndIf

If InitSound() = 0 
  MessageRequester("ERROR", "NO SE PUEDE INICIALIZAR SONIDO", 0)
  End
EndIf

If InitMouse() = 0
  MessageRequester("ERROR", "NO SE PUEDE INICIALIZAR RATÓN", 0)
  End
EndIf
OpenScreen(800,600,32,"BTÍTULO") 
Repeat
ExamineKeyboard() 

StartDrawing(ScreenOutput()) : 
DrawingMode(1)   
FrontColor(RGB(200,00,00))
Circle(100,100,50,RGB(0,0,125))
Box(100,300,125,75)
RoundBox(300,100,75,50,15,15,RGB(128,128,128))
RoundBox(300,175,75,50,10,10,RGB(200,200,200))
RoundBox(300,250,75,50,5,5,RGB(200,200,200))
RoundBox(300,325,75,50,30,30,RGB(128,128,128))
RoundBox(300,400,75,50,35,35,RGB(128,128,128))
Line(400,150,100,-100,RGB(250,250,50))
Line(600,150,-100,-100,RGB(250,250,50))
Line(600,150,-200,-1,RGB(250,250,50))
;FillArea(500,100,RGB(250,250,250))
Plot(500,125,RGB(250,250,50))
;FillArea(500,125,RGB(250,250,50),RGB(250,250,50))
Line(500,300,100,100,RGB(0,128,128))
Line(500,300,-100,100,RGB(0,128,128))
Line(600,400,-200,-1,RGB(0,128,128))
FillArea(550,350,RGB(0,128,128),RGB(0,128,128))
Line(500,450,25,100,RGB(0,175,175))
Line(500,450,-25,100,RGB(0,175,175))
Line(475,550,50,0,RGB(0,175,175))
;FillArea(500,500,RGB(0,175,175),RGB(0,150,200))
DrawText(10,10,"ESC-Fin") 
StopDrawing()

FlipBuffers() 

Until KeyboardReleased(#PB_Key_Escape)  
infratec
Always Here
Always Here
Posts: 7619
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Problems with LINE

Post by infratec »

Read the help for the Line command.
Especially the point 'Width, Height'

https://www.purebasic.com/documentation ... /line.html
fjmangas
New User
New User
Posts: 3
Joined: Thu Dec 15, 2022 7:51 pm

Re: Problems with LINE

Post by fjmangas »

It seems I'm line blinded. I have looked at the help but I didn't see it
Thanks infratec
User avatar
mk-soft
Always Here
Always Here
Posts: 6248
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Problems with LINE

Post by mk-soft »

Welcome ...

For 2D drawing, you can also use the CanvasGadget for windows. Unless you want to program games. But there are better methods than drawing directly on the screen.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
firace
Addict
Addict
Posts: 946
Joined: Wed Nov 09, 2011 8:58 am

Re: Problems with LINE

Post by firace »

fjmangas wrote: Sat Apr 01, 2023 1:35 pm It seems I'm line blinded. I have looked at the help but I didn't see it
Thanks infratec

Perhaps you will find LineXY() easier to use. Try:

Code: Select all

LineXY(475,550,525,550,RGB(0,175,175))
Post Reply