Skip to content

Commit

Permalink
Honor text-color, background-color, border-color; fixes StoneCypher/f…
Browse files Browse the repository at this point in the history
…sl#350, fixes StoneCypher/fsl#351, fixes Stonecyher/fsl#352
  • Loading branch information
StoneCypher committed Jan 26, 2020
1 parent 81b755b commit 527d01c
Show file tree
Hide file tree
Showing 15 changed files with 2,487 additions and 174 deletions.
428 changes: 402 additions & 26 deletions dist/jssm-viz.cjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jssm-viz.cjs.js.map

Large diffs are not rendered by default.

428 changes: 402 additions & 26 deletions dist/jssm-viz.es6.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jssm-viz.es6.js.map

Large diffs are not rendered by default.

428 changes: 402 additions & 26 deletions dist/jssm-viz.iife.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jssm-viz.iife.js.map

Large diffs are not rendered by default.

428 changes: 402 additions & 26 deletions docs/jssm-viz.cjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/jssm-viz.cjs.js.map

Large diffs are not rendered by default.

428 changes: 402 additions & 26 deletions docs/jssm-viz.es6.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/jssm-viz.es6.js.map

Large diffs are not rendered by default.

428 changes: 402 additions & 26 deletions docs/jssm-viz.iife.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/jssm-viz.iife.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"del-cli": "^1.1.0",
"documentation": "^12.1.2",
"eslint": "^4.19.1",
"jssm": "^5.23.0",
"jssm": "^5.24.0",
"nyc": "^14.1.1",
"pegjs": "^0.10.0",
"rimraf": "^2.7.1",
Expand Down
71 changes: 64 additions & 7 deletions src/ts/jssm-viz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var viz = new Viz({ Module, render });


function dot_to_svg(dot: string, config? : Object): Promise<string> { // whargarbl jssm isn't an any
return viz.renderString(dot).catch(e => console.log(e));
return viz.renderString(dot).catch(e => console.log(e)); // TODO FIXME better way to export errors
}


Expand Down Expand Up @@ -92,15 +92,70 @@ function color8to6(color8: string): string {



function border_color_for_state(u_jssm, state): string | undefined {

const d_color = u_jssm._state_declarations;
if (!d_color) { return undefined; }

const decls = u_jssm._state_declarations;
if (!decls) { return undefined; }

const state_decl = decls.get(state);
if (!state_decl) { return undefined; }

return state_decl.borderColor;

}





function text_color_for_state(u_jssm, state): string | undefined {

const d_color = u_jssm._state_declarations;
if (!d_color) { return undefined; }

const decls = u_jssm._state_declarations;
if (!decls) { return undefined; }

const state_decl = decls.get(state);
if (!state_decl) { return undefined; }

return state_decl.textColor;

}





function background_color_for_state(u_jssm, state): string | undefined {

const d_color = u_jssm._state_declarations;
if (!d_color) { return undefined; }

const decls = u_jssm._state_declarations;
if (!decls) { return undefined; }

const state_decl = decls.get(state);
if (!state_decl) { return undefined; }

return state_decl.backgroundColor;

}





function states_to_nodes_string(u_jssm, l_states): string {

return l_states.map( (s) => {

const d_color = u_jssm._state_declarations
? (u_jssm._state_declarations.get(s)
? color8to6(u_jssm._state_declarations.get(s).color)
: undefined)
: undefined;
const bordercolor = border_color_for_state(u_jssm, s),
bgcolor = background_color_for_state(u_jssm, s),
fgcolor = text_color_for_state(u_jssm, s);

const this_state = u_jssm.state_for(s),
// opening = u_jssm.state_is_start_state(s), TODO COMEBACK FIXME
Expand All @@ -110,7 +165,9 @@ function states_to_nodes_string(u_jssm, l_states): string {
features = [
['label', s],
['peripheries', complete? 2 : 1 ], // TODO COMEBACK use peripheries for current state instead
['color', d_color || 'black' ],
['color', bordercolor || 'black' ],
['fillcolor', bgcolor || 'white' ],
['fontcolor', fgcolor || 'black' ],
['fillcolor', final ? vc('fill_final') :
(complete? vc('fill_complete') :
(terminal? vc('fill_terminal') :
Expand Down

0 comments on commit 527d01c

Please sign in to comment.