faqts : Computers : Programming : Languages : Bbcbasic

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

BBCBASIC: Windows: API: Graphics: GDI: Line: Operation: Draw: How to?

May 7th, 2006 12:54
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 07 May 2006 - 05:29 pm ------------------------

BBCBASIC: Windows: API: Graphics: GDI: Line: Operation: Draw: How to?

===

To draw a line between 2 given points:

 1. Create a pen to write with

 2. Move to a begin position (on the screen)

 3. Draw a line to an end position (on the screen)

===

Steps: Overview:

 1. -Create a pen to write with

     1. -Initialize your variables

         1. -Choose the color of your line

             1. -Choose your RGB value

                 1. -colorRedI% (or 'R'ed) is a number between 0 and
                     255 telling the influence of the color component
                     'red'

                 2. -colorGreenI% (or 'G'reen) is a number between 0
                     and 255 telling the influence of color component
                     'green'

                 3. -colorBlueI% (or 'B'lue) is a number between 0 and
                     255 telling the influence of color component
                     'blue'

         2. -Choose the thickness of your line

         3. -Choose the cap of your line

         4. -Create a handle to a window (canvas) you are going to
             write on

             1. -Use e.g. the inbuilt global BBCBASIC variable

                  @memhdc%

                 1. -You know it is inbuilt, because if you create a
                     new program

                      PRINT @memhdc%
                      END

                     It will print e.g. some (random like) number

         5. -Store some information in the screen memory block
             (which starts at the value of the inbuilt BBCBASIC
              variable @vdu%)

 2. -Move to a begin position (on the screen)

     1. -Move to the point

          x1%, y1%

         1. -To get your final x and y, you
             do some linear transformations (like
             scaling and translation)

 3. -Draw a line to an end position (on the screen)

     1. -Draw to the point

          x2%, y2%

         1. -To get your final x and y, you
             do some linear transformations (like
             scaling and translation)

 4. -Create e.g. the following program

--- cut here: begin --------------------------------------------------

   REM PROCGraphicsGotoApiGdiLineTo( xI%, yI% )


--- cut here: end ----------------------------------------------------

 5. -If you run this, it will show a line on a graphics screen

      +-------------------------+
      |                         |
      | . (100, 1000)           |
      |   .                     |
      |     .                   |
      |       .                 |
      |         . (400, 900)    |
      |                         |
      |                         |
      |                         |
      |                         |
      |                         |
      |                         |
      |                         |
      |                         |
      |                         |
      |                         |
      +-------------------------+

===

Internet: see also:

---

BBCBASIC: Windows: Variable: System: Overview: Where to find? [API / 
GDI / GDI+ / @vdu% / @memhdc%]
http://www.faqts.com/knowledge_base/view.phtml/aid/40924/fid/768

---

BBCBASIC: Windows: Graphics: Microsoft: GDI+: Program: How to?
http://www.faqts.com/knowledge_base/view.phtml/aid/40928/fid/768

----------------------------------------------------------------------