print pixels in certain positions

print pixels in certain positions

Postby Silvio.Falconi » Fri Mar 18, 2022 9:24 am

I am trying to print pixels in certain positions
If on the screen the position is x = 4.2 and y = 21.40 multiplied by an n = 10.8 in the printout I cannot center the exact position
in the image you see I put the image below just to help me but in printing it is not printed also because in the printer I put the receipts as sheets of paper

Image

I built a grid to understand what the exact position is compared to the one shown in the video but I didn't understand how to do it

On dialog I have this

Image

what mathematical operation should I do to print the pixel in the right position?


I tried to print a Box having the same measure

Code: Select all  Expand view

function PrintPixel(oPrn)
local nRow:=4.2
Local ncol:= 21.4
local nRapporto := 3.9
local x,y
local nWidth := 2
local nHeight := 2
local oBrushBlack
 nRow     += 0.1 * nRapporto
       nCol     += 0.1 * nRapporto
       nWidth   -= 0.1
       nHeight  -= 0.2

  DEFINE BRUSH oBrushBlack COLOR CLR_BLACK

oPrn:Box(nRow, nCol, nRow + nHeight,nCol + nWidth, ,oBrushBlack,, "MM" )// { cText, oFontSmall2, nColortext1 }

  return nil
 




But the pixel is printed at this position

Image

see this image

Image

the circle with the number "1" is at 4.2 with respect to the left side of the receipt, and at 21.40 with respect to the top of the receipt
the measurements are expressed in millimeters
in the picture the horizontal distance between boxes is 5.45 and the vertical distance is 3.9


Any solution please ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: print pixels in certain positions

Postby Detlef » Fri Mar 18, 2022 6:52 pm

Here is the topic I wanted to answer.
Silvio I try to write a formula for your printing problem.
But i need some measurements in mm.

please, give me the values of a, b, c as you can see on my picture.

Image
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: print pixels in certain positions

Postby Silvio.Falconi » Fri Mar 18, 2022 8:47 pm

There are several coupons for now I'm working with a coupon I can send you all types
It have the width 10 the length 20.5
In this coupon there are 5 boxes
box 1 (Numbers)

the circle "1" is at a distance x from the edge 0.8 and a
distance y from the edge 2.7
each circle has a size of 0.50 (A)
the distance between the two circles (B) is 1.2
the distance between one line and the one below (C) is 0.9

I hope these measure are right

the final user can insert on screen the right measure also for the pixel of each box
if you send me you mail I can send you the test I made
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: print pixels in certain positions

Postby Detlef » Sat Mar 19, 2022 8:28 pm

Silvio,
here is a program which may help you to print pixels in certain positions.
I think you can easily adapt this mechanic to all of your different forms.

Code: Select all  Expand view
#include "FiveWin.ch"

#define _MARGIN_LEFT   0.8  // the circle pattern starts 8 mm from Top
#define _MARGIN_TOP    2.7  // the circle pattern starts  27 mm from Left
#define _XSPACE        0.7  // distance horizontal between 2 circles
#define _YSPACE        0.7  // distance vertical   between 2 circles
#define _CIRCLE        0.5  // each circle has 5 mm in diameter

FUNCTION Main()
//-------------
LOCAL n, o
LOCAL oPrn, oPen, oBrush
LOCAL nTop, nLeft, nBottom, nRight, aRect

LOCAL nVar := 1   // as lotto number
LOCAL nRow := 0   // row to find
LOCAL nCol := 0   // col to find

LOCAL aSelect := {}


// for selecting a number
      for n := 1 to 90
         aadd( aSelect, str( n, 2, 0 ) )
      next

      nVar := MsgSelect( aSelect, " 1" )
//---------------------------------------------

      DEFINE BRUSH oBrush COLOR CLR_BLACK

      PRINT oPrn NAME OemToAnsi( "Silvio Print" ) PREVIEW
         DEFINE PEN  oPen WIDTH  2  OF oPrn

         PAGE     // printing the circles form

            for n := 1 to 9
               for o := 1 to 10
                  nTop    := _MARGIN_TOP  + ( ( n - 1 ) * _YSPACE )
                  nLeft   := _MARGIN_LEFT + ( ( o - 1 ) * _XSPACE )
                  nBottom := nTop    + _CIRCLE
                  nRight  := nLeft   + _CIRCLE

                  oPrn:Cmtr2Pix( @nTop,    @nLeft  )
                  oPrn:Cmtr2Pix( @nBottom, @nRight )

                  oPrn:Ellipse( nTop, nLeft, nBottom, nRight, oPen )
               next
            next

            // now printing a square into circle
            //----------------------------------
            nRow := int( nVar / 10 )
            nCol := ( nVar % 10 )
            if nCol == 0
               nCol := 10
            else
               ++nRow
            endif

            nTop    := _MARGIN_TOP  + .1 + ( --nRow  * _YSPACE )    // + .1 to make square smaller than circle
            nLeft   := _MARGIN_LEFT + .1 + ( --nCol  * _XSPACE )    // + .1 to make square smaller than circle
            nBottom := nTop    - .2 + _CIRCLE                       // - .2 to make square smaller than circle
            nRight  := nLeft   - .2 + _CIRCLE                       // - .2 to make square smaller than circle

            oPrn:Cmtr2Pix( @nTop,    @nLeft  )
            oPrn:Cmtr2Pix( @nBottom, @nRight )

            aRect := { nTop,  nLeft , nBottom , nRight }
            oPrn:FillRect( aRect, oBrush )

         ENDPAGE

      ENDPRINT

      oBrush:End()
      oPen:End()
