Line of 0 or 90 degrees now shows as a diagonal

OS: Win10
PsychoPy version (e.g. 1.84.x): 2024.2.4 on desktop
What are you trying to achieve?: Horizontal/vertical line
What did you try to make it work?:
Polygon → Line → Layout → Orientation = 0 (default)

What specifically went wrong when you tried that?:
Line is diagonal.
To get a horizontal line displayed, I had to enter 45 as the orientation.
To get a vertical line displayed, I had to enter 135 as the orientation.
In earlier versions, I always used 90 degrees to show a straight vertical line. Updating PsychoPy, the stimuli I had that used to be straight vertical lines are now diagonal.
Creating a new app from the Builder, in the new version, by default the line that displays is diagonal even though the default orientation is 0.



Lines are supposed to have just one size value. Maybe the second one is causing the diagonal.

Shown/run are the default values from using the Builder.
I did try using just one value, in the list – length 1. And this produced a diagonal cutting across the entire screen.
A study I had previously run with an earlier version of PsychoPy, showed vertical lines, as expected, by setting orientation to 90 degrees. Now, when opening that study up, and not making any edit to the line, or screen, etc. other than to update the PsychoPy version, the lines now display as diagonals.

I have a solution for you:

For a horizontal line give it a size of [x,0] and for a vertical line give it a size of [0,x]. These lines were created with the following parameters:

lineLength = [.2,[.2,.2],[.2,0],[0,.2]]
linePos = [[-.2,.2],[.2,.2],[-.2,-.2],[.2,-.2]]

N.B. Only the [x,0] version currently works the same online (thicker lines because I also increased the line width form1 to 5).

Under the hood I can see the reason for the difference:

Python

    line = visual.Line(
        win=win, name='line',
        size=[lineLength[0]],
        ori=0.0, pos=[linePos[0]], draggable=False, anchor='center',
        lineWidth=1.0,
        colorSpace='rgb', lineColor='white', fillColor='white',
        opacity=None, depth=-1.0, interpolate=True)

JS

  line = new visual.ShapeStim ({
    win: psychoJS.window, name: 'line', 
    vertices: [[-lineLength[0][0]/2.0, 0], [+lineLength[0][0]/2.0, 0]],
    ori: 0.0, 
    pos: linePos[0], 
    draggable: false, 
    anchor: 'center', 
    lineWidth: 5.0, 
    lineColor: new util.Color('white'), 
    fillColor: new util.Color('white'), 
    colorSpace: 'rgb', 
    opacity: undefined, 
    depth: -1, 
    interpolate: true, 
  });

PsychoJS doesn’t have visual.Line so uses visual.Shapestim with two vertices based on the first size value.

Interesting workaround. It still seems unfortunate that the orientation (“ori”) parameter can’t be relied on to produce the intended orientation – in the same way between py and js builds; that different values are needed for PsychoPy and PsychoJS to render the same thing.