Announcement

Collapse
No announcement yet.

Changing zero,zero point...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Changing zero,zero point...

    Hi, PB people...

    In Power Basic the 0,0 point (where the x axis and y axis meet, is the upper left corner of the screen... Moving to the right or moving down are when the input numbers increase...
    My question, to the PB experts is how to make the 0,0 point the bottom left of the screen, and also how to make the numbers get more positive in the "Y" direction, that is the upward direction...
    I can't find anything on changing the origin in the help files, but that doesn't mean it isn't there under a different name... There are only 100,000 help subjects... If we each take 1,000, etc...

    Thanx...

    Izzy

  • #2
    It is Windows, not PB.

    In other question you used a GRAPHIC WINDOW. See Help for GRAPHIC SCALE. Making y1! larger than y2! should do what you want for a graphic window.

    Cheers,
    Dale

    Comment


    • #3
      For a graphic window or graphic object:

      GRAPHIC SCALE (0, ymax) - (xmax,0)

      Comment


      • #4
        Originally posted by Izzy Zeitz View Post
        I can't find anything on changing the origin in the help files, but that doesn't mean it isn't there under a different name... There are only 100,000 help subjects... If we each take 1,000, etc...
        A logical approach to problem solving will help.
        Help is very well organised. To answer most of your questions, you can just go to Help , Contents -> Keyword Reference -> Command Summary
        Then select the type of commands you are interested in.

        Click image for larger version

Name:	COmmandSummary.png
Views:	77
Size:	4.4 KB
ID:	796254

        There's only 138 entries under -> Graphic Commands. Each with a description. Not too hard to find the relevant entry

        Graphic Commands
        The followings can be used to display graphics:
        CONTROL ADD IMAGE Add a (non-resizing) image control to a dialog.
        CONTROL ADD IMAGEX Add a stretched image control to a dialog.
        CONTROL ADD IMGBUTTON Add an image button to a dialog.
        CONTROL ADD IMGBUTTONX Add a stretched image button to a dialog.
        CONTROL ADD GRAPHIC Add a graphic control to a dialog.
        BGR Convert an RGB color value to BGR format.
        GRAPHIC(CANVAS.X) Retrieves the writable width of the attached graphic target.
        GRAPHIC(CANVAS.Y) Retrieves the writable height of the attached graphic target.
        GRAPHIC(Cell.Size.X) Retrieves the character cell width including external leading.
        GRAPHIC(Cell.Size.Y) Retrieves the character cell height including external leading.
        GRAPHIC(Chr.Size.X) Retrieves the character width on the graphic target.
        GRAPHIC(Chr.Size.Y) Retrieves the character height on the graphic target.
        GRAPHIC(Client.X) Retrieves the client width of the attached graphic target.
        GRAPHIC(Client.Y) Retrieves the client height of the attached graphic target.
        GRAPHIC(Clip.X) Retrieves the width of the clip area.
        GRAPHIC(Clip.Y) Retrieves the height of the clip area.
        GRAPHIC(COL) Retrieves the next column print position, based upon the row and column position of a text cell.
        GRAPHIC(DC) Retrieves the handle of the DC (device context) for the selected graphic target.
        GRAPHIC(INSTAT) determines whether a keyboard character is ready.
        GRAPHIC(LINES) Retrieves the number of text lines which will fit on the graphic target.
        GRAPHIC(LOC.X) Retrieves the horizontal location of the graphic target on the desktop.
        GRAPHIC(LOC.Y) Retrieves the vertical location of the graphic target on the desktop
        GRAPHIC(MIX) Retrieves the color mix mode for the selected graphic target.
        GRAPHIC(OVERLAP) Retrieves the status of Graphic Overlap Mode.
        GRAPHIC(PIXEL...) Retrieves the color of the pixel at the specified point.
        GRAPHIC(POS.X) Retrieves the horizontal POS (last point referenced) by a GRAPHIC statement.
        GRAPHIC(POS.Y) Retrieves the vertical POS (last point referenced) by a GRAPHIC statement.
        GRAPHIC(PPI.X) Retrieves the horizontal resolution of the display device, in points per inch.
        GRAPHIC(PPI.Y) Retrieves the vertical resolution of the display device, in points per inch.
        GRAPHIC(ROW) Retrieves the next row print position, based upon the row and column position of a text cell.
        GRAPHIC(SCROLLTEXT) Retrieves the status of Graphic ScrollText Mode.
        GRAPHIC(SIZE.X) Retrieves the overall width of the selected graphic target.
        GRAPHIC(SIZE.Y) Retrieves the overall height of the selected graphic target.
        GRAPHIC(STRETCHMODE) Retrieves the default bitmap stretching mode for the attached DC.
        GRAPHIC(TEXT.SIZE.X...) calculates the width of text to be printed.
        GRAPHIC(TEXT.SIZE.Y...) calculates the height of text to be printed.
        GRAPHIC(View.X) Retrieves the horizontal position of the virtual graphic viewport.
        GRAPHIC(View.Y) Retrieves the vertical position of the virtual graphic viewport.
        GRAPHIC(WORDWRAP) Retrieves the status of Graphic WordWrap Mode.
        GRAPHIC(WRAP) Retrieves the status of Graphic Wrap Mode.
        GRAPHIC$(CAPTION) Retrieves the caption from a Graphic Window.
        GRAPHIC$(INKEY$) reads a keyboard character if one is ready.
        GRAPHIC$(WAITKEY$) reads a keyboard character or extended key, waiting until one is ready.
        GRAPHIC$(WAITKEY$...) reads a limited set of keyboard characters or extended keys, with an optional timeout value.
        GRAPHIC ARC Draw an arc in the selected graphic window.
        GRAPHIC ATTACH Select the graphic target (window, control, or bitmap) on which future drawing operations will take place.
        GRAPHIC BITMAP END Close the selected graphic bitmap.
        GRAPHIC BITMAP LOAD Create a memory bitmap and load an image into it.
        GRAPHIC BITMAP NEW Create a new memory bitmap.
        GRAPHIC BOX Draw a box with square or rounded corners in the selected graphic window.
        GRAPHIC CELL Sets or Retrieves the next print position of a text cell.
        GRAPHIC CELL SIZE Retrieve the character cell size including external leading.
        GRAPHIC CHR SIZE Retrieve the character size for the current font in the selected graphic window.
        GRAPHIC CLEAR Clear the entire selected graphic window, optionally using a specified color and fill style.
        GRAPHIC COLOR Set the foreground color and optionally the background color for various graphic statements.
        GRAPHIC COPY Copy a bitmap to the selected graphic target.
        GRAPHIC DETACH Detaches a graphic target.
        GRAPHIC ELLIPSE Draw an ellipse or a circle in the selected graphic target.
        GRAPHIC GET BITS Retrieve a copy of a bitmap, storing it as a device-independent bitmap in a dynamic string variable.
        GRAPHIC GET CANVAS Retrieves the buffer size of the attached graphic target.
        GRAPHIC GET CAPTION Retrieves the caption from a Graphic Window.
        GRAPHIC GET CLIENT Retrieve the client size of the selected graphic target.
        GRAPHIC GET CLIP Retrieves the size of the clip area.
        GRAPHIC GET DC Retrieve the handle of the DC (device context) for the selected graphic target.
        GRAPHIC GET LINES Retrieve the number of lines that can be printed on the graphic target.
        GRAPHIC GET LOC Retrieve the location of the selected graphic target on the screen.
        GRAPHIC GET MIX Retrieve the color mix mode for the selected graphic target.
        GRAPHIC GET OVERLAP Retrieves the status of Graphic Overlap Mode.
        GRAPHIC GET PIXEL Retrieve the color of the pixel at the specified point in the selected graphic target.
        GRAPHIC GET POS Retrieve the POS (last point referenced) by a graphic statement.
        GRAPHIC GET PPI Retrieve the resolution of the display device, in points per inch.
        GRAPHIC GET SCALE Retrieve the current coordinate limits for the graphic target.
        GRAPHIC GET SCROLLTEXT Retrieves the status of Graphic ScrollText Mode.
        GRAPHIC GET SIZE Retrieves the overall size of the selected graphic target.
        GRAPHIC GET STRETCHMODE Retrieves the default bitmap stretching mode for the attached DC.
        GRAPHIC GET VIEW Retrieves the position of the virtual graphic viewport.
        GRAPHIC GET WORDWRAP Retrieves the status of Graphic WordWrap Mode.
        GRAPHIC GET WRAP Retrieves the status of Graphic Wrap Mode.
        GRAPHIC IMAGELIST Display an image from an IMAGELIST.
        GRAPHIC INKEY$ Read a keyboard character if one is ready from the graphic target.
        GRAPHIC INPUT Read data from the keyboard from within a graphic window.
        GRAPHIC INSTAT Determine whether a keyboard character is ready.
        GRAPHIC INPUT FLUSH Remove all buffered keyboard data.
        GRAPHIC LINE Draw a line in the selected graphic target.
        GRAPHIC LINE INPUT Read an entire line from the keyboard from graphic window.
        GRAPHIC PAINT Fill an area with a solid color or a hatch pattern.
        GRAPHIC PIE Draw a pie section on the selected graphic target.
        GRAPHIC POLYGON Draw a polygon in the selected graphic target.
        GRAPHIC POLYLINE Draw a series of connected line segments.
        GRAPHIC PRINT Output text to the selected graphic target.
        GRAPHIC REDRAW Update buffered graphical statements, drawing them to the selected graphic target.
        GRAPHIC RENDER Render an image on the selected graphic target.
        GRAPHIC SAVE Save an image to a bitmap (.BMP) file.
        GRAPHIC SCALE Define a custom coordinate system for the graphic target.
        GRAPHIC SET AUTOSIZE Expands a graphic target into autosize mode.
        GRAPHIC SET BITS Replace a copy of a bitmap that was retrieved as a device-independent bitmap.
        GRAPHIC SET CAPTION Change the caption on a Graphic Window.
        GRAPHIC SET CLIENT Change the size of a graphic control or graphic window to a specific client area size.
        GRAPHIC SET CLIP Establishes margins around the outer edges of the graphic target.
        GRAPHIC SET FIXED Restores a graphic target to standard fixed mode.
        GRAPHIC SET FOCUS Bring the selected graphic window to the foreground and direct focus to it.
        GRAPHIC SET FONT Select a font for the GRAPHIC PRINT, GRAPHIC INPUT, and GRAPHIC LINE INPUT statements.
        GRAPHIC SET LOC Change the location of the selected graphic window on the screen.
        GRAPHIC SET MIX Set the color mix mode for the selected graphic target.
        GRAPHIC SET OVERLAP Enables or disables Graphic Overlap Mode.
        GRAPHIC SET PIXEL Draw a single pixel to the selected graphic window.
        GRAPHIC SET POS Set the last point referenced (POS) for the selected graphic target.
        GRAPHIC SET SCROLLTEXT Enables or disables Graphic ScrollText Mode.
        GRAPHIC SET SIZE Change the overall size of a graphic control or graphic window.
        GRAPHIC SET STRETCHMODE Sets the default bitmap stretching mode for the current DC.
        GRAPHIC SET VIEW Changes the position of the viewport on a virtual graphic target.
        GRAPHIC SET VIRTUAL Expands a graphic target into virtual mode.
        GRAPHIC SET WORDWRAP Enables or disables Graphic WordWrap Mode.
        GRAPHIC SET WRAP Enables or disables Graphic Wrap Mode.
        GRAPHIC SPLIT Splits a string into two parts for display on a graphic target.
        GRAPHIC STRETCH Copy and resize a bitmap to the selected graphic target.
        GRAPHIC STYLE Set the line style to be used by various graphical statements in the selected graphic target.
        GRAPHIC TEXT SIZE Calculate the size of text to be printed.
        GRAPHIC WAITKEY$ Read a keyboard character from the graphic window, waiting until one is ready.
        GRAPHIC WIDTH Set the line width to be used by various graphical statements in the selected graphic target.
        GRAPHIC WINDOW Create a new graphic window.
        GRAPHIC WINDOW CLICK Check whether a GRAPHIC WINDOW has been clicked with the mouse.
        GRAPHIC WINDOW END Close and destroy the selected graphic window.
        GRAPHIC WINDOW HIDE Make a graphic window invisible.
        GRAPHIC WINDOW MINIMIZE Minimize a graphic window.
        GRAPHIC WINDOW NONSTABLE Make a graphic window non-stable (closeable).
        GRAPHIC WINDOW NORMALIZE Make a graphic window visible.
        GRAPHIC WINDOW STABILIZE Make a graphic window stable (non-closeable).
        GRAPHIC WINDOW TEXT Create a new graphic window oriented more towards the display of text.
        IMAGELIST ADD BITMAP An bitmap image is added to the IMAGELIST.
        IMAGELIST ADD ICON An icon image is added to the IMAGELIST.
        IMAGELIST ADD MASKED A bitmap is added to the icon IMAGELIST.
        IMAGELIST GET COUNT The number of images in the IMAGELIST is retrieved.
        IMAGELIST KILL The specified IMAGELIST is destroyed.
        IMAGELIST NEW BITMAP A new bitmap IMAGELIST structure is created.
        IMAGELIST NEW ICON A new icon IMAGELIST structure is created.
        IMAGELIST SET OVERLAY Specify an image to be used as an overlay.
        RGB Return an RGB color value for use with the Windows API palette and GDIs.

        Comment


        • #5
          Hi Izzy,

          Here's a compilable example of GRAPHIC SCALE in action..
          '
          Code:
          #COMPILE EXE                        ' PBCC6 program
          #DIM ALL
          
          FUNCTION PBMAIN () AS LONG
           LOCAL hGWin As Dword
           LOCAL Clk, x, y, r, n, xmax, ymax, hFont1, hFont2 AS Long
           LOCAL Title, xAxis, yAxis, sKey As String
          
              CONSOLE SET LOC 1,1
              CONSOLE SET SCREEN 15,25
          
            Title = "Title"
            xAxis = "X-Axis"
            yAxis = "Y-Axis"
          
            GRAPHIC WINDOW "test",300,300,800,500 TO hGWin
            GRAPHIC ATTACH hGWin, 0
            GRAPHIC CLEAR %WHITE
            GRAPHIC COLOR %BLACK, %WHITE
            FONT NEW "Lucida Console", 12, 0, 0, 0, 0 TO hFont1      ' set up fonts to be used
            FONT NEW "Lucida Console", 12, 0, 0, 0, 900 TO hFont2    ' rotated font (must be true type)
          
            xmax = 50 : ymax = 100
              PRINT "xmax" xmax, "ymax" ymax
           '  GRAPHIC SCALE (-5, ymax+10) - (xmax+10,-15)       ' SET SCALE / ORIENTATION
            GRAPHIC SCALE (-6, ymax+10) - (xmax+10,-15)
          
            GRAPHIC SET FONT hFont1                           ' set font1
            GRAPHIC SET POS (xmax/2, ymax+9) : GRAPHIC PRINT Title
            GRAPHIC SET POS (xmax/2,-9)      : GRAPHIC PRINT xAxis    ' X Label
          
            GRAPHIC LINE (0,0) - (0,ymax+5)                   ' y axis
            FOR r = 0 TO ymax STEP 5                          ' marks
              IF r MOD 10 = 0 THEN
                GRAPHIC LINE (0,r) - (-.5,r)
                GRAPHIC SET POS STEP (-4,1.5)
                GRAPHIC PRINT r                               ' scale values
              ELSE
                GRAPHIC LINE (0,r) - (-.2,r)
              END IF
            NEXT
          
            GRAPHIC SET FONT hFont2                           ' font2 = rotated font
            GRAPHIC SET POS (-5.5, ymax/2)
            GRAPHIC PRINT yAxis                               ' Y Label
          
            GRAPHIC SET FONT hFont1                           ' set font1
            GRAPHIC LINE (0,0) - (xmax+5,0)                   ' x axis
            FOR r = 0 TO xmax STEP 5                          ' marks
              IF r MOD 10 = 0 THEN
                GRAPHIC LINE (r,0) - (r,-2)
                GRAPHIC SET POS STEP (-1,-2)
                GRAPHIC PRINT r                               ' scale values
              ELSE
                GRAPHIC LINE (r,0) - (r,-1)
              END IF
            NEXT
          
           GRAPHIC SET POS (1, ymax+8) : GRAPHIC PRINT "Click screen for values"
           '------------------/
           ' Check for user input
            DO WHILE GRAPHIC(DC) <> 0                           ' loop while Graphic Window exists
              GRAPHIC INKEY$ TO sKey$                           ' check keyboard input to graphic window
              SLEEP 1
              IF sKey$ <> "" THEN EXIT LOOP                     ' any key to quit loop (focus goes to console)
          
              GRAPHIC WINDOW CLICK hGWin TO Clk, x, y           ' check if graphic window clicked
              IF Clk = 2 THEN                                   ' Double Click
                GRAPHIC SET POS (1, ymax+8) : GRAPHIC SET CAPTION "Dbl Click x:"+STR$(x)+", y:"+STR$(y) ' clear old pos info
              ELSEIF Clk = 1 THEN
                GRAPHIC SET POS (1, ymax+8) : GRAPHIC PRINT "                       "
                GRAPHIC SET CAPTION " x:"+STR$(x)+", y:"+STR$(y)  ' show 'click' position in graphic window
              END IF
            LOOP
          
              PRINT "Press any key to end."
              CONSOLE SET FOCUS
              WAITKEY$
          
          END FUNCTION
          '------------------/PBMAIN
          Click image for larger version

Name:	Axis.PNG
Views:	72
Size:	18.5 KB
ID:	796256
          Rgds, Dave

          Comment


          • #6
            Just a note on GRAPHIC SCALE
            Code:
            GRAPHIC SCALE (-6, ymax+10) - (xmax+10,-15)
            Help says: Note: GRAPHIC SCALE will not work with negative numeric values - all numeric arguments must be positive

            As you can see from Dave's example, that is not true ( and it was not even true for PBWin8/CC4 ).

            Comment


            • #7
              My question, to the PB experts is how to make the 0,0 point the bottom left of the screen, and also how to make the numbers get more positive in the "Y" direction, that is the upward direction...
              I had to do something similar when creating a PDF file using the Haru Library. First, I was working and thinking in inches but the library needed everything in points; second, the library assumed the origin ("0,0") was at the bottom left but for print reports I was used to working with the origin at the top left.

              So I cheated and created some user macros and functions I could use to feel a bit more "natural"

              Code:
              MACRO  HPDF_REAL = SINGLE
              
              FUNCTION TO_XPOINT ( inches AS SINGLE) PRIVATE AS HPDF_REAL
                  FUNCTION = inches * 72!
              END FUNCTION
              
              ' convert Y in INCHES FROM TOP OF PAGE
              ' to PDF points FROM BOTTOM OF PAGE
              ' A page is %PAGE_HEIGHT_POINTS high
              
              FUNCTION TO_YPOINT (inches AS SINGLE) PRIVATE AS HPDF_REAL
                  FUNCTION = %PAGE_HEIGHT_POINTS - (inches * 72!)
              END FUNCTION
              Using to output stuff:

              Code:
              IF PageNo <> LIC(iLI).iPageNo THEN
              ' new page needed
              ' first print a $LIT_CONTINUED at designated place on THIS page
              x2 = %X_CONTINUED/100! + lMargin
              xPos = TO_XPOINT(X2)
              Y2 = Y2 + %CY_LI_LINES/100
              Ypos = TO_YPoint ( Y2)
              szText = $LIT_CONTINUED
              HPDF_PAGE_BeginText hPage(PageNo)
              HPDF_Page_SetFontAndSize hPage(PageNo), hFont(%FONT_SUB_LINEITEM), %FONT_SIZE_LINEITEM
              iRet = HPDF_Page_SetRGBFill (hPage(PageNo), 0!, 0!, 0!) ' all zero should be black
              HPDF_Page_TextOut hPage(PageNo), xpos, Ypos, szText
              HPDF_PAge_EndText hPage(PageNo)
              As you can see, I also used a lot of equates... which I set up as "inches * 100" so for example an inch and a half was defined = 150

              (It took a lot of tuning to get everything exactly where it needed to be and changing one equate was a lot easier than finding every relevant occurrence of a numeric literal).

              You can probably gin up something like this for your application.

              MCM
              Michael Mattias
              Tal Systems Inc. (retired)
              Racine WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                To all...
                Thanx to all of you for your help...
                Michael Mattias... It is good to here from you again... When I first came on Power Basic your responses were a tremendous help in my continuing to use Power Basic... At that time I was using PBWIN 4 and 8 and PWCC 4.0...
                Stuart McLachian... I really do appreciate your advice... I am not certain if you are aware that I am 60% blind... The help screen is only a help to me when someone is with me to read the items...
                I can find things on my own but it takes a lot of time and effort... That is why I copy a previous file that has everything and more than I need to start any project... Lets not discus memory... I don't know how many times I used 'WAITKEY$' and nothing happened until I realized that I forgot to use 'GRAPHIC WAITKEY$' instead...
                Dave Biggs... I still have some help files I downloaded from you when I first came to Power Basic... Thanx for your INPUT today... Or should that be 'GRAPHIC INPUT'...
                Dale Yarker... Thanx to you also for your thoughts on MY problems...
                And a heavenly thanx to Bob... The guy that made PW happen... I remember asking him if the compiled version of a program was safe from being reverse coded... His answer was that it is the same as taking 500 pounds of hamburger and turning it back into a cow...
                I remember a HEX program I used that allowed editing by pressing the F3 key to toggle between the HEX code and the ASCII code... Anyone remember that program?
                To the many others that I missed... Thanx...

                Izzy

                Comment


                • #9
                  You know, you'd think "someone" by now would have used the text-to-speech library to create an app to "read this page of the help file aloud on request."

                  I have to believe that would be useful for all the visually impaired, no?
                  Michael Mattias
                  Tal Systems Inc. (retired)
                  Racine WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    Thanx for the thought, Michael... I have voice support on my computer for most of the text on the screen, where I set the pointer... My problem is finding the function on the menu...
                    If it weren't for this plague we are trying to fight through, I would not have been doing any Power Basic programming... Maybe it's time to retire again...

                    Best to all...

                    Izzy

                    Comment


                    • #11
                      have voice support on my computer for most of the text on the screen,
                      So... someone DID do that!

                      Maybe it's time to retire again...
                      Once you get into it, it really is pretty cool.
                      Michael Mattias
                      Tal Systems Inc. (retired)
                      Racine WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment

                      Working...
                      X