Skip to content

Commit

Permalink
Merge pull request psychopy#6865 from TEParsons/release-bf-shape-bp-js
Browse files Browse the repository at this point in the history
BF: Fix error writing Polygon initial colors in JS
  • Loading branch information
TEParsons authored Sep 20, 2024
2 parents ab3e33a + 713ea1f commit 9d6e86a
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions psychopy/experiment/components/polygon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,28 +293,27 @@ def writeInitCodeJS(self, buff):
if self.params['interpolate'].val != 'linear':
interpolate = 'false'

code += (" ori: {ori}, \n"
" pos: {pos}, \n"
" draggable: {draggable}, \n"
" anchor: {anchor},\n"
" lineWidth: {lineWidth}, \n"
" colorSpace: {colorSpace},\n")

if inits['lineColor'] == 'undefined':
code += " lineColor: {lineColor},\n"
else:
code += " lineColor: new util.Color({lineColor}),\n"

if inits['fillColor'] == 'undefined':
code += " fillColor: {fillColor},\n"
else:
code += " fillColor: new util.Color({fillColor}),\n"


code += ( " fillColor: {fillColor},\n"
" opacity: {opacity}, depth: {depth}, interpolate: {interpolate},\n"
"}});\n\n")

# make a util.Color object for non-transparent
for key in ("fillColor", "lineColor"):
if inits[key].val != "undefined":
inits[key].val = "new util.Color(%s)" % inits[key]
inits[key].valType = "code"
# add other params
code += (
" ori: {ori}, \n"
" pos: {pos}, \n"
" draggable: {draggable}, \n"
" anchor: {anchor}, \n"
" lineWidth: {lineWidth}, \n"
" lineColor: {lineColor}, \n"
" fillColor: {fillColor}, \n"
" colorSpace: {colorSpace}, \n"
" opacity: {opacity}, \n"
" depth: {depth}, \n"
" interpolate: {interpolate}, \n"
"}});\n"
"\n"
)
buff.writeIndentedLines(code.format(name=inits['name'],
unitsStr=unitsStr,
anchor=inits['anchor'],
Expand Down

0 comments on commit 9d6e86a

Please sign in to comment.