david-pfx / PuzzleScriptNext

A direct successor to PuzzleScript, building on the work of PuzzleScript Plus, Pattern:Script and others.
http://www.puzzlescriptnext.polyomino.com
MIT License
15 stars 6 forks source link

Import object colours into canvas JSON #132

Open david-pfx opened 3 days ago

david-pfx commented 3 days ago

hkmg: It is easy to change the color for normal sprites with tags, but it is troublesome for canvas sprites with tags. Can't we define color1, color2, etc in the first line of canvas sprites the same as what we do in normal sprites? The following serves as an exmaple.

background:red; #f00; canvas:
{"beginPath":[]} {"rect":[0,0,1,1]}
{"fillStyle":"color1"} {"fill":[]}
background:blue; #00f; canvas:
copy: background:red 

For colour, we can use default palette or hex code.

david-pfx commented 2 days ago

Good idea, not too hard, but not happy with the syntax. It needs to be a value that could never conflict with the argument of any function (to avoid having to check the function name), but still must be valid JSON. Also, colours must be numbered from zero.

{"fillStyle":0} {"fill":[]}