RETURN NIL


FUNCTION MsgSelect( aItems, cValue, cTitle )
//------------------------------------------
LOCAL oDlg

   DEFAULT cTitle := "Please, select"

   DEFINE DIALOG oDlg FROM 5,10 TO 24, 55 TITLE cTitle

   @  1, 7 LISTBOX cValue ITEMS aItems SIZE 70, 90 OF oDlg

   @ 7, 7 BUTTON "&OK" OF oDlg SIZE 40, 12 ;
     ACTION oDlg:End() DEFAULT

   @ 7, 17 BUTTON "&Cancel" OF oDlg SIZE 40, 12 ;
     ACTION ( cValue := nil, oDlg:End() )

   ACTIVATE DIALOG oDlg CENTERED

RETURN(  val( alltrim( cValue ) ) )

 

Regards, Detlef
Last edited by Detlef on Sat Mar 19, 2022 11:35 pm, edited 1 time in total.
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: print pixels in certain positions

Postby Silvio.Falconi » Sat Mar 19, 2022 10:03 pm

Detlef wrote:Silvio,
here is a program which may help you to print pixels in certain positions.
I think you can easily adapt this mechanic to all of your different forms.

Code: Select all  Expand view
#include "FiveWin.ch"

#define _MARGIN_LEFT   0.8  // the circle pattern starts 25 mm from Top
#define _MARGIN_TOP    2.7  // the circle pattern starts  2 mm from Left
#define _XSPACE        0.7  // distance horizontal between 2 circles
#define _YSPACE        0.7  // distance vertical   between 2 circles
#define _CIRCLE        0.5  // each circle has 5 mm in diameter

FUNCTION Main()
//-------------
LOCAL n, o
LOCAL oPrn, oPen, oBrush
LOCAL nTop, nLeft, nBottom, nRight, aRect

LOCAL nVar := 1   // as lotto number
LOCAL nRow := 0   // row to find
LOCAL nCol := 0   // col to find

LOCAL aSelect := {}


// for selecting a number
      for n := 1 to 90
         aadd( aSelect, str( n, 2, 0 ) )
      next

      nVar := MsgSelect( aSelect, " 1" )
//---------------------------------------------

      DEFINE BRUSH oBrush COLOR CLR_BLACK

      PRINT oPrn NAME OemToAnsi( "Silvio Print" ) PREVIEW
         DEFINE PEN  oPen WIDTH  2  OF oPrn

         PAGE     // printing the circles form

            for n := 1 to 9
               for o := 1 to 10
                  nTop    := _MARGIN_TOP  + ( ( n - 1 ) * _YSPACE )
                  nLeft   := _MARGIN_LEFT + ( ( o - 1 ) * _XSPACE )
                  nBottom := nTop    + _CIRCLE
                  nRight  := nLeft   + _CIRCLE

                  oPrn:Cmtr2Pix( @nTop,    @nLeft  )
                  oPrn:Cmtr2Pix( @nBottom, @nRight )

                  oPrn:Ellipse( nTop, nLeft, nBottom, nRight, oPen )
               next
            next

            // now printing a square into circle
            //----------------------------------
            nRow := int( nVar / 10 )
            nCol := ( nVar % 10 )
            if nCol == 0
               nCol := 10
            else
               ++nRow
            endif

            nTop    := _MARGIN_TOP  + .1 + ( --nRow  * _YSPACE )    // + .1 to make square smaller than circle
            nLeft   := _MARGIN_LEFT + .1 + ( --nCol  * _XSPACE )    // + .1 to make square smaller than circle
            nBottom := nTop    - .2 + _CIRCLE                       // - .2 to make square smaller than circle
            nRight  := nLeft   - .2 + _CIRCLE                       // - .2 to make square smaller than circle

            oPrn:Cmtr2Pix( @nTop,    @nLeft  )
            oPrn:Cmtr2Pix( @nBottom, @nRight )

            aRect := { nTop,  nLeft , nBottom , nRight }
            oPrn:FillRect( aRect, oBrush )

         ENDPAGE

      ENDPRINT

      oBrush:End()
      oPen:End()
RETURN NIL


FUNCTION MsgSelect( aItems, cValue, cTitle )
//------------------------------------------
LOCAL oDlg

   DEFAULT cTitle := "Please, select"

   DEFINE DIALOG oDlg FROM 5,10 TO 24, 55 TITLE cTitle

   @  1, 7 LISTBOX cValue ITEMS aItems SIZE 70, 90 OF oDlg

   @ 7, 7 BUTTON "&OK" OF oDlg SIZE 40, 12 ;
     ACTION oDlg:End() DEFAULT

   @ 7, 17 BUTTON "&Cancel" OF oDlg SIZE 40, 12 ;
     ACTION ( cValue := nil, oDlg:End() )

   ACTIVATE DIALOG oDlg CENTERED

RETURN(  val( alltrim( cValue ) ) )

 

Regards, Detlef



Very Very Nice,
On Print I not make the circles because I put the receipt on the printer

//first Model
Image

//second Model
Image



Then I not Print one number but I can print from one to all numbers - But Imade a small modification - and run ok

I try with 5 numbers

Image

the modifications
Code: Select all  Expand view

    #include "FiveWin.ch"

    #define _MARGIN_LEFT   0.8  // the circle pattern starts 25 mm from Top
    #define _MARGIN_TOP    2.7  // the circle pattern starts  2 mm from Left
    #define _XSPACE        0.7  // distance horizontal between 2 circles
    #define _YSPACE        0.7  // distance vertical   between 2 circles
    #define _CIRCLE        0.5  // each circle has 5 mm in diameter

    FUNCTION Main()
    //-------------
    LOCAL n, o
    LOCAL oPrn, oPen, oBrush
    LOCAL nTop, nLeft, nBottom, nRight, aRect

    LOCAL nVar := 1   // as lotto number
    LOCAL nRow := 0   // row to find
    LOCAL nCol := 0   // col to find

    LOCAL aSelect := {}
    LOCAL aNumbers:= {}  //as DEMO  silvio
   LOCAL nI //demo silvio

   /* // for selecting a number
  /*        for n := 1 to 90
             aadd( aSelect, str( n, 2, 0 ) )
          next

          nVar := MsgSelect( aSelect, " 1" )*/

    //---------------------------------------------

          aNumbers:= {30,54,17,18,81}  //as DEMO silvio


          DEFINE BRUSH oBrush COLOR CLR_BLACK

          PRINT oPrn NAME OemToAnsi( "Silvio Print" ) PREVIEW
             DEFINE PEN  oPen WIDTH  2  OF oPrn

             PAGE     // printing the circles form

                for n := 1 to 9
                   for o := 1 to 10
                      nTop    := _MARGIN_TOP  + ( ( n - 1 ) * _YSPACE )
                      nLeft   := _MARGIN_LEFT + ( ( o - 1 ) * _XSPACE )
                      nBottom := nTop    + _CIRCLE
                      nRight  := nLeft   + _CIRCLE

                      oPrn:Cmtr2Pix( @nTop,    @nLeft  )
                      oPrn:Cmtr2Pix( @nBottom, @nRight )

                      oPrn:Ellipse( nTop, nLeft, nBottom, nRight, oPen )
                   next
                next

                // now printing a square into circle
                //----------------------------------
            For nI= 1 to Len(aNumbers)
               nVar:=aNumbers[nI]

                nRow := int( nVar / 10 )
                nCol := ( nVar % 10 )
                if nCol == 0
                   nCol := 10
                else
                   ++nRow
                endif

                nTop    := _MARGIN_TOP  + .1 + ( --nRow  * _YSPACE )    // + .1 to make square smaller than circle
                nLeft   := _MARGIN_LEFT + .1 + ( --nCol  * _XSPACE )    // + .1 to make square smaller than circle
                nBottom := nTop    - .2 + _CIRCLE                       // - .2 to make square smaller than circle
                nRight  := nLeft   - .2 + _CIRCLE                       // - .2 to make square smaller than circle

                oPrn:Cmtr2Pix( @nTop,    @nLeft  )
                oPrn:Cmtr2Pix( @nBottom, @nRight )

                aRect := { nTop,  nLeft , nBottom , nRight }
                oPrn:FillRect( aRect, oBrush )
               Next
             ENDPAGE

          ENDPRINT

          oBrush:End()
          oPen:End()
    RETURN NIL


    FUNCTION MsgSelect( aItems, cValue, cTitle )
    //------------------------------------------
    LOCAL oDlg

       DEFAULT cTitle := "Please, select"

       DEFINE DIALOG oDlg FROM 5,10 TO 24, 55 TITLE cTitle

       @  1, 7 LISTBOX cValue ITEMS aItems SIZE 70, 90 OF oDlg

       @ 7, 7 BUTTON "&OK" OF oDlg SIZE 40, 12 ;
         ACTION oDlg:End() DEFAULT

       @ 7, 17 BUTTON "&Cancel" OF oDlg SIZE 40, 12 ;
         ACTION ( cValue := nil, oDlg:End() )

       ACTIVATE DIALOG oDlg CENTERED

    RETURN(  val( alltrim( cValue ) ) )
   
 


Now I must try to print to see it is ok

Then I already told you that in the receipt there are other boxes with other points to put for this I wanted your email to send you the two types of receipt.

Then I would have preferred to have the coordinates in an archive to be modified by the user

then as I sad you on receipt there are other box and I didn't understand how to print the other boxes but I'm studying your source
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: print pixels in certain positions

Postby Detlef » Sat Mar 19, 2022 11:16 pm

Silvio,
this is the important part of my code…

Code: Select all  Expand view
            // now printing a square into circle
            //----------------------------------
            nRow := int( nVar / 10 ) // how many complete rows ( there 10 cols)
            nCol := ( nVar % 10 )    // the rest of the division  may give a new row
            if nCol == 0                 // if no rest of Division  it must be the 10th column
               nCol := 10
            else
               ++nRow                    // additional row because the division gave a rest
            endif

 
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: print pixels in certain positions

Postby Silvio.Falconi » Sun Mar 20, 2022 11:20 am

Dear Detlef,
I tried to divide the receipt on Sections

Print_Numbers(oPrn,oPen,aNumbers,oBrush) // section 1
Print_Ruote(oPrn,oPen,aRoutes,oBrush) // section 2

Code: Select all  Expand view

       #include "FiveWin.ch"

    #define _MARGIN_LEFT   0.8  // the circle pattern starts 25 mm from Top
    #define _MARGIN_TOP    2.7  // the circle pattern starts  2 mm from Left
    #define _XSPACE        0.7  // distance horizontal between 2 circles
    #define _YSPACE        0.7  // distance vertical   between 2 circles
    #define _CIRCLE        0.5  // each circle has 5 mm in diameter




    FUNCTION Main()
    //-------------
    LOCAL n, o
    LOCAL oPrn, oPen, oBrush
    LOCAL nTop, nLeft, nBottom, nRight, aRect

    LOCAL nVar := 1   // as lotto number
    LOCAL nRow := 0   // row to find
    LOCAL nCol := 0   // col to find

    LOCAL aSelect := {}
    LOCAL aNumbers:= {}  //as DEMO  silvio
    LOCAL aRoutes:= {}   //as DEMO  silvio

    // for selecting a number
    /*      for n := 1 to 90
             aadd( aSelect, str( n, 2, 0 ) )
          next

        *  nVar := MsgSelect( aSelect, " 1" )*/

    //---------------------------------------------

          aNumbers:= {30,54,17,18,81}  //as DEMO silvio
          aRoutes:= {1,5,7}  //as DEMO silvio

          DEFINE BRUSH oBrush COLOR CLR_BLACK

          PRINT oPrn NAME OemToAnsi( "Silvio Print" ) PREVIEW
             DEFINE PEN  oPen WIDTH  2  OF oPrn

            PAGE     // printing the circles form
             Print_Numbers(oPrn,oPen,aNumbers,oBrush)
            Print_Ruote(oPrn,oPen,aRoutes,oBrush)


             ENDPAGE

          ENDPRINT

          oBrush:End()
          oPen:End()
    RETURN NIL


    FUNCTION MsgSelect( aItems, cValue, cTitle )
    //------------------------------------------
    LOCAL oDlg

       DEFAULT cTitle := "Please, select"

       DEFINE DIALOG oDlg FROM 5,10 TO 24, 55 TITLE cTitle

       @  1, 7 LISTBOX cValue ITEMS aItems SIZE 70, 90 OF oDlg

       @ 7, 7 BUTTON "&OK" OF oDlg SIZE 40, 12 ;
         ACTION oDlg:End() DEFAULT

       @ 7, 17 BUTTON "&Cancel" OF oDlg SIZE 40, 12 ;
         ACTION ( cValue := nil, oDlg:End() )

       ACTIVATE DIALOG oDlg CENTERED

    RETURN(  val( alltrim( cValue ) ) )


//----------------------------------------------------------------//
Function Print_Numbers(oPrn,oPen,aNumbers,oBrush)
   local n,o
   local nI
   local ntop,nLeft,nBottom,nright,aRect
   local nvar:= 1
   local nRow,nCol


          //circles
           for n := 1 to 9
                   for o := 1 to 10
                      nTop    := _MARGIN_TOP  + ( ( n - 1 ) * _YSPACE )
                      nLeft   := _MARGIN_LEFT + ( ( o - 1 ) * _XSPACE )
                      nBottom := nTop    + _CIRCLE
                      nRight  := nLeft   + _CIRCLE

                      oPrn:Cmtr2Pix( @nTop,    @nLeft  )
                      oPrn:Cmtr2Pix( @nBottom, @nRight )

                      oPrn:Ellipse( nTop, nLeft, nBottom, nRight, oPen )

                   next
                next

          //Numbers

     For nI= 1 to Len(aNumbers)
               nVar:=aNumbers[nI]

                nRow := int( nVar / 10 )
                nCol := ( nVar % 10 )
                if nCol == 0
                   nCol := 10
                else
                   ++nRow
                endif

                nTop    := _MARGIN_TOP  + .1 + ( --nRow  * _YSPACE )    // + .1 to make square smaller than circle
                nLeft   := _MARGIN_LEFT + .1 + ( --nCol  * _XSPACE )    // + .1 to make square smaller than circle
                nBottom := nTop    - .2 + _CIRCLE                       // - .2 to make square smaller than circle
                nRight  := nLeft   - .2 + _CIRCLE                       // - .2 to make square smaller than circle

                oPrn:Cmtr2Pix( @nTop,    @nLeft  )
                oPrn:Cmtr2Pix( @nBottom, @nRight )

                aRect := { nTop,  nLeft , nBottom , nRight }
                oPrn:FillRect( aRect, oBrush )
               Next

  return nil
