removing dashed lines

If you have any questions regarding Quartam PDF Library for LiveCode, this is the place to get answers from your fellow users - experts and newbies alike.
Post Reply
Scott_Morrow
Posts: 3
Joined: Wed Aug 23, 2017 12:16 pm

removing dashed lines

Post by Scott_Morrow » Wed Aug 23, 2017 12:24 pm

After setting line options with

qrtPDF_SetLineOptions tDocRef,"round","miter","0,2",1

I can't work out how to go back to using solid lines.

Quartam PDF Lib 1.1.5
LC 8.1.6 business

Scott Morrow

JanSchenkel
Site Admin
Posts: 110
Joined: Sun Jul 18, 2010 5:21 pm
Location: Aalst, Belgium
Contact:

Re: removing dashed lines

Post by JanSchenkel » Wed Aug 23, 2017 8:30 pm

Hi Scott,

That's an excellent question, indeed. And it looks like there's no clean way to revert to a solid line without changing the library source.

So here's the quick work-around:

Code: Select all

qrtPDF_SetLineOptions tDocRef, "round", "miter", "1,0", 0
For a better solution, here's how you can patch the library script:
  1. Update command 'p_qrtPDF_AssertDashes' as follows

    Code: Select all

    private command p_qrtPDF_AssertDashes @pDashes
       if pDashes is "solid" then exit p_qrtPDF_AssertDashes
       replace space with empty in pDashes
       repeat for each item tDash in pDashes
          if tDash is not an integer then throw "qrtPDFErr: invalid dashes"
       end repeat
    end p_qrtPDF_AssertDashes
  2. Update command 'qrtPDF_SetLineOptions' as follows

    Code: Select all

    command qrtPDF_SetLineOptions pDocID, pCap, pJoin, pDashes, pPhase
       p_qrtPDF_AssertDocID pDocID
       p_qrtPDF_AssertCap pCap
       p_qrtPDF_AssertJoin pJoin
       p_qrtPDF_AssertDashes pDashes
       if pPhase is empty or pPhase is "solid" then put 0 into pPhase
       p_qrtPDF_AssertNumber "phase", pPhase
       --
       put pCap into sDocumentsA[pDocID][kp_LineCap]
       put pJoin into sDocumentsA[pDocID][kp_LineJoin]
       put pDashes into sDocumentsA[pDocID][kp_LineDashes]
       put pPhase into sDocumentsA[pDocID][kp_LinePhase]
       switch pCap
          case "butt"
             p_qrtPDF_ATB pDocID, "0 J"
             break
          case "join"
             p_qrtPDF_ATB pDocID, "1 J"
             break
          case "square"
             p_qrtPDF_ATB pDocID, "2 J"
             break
       end switch
       switch pJoin
          case "miter"
             p_qrtPDF_ATB pDocID, "0 j"
             break
          case "round"
             p_qrtPDF_ATB pDocID, "1 j"
             break
          case "bevel"
             p_qrtPDF_ATB pDocID, "2 j"
             break
       end switch
       if pDashes is "solid" then
          p_qrtPDF_ATB pDocID, "[] 0 d"
       else if pDashes is not empty then
          local tDashes
          repeat for each item tDash in pDashes
             put format("%2.f", tDash) & space after tDashes
          end repeat
          delete char -1 of tDashes
          p_qrtPDF_ATB pDocID, format("[%s] %2.f d", tDashes, pPhase)
       end if
    end qrtPDF_SetLineOptions
And then you can revert to a solid line with the following command call:

Code: Select all

qrtPDF_SetLineOptions tDocRef, "round", "miter", "solid"
I'll include the "solid" approach in the next revision of the library.

Cheers,

Jan Schenkel.
Quartam Developer Tools for LiveCode
http://www.quartam.com

Scott_Morrow
Posts: 3
Joined: Wed Aug 23, 2017 12:16 pm

Re: removing dashed lines

Post by Scott_Morrow » Wed Aug 23, 2017 9:45 pm

Hello Jan,

Wonderful! I eventually figured out the workaround but I will implement your patch. Thanks for this amazing library!

Scott Morrow

Post Reply