Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Idea] Dimmerswitch

1608912976

Edited 1608913233
Pat
Pro
API Scripter
Fiddling with the paths again, found out I could set opacity, now it's a question of if I can adjust opacity gradually - and thinking of an SVG/Path only implementation of some simple environmental effects: darkening the entire background, setting it to sunset (darken and slightly red) or a dream version (strange color plus opacity).  Here's a script snippet that puts an SVG overlay over the entire map and sets it to slightly dim (roughly 20% opacity for the black overlay) in the background layer. I was thinking of having it capable of changing gradually over time instead of instantly, and varying up the "target" color and opacity. Opacity is in hex, so the 20/40/60/80/100 equivalents are roughly 33/66/99/CC/FF var opacity = "33"; // on("ready", function(){ let pageObj = getObj("page", Campaign().get("playerpageid")); let pageWidth = pageObj.get("width") * 70; let pageHeight = pageObj.get("height") * 70; let pathObj = createObj('path', { pageid: Campaign().get("playerpageid"), left: pageWidth/2, top: pageHeight/2, width: pageWidth, height: pageHeight, fill: "#000000" + opacity, stroke: "transparent", stroke_width: 1, layer: 'map', path: JSON.stringify([["M", 0, pageHeight],["L", 0, 0],["L", pageWidth, 0],["L", pageWidth, pageHeight],["Z"]]), controlledby: "emoji" }); toFront(pathObj); }); Hah - was just thinking "yeah, but this won't color the tokens..." but you could marry this with tinting the player tokens for a complete effect... 
1608913800
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That's really handy! Best solution I've seen yet to this. Doesn't it need some sort of trigger other than "on ready", though? Giving it an on/off command and maybe a way to specify color and opacity in the command would make this a very nice tool, and one worthy of adding to the One-Click.
1608913916

Edited 1608913967
Pat
Pro
API Scripter
keithcurtis said: That's really handy! Best solution I've seen yet to this. Doesn't it need some sort of trigger other than "on ready", though? Giving it an on/off command and maybe a way to specify color and opacity in the command would make this a very nice tool, and one worthy of adding to the One-Click. Absolutely! I was planning a control panel for the GM, not an on-load thing - just was curious if this was something people might want to see developed, or if it had already been done?  And yes, planning for a full set of API commands and macros is definitely in the cards. 
1608914962
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
This could be used for fog, water, the fiery glow of the hells...
So simple, not as detailed as a large smoke plume, transparant fog or transparant water overlay, but so much more versatile... This is something i would  be able to use on the fly. 
1608917797
Pat
Pro
API Scripter
keithcurtis said: This could be used for fog, water, the fiery glow of the hells... Martijn S. said: So simple, not as detailed as a large smoke plume, transparant fog or transparant water overlay, but so much more versatile... This is something i would  be able to use on the fly.  So would being able to set up presets (color plus opacity combinations) of your own be a thing? Would that be something folks would want, along with a bunch of available presets, for one-click use? And default (if page not specified) of GM/DM focused page?  
1608928691
Pat
Pro
API Scripter
Update First gist for this script, if folks want it - for starters it puts a button in chat (this will be changed as it develops)  - selecting this button allows you to select a named color and then set a percent opacity for creating a page-sized overlay shape set on the map layer overtop the rest of the content. This doesn't affect player tokens, but this script could be adapted to set colorization of tokens too.  Gist is here
I am so very into this script idea and would use the heck out of it. 
1608989489
Pat
Pro
API Scripter
Update Gist has been updated with the nascent control panel - GM notes controls do not work yet, they're there just as a placeholder. All of this is GM only, but I liked using GMnotes for editing the color list and adding presets (presets will be a combination of color and opacity so it's a one-click, like the Reset Color Overlay button)
1609378922

Edited 1609379650
Pat
Pro
API Scripter
Update Still working on this - right now trying to get a fade/crossfade effect instead of sudden color shift - see if I can get a smooth transition from one color to another to aid in setting mood/indicating time shifting, and then adding the ability to script these cross-fades automatically, or set up preset fades (multiple colors, durations, etc). Math is hard.  Also building clean-up in from the beginning: re-build if the page is resized, clean-up the state variable if a page is removed/destroyed. Updated the gist with the latest really clean color handling and resize and page-destroy updates.