//----------------------------------------------------------------------//
  #define _MARGIN_WITH  9
  #define _SQUARE        0.4  // each circle has 2 mm in diameter

Function Print_Ruote(oPrn,oPen,aRoutes,oBrush)
   local n,o
   local ntop,nLeft,nBottom,nright,aRect
   local nI
   local nvar:= 1
   local nRow,nCol


      for n := 1 to 12
                   for o := 1 to 1
                     nTop    := _MARGIN_TOP  + ( ( n - 2 ) * _YSPACE -0.2)
                      nLeft   :=_MARGIN_WITH + ( ( o - 1 ) * _XSPACE )
                      nBottom := nTop    + _SQUARE
                      nRight  := nLeft   + _SQUARE

                      oPrn:Cmtr2Pix( @nTop,    @nLeft  )
                      oPrn:Cmtr2Pix( @nBottom, @nRight )

                    *  oPrn:Ellipse( nTop, nLeft, nBottom, nRight, oPen )
                    *oPrn:Box( nTop, nLeft, nBottom, nRight, oPen)
                     oPrn:RoundBox( nTop, nLeft, nBottom, nRight, _SQUARE, _SQUARE, oPen)
                  next
                next



           For nI= 1 to Len(aRoutes)
               nVar:=aRoutes[nI]
                nRow := int( nVar / 10 )
                nCol := ( nVar % 1 )
                if nCol == 0
                   nCol := 1
                else
                   ++nRow
                endif

                nTop    := _MARGIN_TOP  + .1 + ( --nRow  * _YSPACE - 0.2)    // + .1 to make square smaller than circle
                nLeft   := _MARGIN_WITH  + .1 + ( --nCol  * _XSPACE )    // + .1 to make square smaller than circle
                nBottom := nTop    - .2 + _SQUARE                       // - .2 to make square smaller than circle
                nRight  := nLeft   - .2 + _SQUARE                       // - .2 to make square smaller than circle

                oPrn:Cmtr2Pix( @nTop,    @nLeft  )
                oPrn:Cmtr2Pix( @nBottom, @nRight )

                aRect := { nTop,  nLeft , nBottom , nRight }
                oPrn:FillRect( aRect, oBrush )
               Next

     return nil
 


Now I 'm trying to print the second section ( routes) you see in this picture

Image

what I don't understand is that there are 12 boxes but in the end the last box is at the same height as circle n. 90


I tried to set the coordinates

#define _MARGIN_WITH 9
#define _SQUARE 0.4 // each box has 2 mm in with

there are 12 box on 1 column
the first Box top is on the top of the circle I had calculate - 0.2

Code: Select all  Expand view
 
 for n := 1 to 12
                   for o := 1 to 1
                     nTop    := _MARGIN_TOP  + ( ( n - 2 ) * _YSPACE -0.2)
                      nLeft   :=_MARGIN_WITH + ( ( o - 1 ) * _XSPACE )
                      nBottom := nTop    + _SQUARE
                      nRight  := nLeft   + _SQUARE

                      oPrn:Cmtr2Pix( @nTop,    @nLeft  )
                      oPrn:Cmtr2Pix( @nBottom, @nRight )

                    *  oPrn:Ellipse( nTop, nLeft, nBottom, nRight, oPen )
                    *oPrn:Box( nTop, nLeft, nBottom, nRight, oPen)
                     oPrn:RoundBox( nTop, nLeft, nBottom, nRight, _SQUARE, _SQUARE, oPen)
                  next
                next
 



But Not run ok as you can see here

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: print pixels in certain positions

Postby Detlef » Sun Mar 20, 2022 4:41 pm

Hi Silvio,

the routs problem is much easier for there is only one column.
Try with the the following:

Code: Select all  Expand view
#include "FiveWin.ch"

#define _MARGIN_LEFT   0.8  // the circle pattern starts 8 mm from Top
#define _MARGIN_TOP    2.7  // the circle pattern starts  2.7 mm from Left
#define _XSPACE            0.7  // distance horizontal between 2 circles
#define _YSPACE            0.7  // distance vertical   between 2 circles
#define _CIRCLE            0.5  // each circle has 5 mm in diameter


FUNCTION Main()
//-------------
LOCAL n, o
LOCAL oPrn, oPen, oBrush
LOCAL nTop, nLeft, nBottom, nRight, aRect

LOCAL nVar := 1   // as lotto number
LOCAL nRow := 0   // row to find
LOCAL nCol := 0   // col to find

