It is currently Sat Nov 28, 2020 6:23 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 39 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: LineXY
PostPosted: Sun Sep 13, 2020 5:03 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 337
Location: Pandora
Thanks Wilbert,
i don't use it, because i primarily didn't see any advantage over point and plot.
With assembler this is something different again !

_________________
地球上の平和


Top
 Profile  
Reply with quote  
 Post subject: Re: LineXY
PostPosted: Sun Sep 13, 2020 6:16 pm 
Offline
User
User

Joined: Fri Sep 11, 2020 1:53 pm
Posts: 25
@mk-soft For now, you are way over my head, but maybe when I know PB better.

I did a test routine I'm for a start are satisfied with:

Code:
lenght.w = 1600                                           ; window size
height.w = 800
scale.w = 200
xpos.w = 500                                              ; center for unit circle
ypos.w = 500
x.f = 0                                                   ; periferi coordinates for unit circle
y.f = 0
t.f = 0                                                   ; start circle 3 o clock

If OpenWindow(0, 0, 0, lenght, height, "2D-test", #PB_Window_SystemMenu | #PB_Window_Normal)
    If CreateImage(0, lenght, height) And StartDrawing(ImageOutput(0))
      Box(0, 0, lenght, height, RGB(255, 255, 255))
                     
      Repeat
       
        x = Cos(t) * scale       
        y = Sin(t) * scale
       
        y *-1                                             ; move normal anti clockwise for unit circle
       
        x + xpos
        y + ypos
       
        LineXY(500, 500, x, y, $FF0000)
        ;Plot(x, y, RGB (0, 0, 255))
       
        t + 0.0314                                        ; jump 1/100 PI RADIAN
       
        ;Debug Str(Int(xpos+x)) + "," + Str(Int(ypos+y))
       
      Until t >= #PI                                      ; half unit circle = 1 PI RADIAN

      StopDrawing()
      ImageGadget(0, 0, 0, 200, 200, ImageID(0))
    EndIf
   
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
  EndIf


Top
 Profile  
Reply with quote  
 Post subject: Re: LineXY
PostPosted: Mon Sep 14, 2020 8:48 am 
Offline
User
User

Joined: Fri Sep 11, 2020 1:53 pm
Posts: 25
The line:

LineXY(500, 500, x, y, $FF0000)

should of course have been:

LineXY(xpos, ypos, x, y, $FF0000)


Top
 Profile  
Reply with quote  
 Post subject: Re: LineXY
PostPosted: Mon Sep 14, 2020 10:05 am 
Offline
Enthusiast
Enthusiast

Joined: Tue Jan 05, 2010 10:35 am
Posts: 109
hello
Little description

Code:
x.l = 100
y.l = 100
x1.l = 400
y1.l = 400
If OpenWindow(0, 0, 0, 600, 600, "Description Function Drawing line", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0,600, 600)
 
  StartDrawing(CanvasOutput(0))
 
  DrawingMode(#PB_2DDrawing_Outlined)
 
  Box(x, y, x1, y1,#Black)
 
  Line(x, y, x1, y1,#Red)
 
  ;  Analysis Function Drawing Line in PureBasic
  ;  angle projection line = atn( x1 / y1 ) = 45 deg
  ;  long  projection line = square( x1 ^ 2 + y1 ^ 2 ) = 565.685425
  ;  example diameter hypothenus square to 45 degree
 
  Circle(x1 - 100, y1 - 100, 565 / 2, #Blue)
 
  StopDrawing()
 
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf


best regard


Top
 Profile  
Reply with quote  
 Post subject: Re: LineXY
PostPosted: Mon Sep 14, 2020 11:10 am 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 2730
Location: Germany
Example with Macros ...
At time need alway color parameter.
Code:
;-TOP

DeclareModule Flip2d
  Global _OffsetY_.i
 
  Macro _PB_(_Function_)
    _Function_
  EndMacro
 
  Macro SetOffset(_Value_)
    _OffsetY_ = _Value_
  EndMacro
 
  Macro Line(x, y, Width, Height, Color)
    _PB_(Line)(x, _OffsetY_ - (y), Width, (Height) * -1, Color)
  EndMacro
 
  Macro Box(x, y, Width, Height, Color)
    _PB_(Box)(x, _OffsetY_ - (y), Width, (Height) * -1, Color)
  EndMacro
 
  Macro Circle(x, y, Radius, Color)
    _PB_(Cirle)(x, _OffsetY_ - (y), Radius, Color)
  EndMacro
 
EndDeclareModule

Module Flip2d
 
EndModule


If OpenWindow(0, 0, 0, 200, 200, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  If CreateImage(0, 200, 200) And StartDrawing(ImageOutput(0))
   
    Box(0, 0, 200, 200, RGB(255, 255, 255))
    Box(160, 20, 20, 20, RGB(255, 0, 0))
   
    UseModule Flip2d
    SetOffset(200)
   
    Box(160, 20, 20, 20, RGB(0, 255, 0))
   
    For Width = 1 To 180 Step 5
      Line(10, 10, Width, 180, RGB(Random(255), Random(255), Random(255)))
    Next Width
    StopDrawing()
    ImageGadget(0, 0, 0, 200, 200, ImageID(0))
  EndIf
 
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: LineXY
PostPosted: Tue Sep 15, 2020 10:28 am 
Offline
User
User

Joined: Fri Sep 11, 2020 1:53 pm
Posts: 25
I'm currently writing a program that needs a lot of collision detection and scrolling.

I converted some of my code from BBC BASIC to Pure Basic with ease, but the upside-down for y-values adds another layer of difficulties that makes it extra hard and is a hurdle for me.

I really, really like PB but for now I have to be productive again because of a deadline.

Cheers. :)


Top
 Profile  
Reply with quote  
 Post subject: Re: LineXY
PostPosted: Wed Sep 16, 2020 8:24 am 
Offline
User
User

Joined: Fri Sep 11, 2020 1:53 pm
Posts: 25
Little John wrote:
Ivan wrote:
@Little John

"(this is the classic behaviour of the BASIC programming language)." - not the BBC Basic I was used to in the eighties. :)

OK. But it works that way in many classic BASIC flavours, IIRC e.g. in GW-BASIC, QBASIC, QuickBASIC, Turbo BASIC, PowerBASIC, ...

Ivan wrote:
That very little I know about a coordinate system and math: Incrementing y-values goes up - not down.

This is true for the "normal" Cartesian coordinate system that most people learn at school. Hoewever, mathematicians also work with various other coordinate systems, and everyone is free to define her/his own coordinate system. The creators of many classic BASIC flavours took the freedom to define it the way that incrementing y-values go down from the top.


("normal" Cartesian coordinate system that most people learn at school. Hoewever, mathematicians also work with various...)

With my little knowledge in matematics and geometry I assumed that most programmers are not matemathecians allthough we use matematics to some extend and could use the knowledge we already have.


Top
 Profile  
Reply with quote  
 Post subject: Re: LineXY
PostPosted: Wed Sep 16, 2020 9:59 am 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3965
Location: Berlin, Germany
Ivan wrote:
Little John wrote:
Ivan wrote:
@Little John

"(this is the classic behaviour of the BASIC programming language)." - not the BBC Basic I was used to in the eighties. :)

OK. But it works that way in many classic BASIC flavours, IIRC e.g. in GW-BASIC, QBASIC, QuickBASIC, Turbo BASIC, PowerBASIC, ...

Ivan wrote:
That very little I know about a coordinate system and math: Incrementing y-values goes up - not down.

This is true for the "normal" Cartesian coordinate system that most people learn at school. Hoewever, mathematicians also work with various other coordinate systems, and everyone is free to define her/his own coordinate system. The creators of many classic BASIC flavours took the freedom to define it the way that incrementing y-values go down from the top.


("normal" Cartesian coordinate system that most people learn at school. Hoewever, mathematicians also work with various...)

With my little knowledge in matematics and geometry I assumed that most programmers are not matemathecians allthough we use matematics to some extend and could use the knowledge we already have.

  1. You don't have to be a mathematician in order to be able to use PureBasic's LineXY() command properly (and I didn't write that).
  2. When you start using a new programming language, you better should be prepared for learning new stuff.
  3. Usage of PureBasic's LineXY() command is documented properly, and you've got a lot of additional information in this thread.

So what is the problem now :?:

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: LineXY
PostPosted: Wed Sep 16, 2020 10:09 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 337
Location: Pandora
Little John is right !

It is a strange large thread.
Making simple things mostly complicated. :wink:

You have to do it like it says in the manual :!:

_________________
地球上の平和


Top
 Profile  
Reply with quote  
 Post subject: Re: LineXY
PostPosted: Wed Sep 16, 2020 10:15 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Jun 24, 2006 3:29 am
Posts: 263
Location: Edinburgh, Scotland.
Does BBC BASIC invert the Y coords? Didn't know that... interesting...

_________________
Proud supporter of PB! * Musician * C64/6502 Freak


Top
 Profile  
Reply with quote  
 Post subject: Re: LineXY
PostPosted: Wed Sep 16, 2020 12:12 pm 
Offline
User
User

Joined: Fri Sep 11, 2020 1:53 pm
Posts: 25
Little John wrote:
Ivan wrote:
Little John wrote:
Ivan wrote:
@Little John

"(this is the classic behaviour of the BASIC programming language)." - not the BBC Basic I was used to in the eighties. :)

OK. But it works that way in many classic BASIC flavours, IIRC e.g. in GW-BASIC, QBASIC, QuickBASIC, Turbo BASIC, PowerBASIC, ...

Ivan wrote:
That very little I know about a coordinate system and math: Incrementing y-values goes up - not down.

This is true for the "normal" Cartesian coordinate system that most people learn at school. Hoewever, mathematicians also work with various other coordinate systems, and everyone is free to define her/his own coordinate system. The creators of many classic BASIC flavours took the freedom to define it the way that incrementing y-values go down from the top.


("normal" Cartesian coordinate system that most people learn at school. Hoewever, mathematicians also work with various...)

With my little knowledge in matematics and geometry I assumed that most programmers are not matemathecians allthough we use matematics to some extend and could use the knowledge we already have.

  1. You don't have to be a mathematician in order to be able to use PureBasic's LineXY() command properly (and I didn't write that).
  2. When you start using a new programming language, you better should be prepared for learning new stuff.
  3. Usage of PureBasic's LineXY() command is documented properly, and you've got a lot of additional information in this thread.

So what is the problem now :?:


Of course you have to learn new stuff, if you try another languages - what else.

I was apparently not succesfull in explaining that in a x,y coordinat system I know of will y increment, when you go up - that it.

No problem, if you ask me.


Top
 Profile  
Reply with quote  
 Post subject: Re: LineXY
PostPosted: Wed Sep 16, 2020 12:20 pm 
Offline
User
User

Joined: Fri Sep 11, 2020 1:53 pm
Posts: 25
oreopa wrote:
Does BBC BASIC invert the Y coords? Didn't know that... interesting...


BBC BASIC does what I have learned about coordinate systems.

For me it's logically when y = 0 then you are on the floor and increasing y-values goes upwards.

And that view goes fine with the origin at 0,0 and move in a quadrant or in an octant 0,0,0


Top
 Profile  
Reply with quote  
 Post subject: Re: LineXY
PostPosted: Wed Sep 16, 2020 12:25 pm 
Offline
User
User

Joined: Fri Sep 11, 2020 1:53 pm
Posts: 25
Saki wrote:
Little John is right !

It is a strange large thread.
Making simple things mostly complicated. :wink:

You have to do it like it says in the manual :!:


Agreed.

If I won't follow the manual I'll have to invert y myself.

I thought I had explained that. :)


Top
 Profile  
Reply with quote  
 Post subject: Re: LineXY
PostPosted: Wed Sep 16, 2020 1:08 pm 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3965
Location: Berlin, Germany
Ivan wrote:
Of course you have to learn new stuff, if you try another languages - what else.
Well, you previously wrote
Quote:
I assumed that [.. we ..] could use the knowledge we already have.
Hence my respective reply.

Ivan wrote:
No problem, if you ask me.

I still do not understand why in this message you quoted text from me, and what the purpose of that message was ...
However, when there are no problems, that's fine. :-)

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: LineXY
PostPosted: Thu Sep 17, 2020 2:51 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Jun 24, 2006 3:29 am
Posts: 263
Location: Edinburgh, Scotland.
Ivan wrote:
oreopa wrote:
Does BBC BASIC invert the Y coords? Didn't know that... interesting...


BBC BASIC does what I have learned about coordinate systems.

For me it's logically when y = 0 then you are on the floor and increasing y-values goes upwards.

And that view goes fine with the origin at 0,0 and move in a quadrant or in an octant 0,0,0


It's not an issue for me for you to have your own preference :) I have no comment on that at all...

I should have been clearer. I was simply interested in the way the BBC is handling this internally... it means that bitmap memory is stored left-right/bottom-up? Or that it's just simply a translation in basic interpreter that y=0 is the bottom? Curious... I will look into it...

_________________
Proud supporter of PB! * Musician * C64/6502 Freak


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 39 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye