• How to ensure line widths are the same vertically and horizontally?

    From Eremey Valetov@eremeyvvaletov@gmail.com to comp.lang.postscript on Tue Oct 6 02:55:58 2020
    From Newsgroup: comp.lang.postscript

    Hello All,
    The width of a line in PostScript is defined in terms of distances in the user space. In my use case, the aspect ratio of the device space (e.g. 4:3) is different from the aspect ratio of the user space (e.g. 1:1), which causes the line widths in the device space to be different in vertical and horizontal directions.
    How to make line widths the same regardless of the line orientation? The PostScript Language Reference Manual for setlinewidth mentions that if the current transformation matrix (CTM) in effect at the time of the stroke specifies scaling by different factors in the x and y dimensions, then thickness of the lines can vary.
    Does this mean that if I set a CTM with the same scaling factor in x and y dimensions before calling stroke and them reset the CTM to the value used elsewhere in the PostScript file, the line widths will be the same without affecting anything else?
    Thanks,
    Eremey
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Jeffrey H. Coffield@jeffrey@digitalsynergyinc.com to comp.lang.postscript on Tue Oct 6 09:00:46 2020
    From Newsgroup: comp.lang.postscript



    On 10/06/2020 02:55 AM, Eremey Valetov wrote:
    Hello All,

    The width of a line in PostScript is defined in terms of distances in the user space. In my use case, the aspect ratio of the device space (e.g. 4:3) is different from the aspect ratio of the user space (e.g. 1:1), which causes the line widths in the device space to be different in vertical and horizontal directions.

    How to make line widths the same regardless of the line orientation? The PostScript Language Reference Manual for setlinewidth mentions that if the current transformation matrix (CTM) in effect at the time of the stroke specifies scaling by different factors in the x and y dimensions, then thickness of the lines can vary.

    Does this mean that if I set a CTM with the same scaling factor in x and y dimensions before calling stroke and them reset the CTM to the value used elsewhere in the PostScript file, the line widths will be the same without affecting anything else?

    Thanks,
    Eremey

    Without writing a test case, it would seem to me that changing the scale factor would not change the line width, but also the line position. Do
    you have a sample .ps file that demonstrates what you want to acheive?

    Jeff Coffield
    www.digitalsynergyinc.com
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From luser droog@luser.droog@gmail.com to comp.lang.postscript on Tue Oct 6 11:04:01 2020
    From Newsgroup: comp.lang.postscript

    On Tuesday, October 6, 2020 at 4:56:00 AM UTC-5, Eremey Valetov wrote:
    Hello All,

    The width of a line in PostScript is defined in terms of distances in the user space. In my use case, the aspect ratio of the device space (e.g. 4:3) is different from the aspect ratio of the user space (e.g. 1:1), which causes the line widths in the device space to be different in vertical and horizontal directions.

    How to make line widths the same regardless of the line orientation? The PostScript Language Reference Manual for setlinewidth mentions that if the current transformation matrix (CTM) in effect at the time of the stroke specifies scaling by different factors in the x and y dimensions, then thickness of the lines can vary.

    Does this mean that if I set a CTM with the same scaling factor in x and y dimensions before calling stroke and them reset the CTM to the value used elsewhere in the PostScript file, the line widths will be the same without affecting anything else?

    Thanks,
    Eremey
    You can start with a uniform scaling matrix
    4 4 matrix scale
    And then multiply it by the inverse of the CTM
    matrix currentmatrix matrix invertmatrix matrix concatmatrix
    Now if you `concat` this matrix onto the CTM, then the CTM will become
    exactly the uniform scaling matrix created on the first line.
    hth
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From luser droog@luser.droog@gmail.com to comp.lang.postscript on Tue Oct 6 16:35:48 2020
    From Newsgroup: comp.lang.postscript

    On Tuesday, October 6, 2020 at 1:04:03 PM UTC-5, luser droog wrote:
    On Tuesday, October 6, 2020 at 4:56:00 AM UTC-5, Eremey Valetov wrote:
    Hello All,

    The width of a line in PostScript is defined in terms of distances in the user space. In my use case, the aspect ratio of the device space (e.g. 4:3) is different from the aspect ratio of the user space (e.g. 1:1), which causes the line widths in the device space to be different in vertical and horizontal directions.

    How to make line widths the same regardless of the line orientation? The PostScript Language Reference Manual for setlinewidth mentions that if the current transformation matrix (CTM) in effect at the time of the stroke specifies scaling by different factors in the x and y dimensions, then thickness of the lines can vary.

    Does this mean that if I set a CTM with the same scaling factor in x and y dimensions before calling stroke and them reset the CTM to the value used elsewhere in the PostScript file, the line widths will be the same without affecting anything else?

    Thanks,
    Eremey

    You can start with a uniform scaling matrix

    4 4 matrix scale

    And then multiply it by the inverse of the CTM

    matrix currentmatrix matrix invertmatrix matrix concatmatrix

    Now if you `concat` this matrix onto the CTM, then the CTM will become exactly the uniform scaling matrix created on the first line.

    hth
    Ugh. Made it too complicated.
    matrix currentmatrix
    4 4 matrix scale setmatrix
    stroke
    setmatrix
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Eremey Valetov@eremeyvvaletov@gmail.com to comp.lang.postscript on Wed Oct 7 03:38:24 2020
    From Newsgroup: comp.lang.postscript

    On Tuesday, October 6, 2020 at 11:00:50 AM UTC-5, Jeffrey H. Coffield wrote:
    On 10/06/2020 02:55 AM, Eremey Valetov wrote:
    Hello All,

    The width of a line in PostScript is defined in terms of distances in the user space. In my use case, the aspect ratio of the device space (e.g. 4:3) is different from the aspect ratio of the user space (e.g. 1:1), which causes the line widths in the device space to be different in vertical and horizontal directions.

    How to make line widths the same regardless of the line orientation? The PostScript Language Reference Manual for setlinewidth mentions that if the current transformation matrix (CTM) in effect at the time of the stroke specifies scaling by different factors in the x and y dimensions, then thickness of the lines can vary.

    Does this mean that if I set a CTM with the same scaling factor in x and y dimensions before calling stroke and them reset the CTM to the value used elsewhere in the PostScript file, the line widths will be the same without affecting anything else?

    Thanks,
    Eremey

    Without writing a test case, it would seem to me that changing the scale factor would not change the line width, but also the line position. Do
    you have a sample .ps file that demonstrates what you want to acheive?

    Jeff Coffield
    www.digitalsynergyinc.com
    Hi Jeff,
    I placed the original version of a test case "pic002_old.ps" and a new version "pic002_new.ps", where the issue of non-uniform line widths is fixed, to this filebin:
    https://filebin.net/1ih1vywlu9ep2hoz
    I resolved the issue by replacing "/sn {stroke newpath} bind def" with "/sn {gsave 1 1.1 scale stroke newpath grestore} bind def".
    Thanks,
    Eremey
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Eremey Valetov@eremeyvvaletov@gmail.com to comp.lang.postscript on Wed Oct 7 03:43:24 2020
    From Newsgroup: comp.lang.postscript

    On Tuesday, October 6, 2020 at 11:00:50 AM UTC-5, Jeffrey H. Coffield wrote:
    On 10/06/2020 02:55 AM, Eremey Valetov wrote:
    Hello All,

    The width of a line in PostScript is defined in terms of distances in the user space. In my use case, the aspect ratio of the device space (e.g. 4:3) is different from the aspect ratio of the user space (e.g. 1:1), which causes the line widths in the device space to be different in vertical and horizontal directions.

    How to make line widths the same regardless of the line orientation? The PostScript Language Reference Manual for setlinewidth mentions that if the current transformation matrix (CTM) in effect at the time of the stroke specifies scaling by different factors in the x and y dimensions, then thickness of the lines can vary.

    Does this mean that if I set a CTM with the same scaling factor in x and y dimensions before calling stroke and them reset the CTM to the value used elsewhere in the PostScript file, the line widths will be the same without affecting anything else?

    Thanks,
    Eremey

    Without writing a test case, it would seem to me that changing the scale factor would not change the line width, but also the line position. Do
    you have a sample .ps file that demonstrates what you want to acheive?

    Jeff Coffield
    www.digitalsynergyinc.com
    Hi Jeff,
    I placed the original version of the test case "pic002_old.ps" and a new version "pic002_new.ps", where the issue of non-uniform line widths is fixed, in the following filebin:
    https://filebin.net/1ih1vywlu9ep2hoz
    I resolved the issue by replacing "/sn {newpath} bind def" with "/sn {gsave 1 1.5 scale stroke newpath grestore} bind def".
    Thanks,
    Eremey
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Eremey Valetov@eremeyvvaletov@gmail.com to comp.lang.postscript on Wed Oct 7 03:48:39 2020
    From Newsgroup: comp.lang.postscript

    On Tuesday, October 6, 2020 at 6:35:50 PM UTC-5, luser droog wrote:
    On Tuesday, October 6, 2020 at 1:04:03 PM UTC-5, luser droog wrote:
    On Tuesday, October 6, 2020 at 4:56:00 AM UTC-5, Eremey Valetov wrote:
    Hello All,

    The width of a line in PostScript is defined in terms of distances in the user space. In my use case, the aspect ratio of the device space (e.g. 4:3) is different from the aspect ratio of the user space (e.g. 1:1), which causes the line widths in the device space to be different in vertical and horizontal directions.

    How to make line widths the same regardless of the line orientation? The PostScript Language Reference Manual for setlinewidth mentions that if the current transformation matrix (CTM) in effect at the time of the stroke specifies scaling by different factors in the x and y dimensions, then thickness of the lines can vary.

    Does this mean that if I set a CTM with the same scaling factor in x and y dimensions before calling stroke and them reset the CTM to the value used elsewhere in the PostScript file, the line widths will be the same without affecting anything else?

    Thanks,
    Eremey

    You can start with a uniform scaling matrix

    4 4 matrix scale

    And then multiply it by the inverse of the CTM

    matrix currentmatrix matrix invertmatrix matrix concatmatrix

    Now if you `concat` this matrix onto the CTM, then the CTM will become exactly the uniform scaling matrix created on the first line.

    hth
    Ugh. Made it too complicated.

    matrix currentmatrix
    4 4 matrix scale setmatrix
    stroke
    setmatrix
    Hi luser droog,
    Thanks! This fixed the issue with something like
    matrix currentmatrix
    750 750 matrix scale setmatrix
    stroke
    setmatrix
    Because this requires knowing the horizontal size of the device space, which happens to be 750, I settled on this solution:
    gsave 1 1.5 scale stroke newpath grestore
    By the way, while this does resolve the issue in PostScript, in PDF this also results in the line coordinates being scaled vertically by the same coefficient 1.5. What would be a good place to ask the respective question about PDF?
    Thanks,
    Eremey
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From luser droog@luser.droog@gmail.com to comp.lang.postscript on Wed Oct 7 08:40:53 2020
    From Newsgroup: comp.lang.postscript

    On Wednesday, October 7, 2020 at 5:48:40 AM UTC-5, Eremey Valetov wrote:
    On Tuesday, October 6, 2020 at 6:35:50 PM UTC-5, luser droog wrote:
    On Tuesday, October 6, 2020 at 1:04:03 PM UTC-5, luser droog wrote:
    On Tuesday, October 6, 2020 at 4:56:00 AM UTC-5, Eremey Valetov wrote:
    Hello All,

    The width of a line in PostScript is defined in terms of distances in the user space. In my use case, the aspect ratio of the device space (e.g. 4:3) is different from the aspect ratio of the user space (e.g. 1:1), which causes the line widths in the device space to be different in vertical and horizontal directions.

    How to make line widths the same regardless of the line orientation? The PostScript Language Reference Manual for setlinewidth mentions that if the current transformation matrix (CTM) in effect at the time of the stroke specifies scaling by different factors in the x and y dimensions, then thickness of the lines can vary.

    Does this mean that if I set a CTM with the same scaling factor in x and y dimensions before calling stroke and them reset the CTM to the value used elsewhere in the PostScript file, the line widths will be the same without affecting anything else?

    Thanks,
    Eremey

    You can start with a uniform scaling matrix

    4 4 matrix scale

    And then multiply it by the inverse of the CTM

    matrix currentmatrix matrix invertmatrix matrix concatmatrix

    Now if you `concat` this matrix onto the CTM, then the CTM will become exactly the uniform scaling matrix created on the first line.

    hth
    Ugh. Made it too complicated.

    matrix currentmatrix
    4 4 matrix scale setmatrix
    stroke
    setmatrix

    Hi luser droog,

    Thanks! This fixed the issue with something like

    matrix currentmatrix
    750 750 matrix scale setmatrix
    stroke
    setmatrix

    Because this requires knowing the horizontal size of the device space, which happens to be 750, I settled on this solution:

    gsave 1 1.5 scale stroke newpath grestore

    By the way, while this does resolve the issue in PostScript, in PDF this also results in the line coordinates being scaled vertically by the same coefficient 1.5. What would be a good place to ask the respective question about PDF?

    Thanks,
    Eremey
    Maybe swapping 'newpath' and 'grestore'? As it is, grestore will
    resurrect the path that you just discarded.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Eremey Valetov@eremeyvvaletov@gmail.com to comp.lang.postscript on Wed Oct 7 21:21:32 2020
    From Newsgroup: comp.lang.postscript

    On Wednesday, October 7, 2020 at 10:40:55 AM UTC-5, luser droog wrote:
    On Wednesday, October 7, 2020 at 5:48:40 AM UTC-5, Eremey Valetov wrote:
    On Tuesday, October 6, 2020 at 6:35:50 PM UTC-5, luser droog wrote:
    On Tuesday, October 6, 2020 at 1:04:03 PM UTC-5, luser droog wrote:
    On Tuesday, October 6, 2020 at 4:56:00 AM UTC-5, Eremey Valetov wrote:
    Hello All,

    The width of a line in PostScript is defined in terms of distances in the user space. In my use case, the aspect ratio of the device space (e.g. 4:3) is different from the aspect ratio of the user space (e.g. 1:1), which causes the line widths in the device space to be different in vertical and horizontal directions.

    How to make line widths the same regardless of the line orientation? The PostScript Language Reference Manual for setlinewidth mentions that if the current transformation matrix (CTM) in effect at the time of the stroke specifies scaling by different factors in the x and y dimensions, then thickness of the lines can vary.

    Does this mean that if I set a CTM with the same scaling factor in x and y dimensions before calling stroke and them reset the CTM to the value used elsewhere in the PostScript file, the line widths will be the same without affecting anything else?

    Thanks,
    Eremey

    You can start with a uniform scaling matrix

    4 4 matrix scale

    And then multiply it by the inverse of the CTM

    matrix currentmatrix matrix invertmatrix matrix concatmatrix

    Now if you `concat` this matrix onto the CTM, then the CTM will become exactly the uniform scaling matrix created on the first line.

    hth
    Ugh. Made it too complicated.

    matrix currentmatrix
    4 4 matrix scale setmatrix
    stroke
    setmatrix

    Hi luser droog,

    Thanks! This fixed the issue with something like

    matrix currentmatrix
    750 750 matrix scale setmatrix
    stroke
    setmatrix

    Because this requires knowing the horizontal size of the device space, which happens to be 750, I settled on this solution:

    gsave 1 1.5 scale stroke newpath grestore

    By the way, while this does resolve the issue in PostScript, in PDF this also results in the line coordinates being scaled vertically by the same coefficient 1.5. What would be a good place to ask the respective question about PDF?

    Thanks,
    Eremey
    Maybe swapping 'newpath' and 'grestore'? As it is, grestore will
    resurrect the path that you just discarded.
    Thanks, that makes sense. I swapped 'newpath' and 'grestore' in the PostScript code.
    I made the corresponding revision to the PDF code,
    'q 1 0 0 1.5 0 0 cm S Q h',
    but this still has the side effect of vertically scaling the endpoints of the line segments, as pic002.pdf in this Filebin shows:
    https://filebin.net/1pcf0p3pb922nw8k
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From luser droog@luser.droog@gmail.com to comp.lang.postscript on Sat Oct 10 08:13:17 2020
    From Newsgroup: comp.lang.postscript

    On Wednesday, October 7, 2020 at 11:21:34 PM UTC-5, Eremey Valetov wrote:
    On Wednesday, October 7, 2020 at 10:40:55 AM UTC-5, luser droog wrote:
    On Wednesday, October 7, 2020 at 5:48:40 AM UTC-5, Eremey Valetov wrote:
    On Tuesday, October 6, 2020 at 6:35:50 PM UTC-5, luser droog wrote:
    On Tuesday, October 6, 2020 at 1:04:03 PM UTC-5, luser droog wrote:
    On Tuesday, October 6, 2020 at 4:56:00 AM UTC-5, Eremey Valetov wrote:
    Hello All,

    The width of a line in PostScript is defined in terms of distances in the user space. In my use case, the aspect ratio of the device space (e.g. 4:3) is different from the aspect ratio of the user space (e.g. 1:1), which causes the line widths in the device space to be different in vertical and horizontal directions.

    How to make line widths the same regardless of the line orientation? The PostScript Language Reference Manual for setlinewidth mentions that if the current transformation matrix (CTM) in effect at the time of the stroke specifies scaling by different factors in the x and y dimensions, then thickness of the lines can vary.

    Does this mean that if I set a CTM with the same scaling factor in x and y dimensions before calling stroke and them reset the CTM to the value used elsewhere in the PostScript file, the line widths will be the same without affecting anything else?

    Thanks,
    Eremey

    You can start with a uniform scaling matrix

    4 4 matrix scale

    And then multiply it by the inverse of the CTM

    matrix currentmatrix matrix invertmatrix matrix concatmatrix

    Now if you `concat` this matrix onto the CTM, then the CTM will become
    exactly the uniform scaling matrix created on the first line.

    hth
    Ugh. Made it too complicated.

    matrix currentmatrix
    4 4 matrix scale setmatrix
    stroke
    setmatrix

    Hi luser droog,

    Thanks! This fixed the issue with something like

    matrix currentmatrix
    750 750 matrix scale setmatrix
    stroke
    setmatrix

    Because this requires knowing the horizontal size of the device space, which happens to be 750, I settled on this solution:

    gsave 1 1.5 scale stroke newpath grestore

    By the way, while this does resolve the issue in PostScript, in PDF this also results in the line coordinates being scaled vertically by the same coefficient 1.5. What would be a good place to ask the respective question about PDF?

    Thanks,
    Eremey
    Maybe swapping 'newpath' and 'grestore'? As it is, grestore will
    resurrect the path that you just discarded.

    Thanks, that makes sense. I swapped 'newpath' and 'grestore' in the PostScript code.

    I made the corresponding revision to the PDF code,
    'q 1 0 0 1.5 0 0 cm S Q h',
    but this still has the side effect of vertically scaling the endpoints of the line segments, as pic002.pdf in this Filebin shows:
    https://filebin.net/1pcf0p3pb922nw8k
    I looked at the file, but I'm not sure what I'm looking at.
    There is a newsgroup for PDF that maybe can help.
    https://groups.google.com/forum/?oldui=1#!forum/comp.text.pdf
    --- Synchronet 3.21d-Linux NewsLink 1.2