LOCAL aNumbers:= {}  //as DEMO  silvio
LOCAL aRoutes:= {}   //as DEMO  silvio


      aNumbers := { 30, 54, 17, 18, 81 }  //as DEMO silvio
      aRoutes  := {  1,  5,  7 }          //as DEMO silvio

      DEFINE BRUSH oBrush COLOR CLR_BLACK

      PRINT oPrn NAME OemToAnsi( "Silvio Print" ) PREVIEW
         DEFINE PEN  oPen WIDTH  2  OF oPrn

        PAGE     // printing the circles form
            Print_Numbers( oPrn, oPen, aNumbers, oBrush )
            Print_Ruote( oPrn, oPen, aRoutes, oBrush )
         ENDPAGE
      ENDPRINT

      oBrush:End()
      oPen:End()
RETURN NIL

FUNCTION Print_Numbers(oPrn,oPen,aNumbers,oBrush)
//-----------------------------------------------
LOCAL n, o
LOCAL nI
LOCAL nTop, nLeft, nBottom, nRight, aRect
LOCAL nVar := 1
LOCAL nRow, nCol


      //circles
      for n := 1 to 9
         for o := 1 to 10
            nTop    := _MARGIN_TOP  + ( ( n - 1 ) * _YSPACE )
            nLeft   := _MARGIN_LEFT + ( ( o - 1 ) * _XSPACE )
            nBottom := nTop    + _CIRCLE
            nRight  := nLeft   + _CIRCLE

            oPrn:Cmtr2Pix( @nTop,    @nLeft  )
            oPrn:Cmtr2Pix( @nBottom, @nRight )

            oPrn:Ellipse( nTop, nLeft, nBottom, nRight, oPen )
         next
      next

      //Numbers

      for nI := 1 to len( aNumbers )
         nVar := aNumbers[ nI ]

         nRow := int( nVar / 10 )
         nCol := ( nVar % 10 )
         if nCol == 0
            nCol := 10
         else
            ++nRow
         endif

         nTop    := _MARGIN_TOP  + .1 + ( --nRow  * _YSPACE )    // + .1 to make square smaller than circle
         nLeft   := _MARGIN_LEFT + .1 + ( --nCol  * _XSPACE )     // + .1 to make square smaller than circle
         nBottom := nTop    - .2 + _CIRCLE                                 // - .2 to make square smaller than circle
         nRight  := nLeft   - .2 + _CIRCLE                                   // - .2 to make square smaller than circle

         oPrn:Cmtr2Pix( @nTop,    @nLeft  )
         oPrn:Cmtr2Pix( @nBottom, @nRight )

         aRect := { nTop,  nLeft , nBottom , nRight }
         oPrn:FillRect( aRect, oBrush )
      next

RETURN NIL

#define _SQUARE_LEFT   9       // left margin for route block
#define _SQUARE_SIZE   0.35  // each circle has 2 mm in diameter
#define _SQUARE_DIST   0.52  // space from top of one square to top of next square
#define _SQUARE_RAD    1.2   // radius of round corners


FUNCTION Print_Ruote( oPrn, oPen, aRoutes, oBrush )
//-------------------------------------------------
LOCAL n, o
LOCAL nTop, nLeft, nBottom, nRight, aRect
LOCAL nVar  := 1
LOCAL nRow, nCol
LOCAL nRadH := _SQUARE_RAD * ( 10 * oPrn:nHorzRes() / oPRn:nHorzSize() ) / 10 // radius for round boxes in printer resolution horizontal
LOCAL nRadV := _SQUARE_RAD * ( 10 * oPrn:nVertRes()  / oPrn:nVertSize() )  / 10 // radius for round boxes in printer resolution vertical



   for n := 1 to 12

      nTop    := _SQUARE_LEFT                                   // these 2 lines work for me because my FWH version has a glitch exchanging nTop with nLeft for oPrn:RoundBox
      nLeft   := _MARGIN_TOP  + ( ( n - 1 ) * _SQUARE_DIST )
/*
      nTop    := _MARGIN_TOP  + ( ( n - 1 ) * _SQUARE_DIST )   // if you have a newer FWH version than me take the 2 lines here
      nLeft   := _SQUARE_LEFT
 */

      nBottom := nTop    + _SQUARE_SIZE
      nRight  := nLeft   + _SQUARE_SIZE

      oPrn:Cmtr2Pix( @nTop,    @nLeft  )
      oPrn:Cmtr2Pix( @nBottom, @nRight )

      oPrn:RoundBox( nTop, nLeft, nBottom, nRight, nRadH, nRadV, oPen )
   next

   for o = 1 to len( aRoutes )
      nVar := aRoutes[ o ]
      nRow := ( nVar - 1 ) * _SQUARE_DIST

      nTop    := _MARGIN_TOP + nRow + .1
      nLeft   := _SQUARE_LEFT + .1
      nBottom := nTop  + _SQUARE_SIZE - .2
      nRight  := nLeft + _SQUARE_SIZE - .2

      oPrn:Cmtr2Pix( @nTop,    @nLeft  )
      oPrn:Cmtr2Pix( @nBottom, @nRight )

      aRect := { nTop,  nLeft , nBottom , nRight }
      oPrn:FillRect( aRect, oBrush )
   next
RETURN NIL
 
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: print pixels in certain positions

Postby Silvio.Falconi » Sun Mar 20, 2022 5:58 pm

Detlef wrote:Hi Silvio,

the routs problem is much easier for there is only one column.
Try with the the following:

Code: Select all  Expand view
#include "FiveWin.ch"

#define _MARGIN_LEFT   0.8  // the circle pattern starts 8 mm from Top
#define _MARGIN_TOP    2.7  // the circle pattern starts  2.7 mm from Left
#define _XSPACE            0.7  // distance horizontal between 2 circles
#define _YSPACE            0.7  // distance vertical   between 2 circles
#define _CIRCLE            0.5  // each circle has 5 mm in diameter


FUNCTION Main()
//-------------
LOCAL n, o
LOCAL oPrn, oPen, oBrush
LOCAL nTop, nLeft, nBottom, nRight, aRect

LOCAL nVar := 1   // as lotto number
LOCAL nRow := 0   // row to find
LOCAL nCol := 0   // col to find

LOCAL aNumbers:= {}  //as DEMO  silvio
LOCAL aRoutes:= {}   //as DEMO  silvio


      aNumbers := { 30, 54, 17, 18, 81 }  //as DEMO silvio
      aRoutes  := {  1,  5,  7 }          //as DEMO silvio

      DEFINE BRUSH oBrush COLOR CLR_BLACK

      PRINT oPrn NAME OemToAnsi( "Silvio Print" ) PREVIEW
         DEFINE PEN  oPen WIDTH  2  OF oPrn

        PAGE     // printing the circles form
            Print_Numbers( oPrn, oPen, aNumbers, oBrush )
            Print_Ruote( oPrn, oPen, aRoutes, oBrush )
         ENDPAGE
      ENDPRINT

      oBrush:End()
      oPen:End()
RETURN NIL

FUNCTION Print_Numbers(oPrn,oPen,aNumbers,oBrush)
//-----------------------------------------------
LOCAL n, o
LOCAL nI
LOCAL nTop, nLeft, nBottom, nRight, aRect
LOCAL nVar := 1
LOCAL nRow, nCol


      //circles
      for n := 1 to 9
         for o := 1 to 10
            nTop    := _MARGIN_TOP  + ( ( n - 1 ) * _YSPACE )
            nLeft   := _MARGIN_LEFT + ( ( o - 1 ) * _XSPACE )
            nBottom := nTop    + _CIRCLE
            nRight  := nLeft   + _CIRCLE

            oPrn:Cmtr2Pix( @nTop,    @nLeft  )
            oPrn:Cmtr2Pix( @nBottom, @nRight )

            oPrn:Ellipse( nTop, nLeft, nBottom, nRight, oPen )
         next
      next

      //Numbers

      for nI := 1 to len( aNumbers )
         nVar := aNumbers[ nI ]

         nRow := int( nVar / 10 )
         nCol := ( nVar % 10 )
         if nCol == 0
            nCol := 10
         else
            ++nRow
         endif

         nTop    := _MARGIN_TOP  + .1 + ( --nRow  * _YSPACE )    // + .1 to make square smaller than circle
         nLeft   := _MARGIN_LEFT + .1 + ( --nCol  * _XSPACE )     // + .1 to make square smaller than circle
         nBottom := nTop    - .2 + _CIRCLE                                 // - .2 to make square smaller than circle
         nRight  := nLeft   - .2 + _CIRCLE                                   // - .2 to make square smaller than circle

         oPrn:Cmtr2Pix( @nTop,    @nLeft  )
         oPrn:Cmtr2Pix( @nBottom, @nRight )

         aRect := { nTop,  nLeft , nBottom , nRight }
         oPrn:FillRect( aRect, oBrush )
      next

RETURN NIL

#define _SQUARE_LEFT   9       // left margin for route block
#define _SQUARE_SIZE   0.35  // each circle has 2 mm in diameter
#define _SQUARE_DIST   0.52  // space from top of one square to top of next square
#define _SQUARE_RAD    1.2   // radius of round corners


FUNCTION Print_Ruote( oPrn, oPen, aRoutes, oBrush )
//-------------------------------------------------
LOCAL n, o
LOCAL nTop, nLeft, nBottom, nRight, aRect
LOCAL nVar  := 1
LOCAL nRow, nCol
LOCAL nRadH := _SQUARE_RAD * ( 10 * oPrn:nHorzRes() / oPRn:nHorzSize() ) / 10 // radius for round boxes in printer resolution horizontal
LOCAL nRadV := _SQUARE_RAD * ( 10 * oPrn:nVertRes()  / oPrn:nVertSize() )  / 10 // radius for round boxes in printer resolution vertical



   for n := 1 to 12

      nTop    := _SQUARE_LEFT                                   // these 2 lines work for me because my FWH version has a glitch exchanging nTop with nLeft for oPrn:RoundBox
      nLeft   := _MARGIN_TOP  + ( ( n - 1 ) * _SQUARE_DIST )
/*
      nTop    := _MARGIN_TOP  + ( ( n - 1 ) * _SQUARE_DIST )   // if you have a newer FWH version than me take the 2 lines here
      nLeft   := _SQUARE_LEFT
 */

      nBottom := nTop    + _SQUARE_SIZE
      nRight  := nLeft   + _SQUARE_SIZE

      oPrn:Cmtr2Pix( @nTop,    @nLeft  )
      oPrn:Cmtr2Pix( @nBottom, @nRight )

      oPrn:RoundBox( nTop, nLeft, nBottom, nRight, nRadH, nRadV, oPen )
   next

   for o = 1 to len( aRoutes )
      nVar := aRoutes[ o ]
      nRow := ( nVar - 1 ) * _SQUARE_DIST

      nTop    := _MARGIN_TOP + nRow + .1
      nLeft   := _SQUARE_LEFT + .1
      nBottom := nTop  + _SQUARE_SIZE - .2
      nRight  := nLeft + _SQUARE_SIZE - .2

      oPrn:Cmtr2Pix( @nTop,    @nLeft  )
      oPrn:Cmtr2Pix( @nBottom, @nRight )

      aRect := { nTop,  nLeft , nBottom , nRight }
      oPrn:FillRect( aRect, oBrush )
   next
RETURN NIL
 



Dear friend,
the boxes are 12 but on vertical I have this ( your source)

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: print pixels in certain positions

Postby Detlef » Sun Mar 20, 2022 6:04 pm

Silvio,
Look at the source code.
I wrote there a comment to exchange 2 lines of code if you have an other version of FiveWin.
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: print pixels in certain positions

Postby Silvio.Falconi » Sun Mar 20, 2022 6:25 pm

Detlef wrote:Silvio,
Look at the source code.
I wrote there a comment to exchange 2 lines of code if you have an other version of FiveWin.


Sorry I saw now !!!
Image

only I put the image on
PrintImage(0.5,0,10,21,"002.jpg",oPrn)


I not Know if your version of fwh run this

Code: Select all  Expand view
Function PrintImage(nTop,nLeft,nRight,nBottom,cFile,oPrn)
    local lStretch :=.f.
    local nAlpha:=0
    local lTransp:= .f.
    local lGray  := .f.

          oPrn:Cmtr2Pix( @nTop,    @nLeft  )
          oPrn:Cmtr2Pix( @nBottom, @nRight )
          oPrn:PrintImage( nTop,  nLeft,cFile,nRight,nBottom, lStretch, nAlpha, lTransp, lGray )

//  oPrn:SayImage( nTop,  nLeft,cFile,nRight,nBottom)
// oPrn:SayBitmap(nTop,  nLeft,cFile,nRight,nBottom)
  return nil


002.jpg
Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: print pixels in certain positions

Postby Detlef » Sun Mar 20, 2022 7:00 pm

Dear Silvio,
It looks like you will have to play with the #define values of
_MARGIN_LEFT, _MARGIN_TOP, _SQUARE_LEFT and _SQUARE_DIST to adjust the printing to your image.
Maybe the vertical squares need an own 'margin top'.
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: print pixels in certain positions

Postby Silvio.Falconi » Sun Mar 20, 2022 7:14 pm

Detlef wrote:Dear Silvio,
It looks like you will have to play with the #define values of
_MARGIN_LEFT, _MARGIN_TOP, _SQUARE_LEFT and _SQUARE_DIST to adjust the printing to your image.
Maybe the vertical squares need an own 'margin top'.


ok but it eas only a test because i not know how it can print on receipt, this evening I have problem with my printer I80 canon

I have a problem with my Canon I80 printer, I broke a wheel and I have to take it apart. It has already happened another time, it is a plastic wheel that I have to buy on ebay.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: print pixels in certain positions

Postby Silvio.Falconi » Thu Mar 24, 2022 5:47 pm

Detlef wrote:Dear Silvio,
It looks like you will have to play with the #define values of
_MARGIN_LEFT, _MARGIN_TOP, _SQUARE_LEFT and _SQUARE_DIST to adjust the printing to your image.
Maybe the vertical squares need an own 'margin top'.


Image

Note
on number can go good
on routes there is some error on last 2 positions
I not change the source only the set

Code: Select all  Expand view
#define _MARGIN_LEFT   0.9  // the circle pattern starts 8 mm from Top
    #define _MARGIN_TOP    2.78  // the circle pattern starts  2.7 mm from Left
    #define _XSPACE            0.7  // distance horizontal between 2 circles
    #define _YSPACE            0.7  // distance vertical   between 2 circles
    #define _CIRCLE            0.5  // each circle has 5 mm in diameter

    #define _SQUARE_LEFT   9.2     // left margin for route block
    #define _SQUARE_SIZE   0.35  // each circle has 2 mm in diameter
    #define _SQUARE_DIST   0.52  // space from top of one square to top of next square
    #define _SQUARE_RAD    1.2   // radius of round corners
 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 80 guests