@idosgames/gfx 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +41 -2
- package/dist/chunk-CJTRRUEK.js +1 -0
- package/dist/chunk-PYGRABBR.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +1 -0
- package/dist/moods-CROfsmd7.d.cts +180 -0
- package/dist/moods-CROfsmd7.d.ts +180 -0
- package/dist/phaser/index.cjs +1 -0
- package/dist/phaser/index.d.cts +116 -0
- package/dist/phaser/index.d.ts +116 -0
- package/dist/phaser/index.js +1 -0
- package/dist/three/index.cjs +122 -0
- package/dist/three/index.d.cts +228 -0
- package/dist/three/index.d.ts +228 -0
- package/dist/three/index.js +122 -0
- package/package.json +78 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 iDos Games
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @idosgames/gfx
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The one visual standard of iDosGames games, 2D and 3D. A game that draws through it looks bright and
|
|
4
|
+
juicy and still runs on a cheap phone.
|
|
5
|
+
|
|
6
|
+
- `@idosgames/gfx` (engine-free): quality tiers `low | mid | high` with a verified fallback
|
|
7
|
+
(`AdaptiveQuality`), moods as data (`day`, `cozy`, `sunset`, `neon-night`), hue-shifted `shade` / `tint`,
|
|
8
|
+
`juicy` (a pale colour made full-bodied), easings.
|
|
9
|
+
- `@idosgames/gfx/three`: `setupRenderer`, `createLightRig`, `createSky`, `ToyLook` (the toy material),
|
|
10
|
+
`Particles`, `Halos` (glow), `BlobShadows`, `createPostChain` (glow + tone mapping + grade + vignette in
|
|
11
|
+
one pass, loaded lazily on mid and high only).
|
|
12
|
+
- `@idosgames/gfx/phaser`: `screenDensity` / `markDensity`, `Particles2D`, `glowSprite`, `shadowSprite`,
|
|
13
|
+
`createBackdrop`, `createFrameGrade`.
|
|
14
|
+
|
|
15
|
+
## Rules of the standard
|
|
16
|
+
|
|
17
|
+
1. A shade is never the colour mixed with black, a light never the colour mixed with white: use `shade` and
|
|
18
|
+
`tint`.
|
|
19
|
+
2. The sun is warm, the shadow is cool, light and soft (a blurred variance map, its darkness is the mood's
|
|
20
|
+
`shadow`; `setupSunShadow`), the sky is a gradient. Take the numbers from a mood, do not invent
|
|
21
|
+
lights per game.
|
|
22
|
+
3. Phones first. The low tier has no post chain and no shadow map; effects are one draw call each. No
|
|
23
|
+
filter on a single game object, ever: a glow is an additive sprite.
|
|
24
|
+
4. Quality steps down only when the step is proven to help (A, B, A), and never back up.
|
|
25
|
+
|
|
26
|
+
## three.js in short
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { moodOf, pickTier, TIERS } from "@idosgames/gfx";
|
|
30
|
+
import { createLightRig, createSky, setupRenderer, ToyLook } from "@idosgames/gfx/three";
|
|
31
|
+
|
|
32
|
+
const tier = TIERS[pickTier("auto")];
|
|
33
|
+
const mood = moodOf("day");
|
|
34
|
+
setupRenderer(renderer, tier, mood);
|
|
35
|
+
const lights = createLightRig(scene, mood, tier);
|
|
36
|
+
const sky = createSky(mood, tier.skyDetail);
|
|
37
|
+
scene.add(sky.object);
|
|
38
|
+
const toys = new ToyLook(mood);
|
|
39
|
+
mesh.material = toys.get("#ff5a4f", { finish: "glossy" });
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
⚠ `postprocessing` caps three (`< 0.188`): raise three only together with it.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=Object.freeze({low:{tier:"low",maxDensity:1.5,shadows:"none",shadowMap:0,post:false,msaa:0,particles:.6,skyDetail:false},mid:{tier:"mid",maxDensity:1.75,shadows:"pcf",shadowMap:512,post:true,msaa:2,particles:1,skyDetail:true},high:{tier:"high",maxDensity:2,shadows:"soft",shadowMap:1024,post:true,msaa:4,particles:1,skyDetail:true}});function n(){return typeof matchMedia!="function"?false:matchMedia("(pointer: coarse)").matches&&!matchMedia("(any-pointer: fine)").matches}function h(s){return s==="low"||s==="mid"||s==="high"?s:n()?"mid":"high"}var a=class{constructor(t,e={}){this.steps=t;this.minFps=e.minFps??50,this.sampleSec=e.sampleSec??2,this.settleSec=e.settleSec??1,this.gain=e.gain??1.15,this.onStep=e.onStep,this.settle=this.settleSec*2;}steps;minFps;sampleSec;settleSec;gain;onStep;index=0;phase="watch";settle;time=0;frames=0;fpsA=0;fpsB=0;taken=[];get done(){return this.index>=this.steps.length}restart(t=0){this.time=0,this.frames=0,this.settle=t;}frame(t){if(this.done||!(t>0))return;if(t>.25){this.restart(this.settleSec);return}if(this.settle>0){this.settle-=t;return}if(this.time+=t,this.frames+=1,this.time<this.sampleSec)return;let e=this.frames/this.time,i=this.steps[this.index];if(this.phase==="watch"){if(e>=this.minFps){this.restart();return}this.fpsA=e,i.apply(),this.phase="try",this.restart(this.settleSec);return}if(this.phase==="try"){this.fpsB=e,i.revert(),this.phase="back",this.restart(this.settleSec);return}let r=this.fpsB>=Math.max(this.fpsA,e)*this.gain;r&&(i.apply(),this.taken.push(i.name)),this.onStep?.(i.name,r,this.fpsB),this.index+=1,this.phase="watch",this.restart(this.settleSec);}};export{p as a,n as b,h as c,a as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=s=>Math.min(1,Math.max(0,s));function a(s){let o=/^#[0-9a-fA-F]{6}/.test(s)?s.slice(1,7):"ffffff";return [Number.parseInt(o.slice(0,2),16),Number.parseInt(o.slice(2,4),16),Number.parseInt(o.slice(4,6),16)]}var f=(s,o,e)=>`#${[s,o,e].map(n=>Math.round(Math.min(255,Math.max(0,n))).toString(16).padStart(2,"0")).join("")}`;function l(s){let[o,e,n]=a(s),t=o/255,r=e/255,u=n/255,m=Math.max(t,r,u),x=Math.min(t,r,u),b=(m+x)/2,h=m-x;if(h<1e-6)return [0,0,b];let d=h/(1-Math.abs(2*b-1)),p;return m===t?p=(r-u)/h%6:m===r?p=(u-t)/h+2:p=(t-r)/h+4,[(p*60+360)%360,c(d),b]}function i(s,o,e){let n=(s%360+360)%360,t=(1-Math.abs(2*e-1))*c(o),r=t*(1-Math.abs(n/60%2-1)),u=e-t/2,[m,x,b]=n<60?[t,r,0]:n<120?[r,t,0]:n<180?[0,t,r]:n<240?[0,r,t]:n<300?[r,0,t]:[t,0,r];return f((m+u)*255,(x+u)*255,(b+u)*255)}function I(s,o,e){let n=a(s),t=a(o);return f(n[0]+(t[0]-n[0])*e,n[1]+(t[1]-n[1])*e,n[2]+(t[2]-n[2])*e)}var A=s=>{let[o,e,n]=a(s);return (o*.299+e*.587+n*.114)/255},M=.1,g=255,O=48,y=228;function H(s,o,e){let n=(o-s+540)%360-180;return s+Math.sign(n)*Math.min(Math.abs(n),e)}function N(s,o){let e=c(o);if(e===0)return f(...a(s));let[n,t,r]=l(s);return t<M?i(n,t,r+(Math.min(r,.05)-r)*e):i(H(n,g,34*e),c(t+(Math.max(t,.6)-t)*e+.14*Math.sin(Math.PI*e)),r+(Math.min(r,.07)-r)*e)}function j(s,o){let e=c(o);if(e===0)return f(...a(s));let[n,t,r]=l(s);return t<M?i(n,t,r+(1-r)*e):i(H(n,O,26*e),t+(Math.max(.5,t*.85)-t)*e,r+(Math.max(r,.95)-r)*e)}function v(s,o=.6){let[e,n,t]=l(s);return n<M||n>=o?f(...a(s)):i(e,o,t)}function E(s,o){let e=c(o);if(e===0)return f(...a(s));let[n,t,r]=l(s);if(r>.93||r<.08)return f(...a(s));if(t<M){let b=1-Math.abs(r-.5)/.43;return i(y,.2*e*c(b*1.6),r)}let u=r>.52?r-(r-.52)*.7*e:r,m=c((t-M)/.25),x=c(t+(1-t)*.5*e*m);return n>62&&n<128?i(H(n,118,16*e),Math.min(x,Math.max(t,.58)),u):i(n,x,u)}function L(s,o=.35){let[,e,n]=l(s);return n>.12&&n<.9&&e<o}export{a,f as b,l as c,i as d,I as e,A as f,N as g,j as h,v as i,E as j,L as k};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var I=Object.freeze({low:{tier:"low",maxDensity:1.5,shadows:"none",shadowMap:0,post:false,msaa:0,particles:.6,skyDetail:false},mid:{tier:"mid",maxDensity:1.75,shadows:"pcf",shadowMap:512,post:true,msaa:2,particles:1,skyDetail:true},high:{tier:"high",maxDensity:2,shadows:"soft",shadowMap:1024,post:true,msaa:4,particles:1,skyDetail:true}});function w(){return typeof matchMedia!="function"?false:matchMedia("(pointer: coarse)").matches&&!matchMedia("(any-pointer: fine)").matches}function P(t){return t==="low"||t==="mid"||t==="high"?t:w()?"mid":"high"}var S=class{constructor(n,e={}){this.steps=n;this.minFps=e.minFps??50,this.sampleSec=e.sampleSec??2,this.settleSec=e.settleSec??1,this.gain=e.gain??1.15,this.onStep=e.onStep,this.settle=this.settleSec*2;}steps;minFps;sampleSec;settleSec;gain;onStep;index=0;phase="watch";settle;time=0;frames=0;fpsA=0;fpsB=0;taken=[];get done(){return this.index>=this.steps.length}restart(n=0){this.time=0,this.frames=0,this.settle=n;}frame(n){if(this.done||!(n>0))return;if(n>.25){this.restart(this.settleSec);return}if(this.settle>0){this.settle-=n;return}if(this.time+=n,this.frames+=1,this.time<this.sampleSec)return;let e=this.frames/this.time,o=this.steps[this.index];if(this.phase==="watch"){if(e>=this.minFps){this.restart();return}this.fpsA=e,o.apply(),this.phase="try",this.restart(this.settleSec);return}if(this.phase==="try"){this.fpsB=e,o.revert(),this.phase="back",this.restart(this.settleSec);return}let r=this.fpsB>=Math.max(this.fpsA,e)*this.gain;r&&(o.apply(),this.taken.push(o.name)),this.onStep?.(o.name,r,this.fpsB),this.index+=1,this.phase="watch",this.restart(this.settleSec);}};var m=t=>Math.min(1,Math.max(0,t));function u(t){let n=/^#[0-9a-fA-F]{6}/.test(t)?t.slice(1,7):"ffffff";return [Number.parseInt(n.slice(0,2),16),Number.parseInt(n.slice(2,4),16),Number.parseInt(n.slice(4,6),16)]}var h=(t,n,e)=>`#${[t,n,e].map(o=>Math.round(Math.min(255,Math.max(0,o))).toString(16).padStart(2,"0")).join("")}`;function c(t){let[n,e,o]=u(t),r=n/255,s=e/255,i=o/255,f=Math.max(r,s,i),l=Math.min(r,s,i),p=(f+l)/2,b=f-l;if(b<1e-6)return [0,0,p];let T=b/(1-Math.abs(2*p-1)),x;return f===r?x=(s-i)/b%6:f===s?x=(i-r)/b+2:x=(r-s)/b+4,[(x*60+360)%360,m(T),p]}function a(t,n,e){let o=(t%360+360)%360,r=(1-Math.abs(2*e-1))*m(n),s=r*(1-Math.abs(o/60%2-1)),i=e-r/2,[f,l,p]=o<60?[r,s,0]:o<120?[s,r,0]:o<180?[0,r,s]:o<240?[0,s,r]:o<300?[s,0,r]:[r,0,s];return h((f+i)*255,(l+i)*255,(p+i)*255)}function M(t,n,e){let o=u(t),r=u(n);return h(o[0]+(r[0]-o[0])*e,o[1]+(r[1]-o[1])*e,o[2]+(r[2]-o[2])*e)}var H=t=>{let[n,e,o]=u(t);return (n*.299+e*.587+o*.114)/255},y=.1,z=255,D=48,B=228;function k(t,n,e){let o=(n-t+540)%360-180;return t+Math.sign(o)*Math.min(Math.abs(o),e)}function F(t,n){let e=m(n);if(e===0)return h(...u(t));let[o,r,s]=c(t);return r<y?a(o,r,s+(Math.min(s,.05)-s)*e):a(k(o,z,34*e),m(r+(Math.max(r,.6)-r)*e+.14*Math.sin(Math.PI*e)),s+(Math.min(s,.07)-s)*e)}function G(t,n){let e=m(n);if(e===0)return h(...u(t));let[o,r,s]=c(t);return r<y?a(o,r,s+(1-s)*e):a(k(o,D,26*e),r+(Math.max(.5,r*.85)-r)*e,s+(Math.max(s,.95)-s)*e)}function A(t,n=.6){let[e,o,r]=c(t);return o<y||o>=n?h(...u(t)):a(e,n,r)}function C(t,n){let e=m(n);if(e===0)return h(...u(t));let[o,r,s]=c(t);if(s>.93||s<.08)return h(...u(t));if(r<y){let p=1-Math.abs(s-.5)/.43;return a(B,.2*e*m(p*1.6),s)}let i=s>.52?s-(s-.52)*.7*e:s,f=m((r-y)/.25),l=m(r+(1-r)*.5*e*f);return o>62&&o<128?a(k(o,118,16*e),Math.min(l,Math.max(r,.58)),i):a(o,l,i)}function R(t,n=.35){let[,e,o]=c(t);return o>.12&&o<.9&&e<n}var g=Object.freeze({day:{id:"day",skyTop:"#2f8cff",skyHorizon:"#bfe9ff",skyBottom:"#e4f6ff",sun:"#fff0cf",sunPower:2.55,ambientSky:"#a9d6ff",ambientGround:"#c9b58f",ambientPower:1.05,shadow:.55,rim:"#d8f0ff",rimPower:.55,vibrance:.6,exposure:1.05,saturation:1.15,contrast:1.1,bloom:.55,bloomThreshold:.86,vignette:.28,clouds:.55,cloudColor:"#ffffff",stars:0},cozy:{id:"cozy",skyTop:"#57b6ff",skyHorizon:"#ffe9c2",skyBottom:"#fff4dc",sun:"#ffe7b8",sunPower:2.45,ambientSky:"#bfe0ff",ambientGround:"#e2c29a",ambientPower:1.15,shadow:.5,rim:"#fff1d6",rimPower:.5,vibrance:.55,exposure:1.08,saturation:1.18,contrast:1.08,bloom:.6,bloomThreshold:.84,vignette:.24,clouds:.7,cloudColor:"#fff8ec",stars:0},sunset:{id:"sunset",skyTop:"#3d3a8c",skyHorizon:"#ff9a4d",skyBottom:"#ffc78a",sun:"#ffb066",sunPower:2.5,ambientSky:"#8f8ae0",ambientGround:"#c7764a",ambientPower:1.05,shadow:.6,rim:"#ffc98f",rimPower:.75,vibrance:.55,exposure:1.06,saturation:1.22,contrast:1.1,bloom:.75,bloomThreshold:.8,vignette:.36,clouds:.5,cloudColor:"#ffb88a",stars:0},"neon-night":{id:"neon-night",skyTop:"#070a24",skyHorizon:"#3a1f8a",skyBottom:"#1b1250",sun:"#9db8ff",sunPower:1.6,ambientSky:"#6f7cff",ambientGround:"#b03fd0",ambientPower:1.15,shadow:.65,rim:"#5fe8ff",rimPower:1.1,vibrance:.7,exposure:1.12,saturation:1.26,contrast:1.1,bloom:1.05,bloomThreshold:.62,vignette:.42,clouds:.18,cloudColor:"#5b3fc0",stars:.8}}),j=["day","cozy","sunset","neon-night"],v=t=>typeof t=="string"&&Object.prototype.hasOwnProperty.call(g,t),E=t=>v(t)?g[t]:g.day;function q(t){switch(t){case "sci-fi":return "neon-night";case "post-apocalypse":return "sunset";case "cozy":return "cozy";default:return "day"}}function N(t,n="day"){if(H(t)<.3)return "neon-night";let[e,o]=c(t);return o>.35&&(e<45||e>320)?"sunset":n==="neon-night"||n==="sunset"?"day":n}function O(t){let[n,e,o]=c(t);if(o<.3)return {top:a(n,Math.min(1,e+.1),Math.max(.03,o*.45)),horizon:a(n+18,Math.max(e,.55),Math.min(.42,o+.2)),bottom:a(n+10,Math.max(e,.5),Math.min(.3,o+.1))};let r=M(t,"#ffffff",.45);return {top:a(n-6,Math.min(1,Math.max(e,.6)+.12),o*.72),horizon:r,bottom:M(r,"#ffffff",.35)}}function Q(t,n){let e=O(n);return {...t,skyTop:e.top,skyHorizon:e.horizon,skyBottom:e.bottom}}var d=t=>Math.min(1,Math.max(0,t)),W=t=>1-(1-d(t))**3,L=t=>d(t)**3;function _(t,n=1.70158){let e=d(t)-1;return 1+(n+1)*e*e*e+n*e*e}function Y(t){let n=d(t);return n===0||n===1?n:2**(-10*n)*Math.sin((n*10-.75)*2*Math.PI/3)+1}function $(t,n=.2){let e=d(t),r=1-Math.sin(e*Math.PI*2)*(1-e)*n;return {along:r,across:1/Math.sqrt(Math.max(.2,r))}}var J=t=>.5-.5*Math.cos(d(t)*Math.PI*2);exports.AdaptiveQuality=S;exports.MOODS=g;exports.MOOD_IDS=j;exports.TIERS=I;exports.easeInCubic=L;exports.easeOutBack=_;exports.easeOutCubic=W;exports.easeOutElastic=Y;exports.hexOf=h;exports.hexOfHsl=a;exports.hslOf=c;exports.isDull=R;exports.isMood=v;exports.juicy=C;exports.lum=H;exports.mix=M;exports.moodForSky=N;exports.moodForStyle=q;exports.moodOf=E;exports.moodWithSky=Q;exports.pickTier=P;exports.pulse=J;exports.rgbOf=u;exports.shade=F;exports.skyFrom=O;exports.squash=$;exports.tint=G;exports.touchOnly=w;exports.vivid=A;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { A as AdaptiveOptions, a as AdaptiveQuality, G as GfxTier, H as Hex, M as MOODS, b as MOOD_IDS, c as Mood, d as MoodId, Q as QualityStep, T as TIERS, e as TierSettings, h as hexOf, f as hexOfHsl, g as hslOf, i as isDull, j as isMood, k as juicy, l as lum, m as mix, n as moodForSky, o as moodForStyle, p as moodOf, q as moodWithSky, r as pickTier, s as rgbOf, t as shade, u as skyFrom, v as tint, w as touchOnly, x as vivid } from './moods-CROfsmd7.cjs';
|
|
2
|
+
|
|
3
|
+
declare const easeOutCubic: (t: number) => number;
|
|
4
|
+
declare const easeInCubic: (t: number) => number;
|
|
5
|
+
/** Overshoots its end a little and settles: a thing popping in. */
|
|
6
|
+
declare function easeOutBack(t: number, overshoot?: number): number;
|
|
7
|
+
/** Wobbles around its end: a thing landing on a spring. */
|
|
8
|
+
declare function easeOutElastic(t: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Squash and stretch of a thing that was just hit, picked up or landed: scale along its axis and across
|
|
11
|
+
* it over t = 0..1 (volume kept: wider when shorter). `power` is how far it squashes (0.25 is a lot).
|
|
12
|
+
*/
|
|
13
|
+
declare function squash(t: number, power?: number): {
|
|
14
|
+
along: number;
|
|
15
|
+
across: number;
|
|
16
|
+
};
|
|
17
|
+
/** A pulse 0 → 1 → 0 (a glow breathing, a coin winking). */
|
|
18
|
+
declare const pulse: (t: number) => number;
|
|
19
|
+
|
|
20
|
+
export { easeInCubic, easeOutBack, easeOutCubic, easeOutElastic, pulse, squash };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { A as AdaptiveOptions, a as AdaptiveQuality, G as GfxTier, H as Hex, M as MOODS, b as MOOD_IDS, c as Mood, d as MoodId, Q as QualityStep, T as TIERS, e as TierSettings, h as hexOf, f as hexOfHsl, g as hslOf, i as isDull, j as isMood, k as juicy, l as lum, m as mix, n as moodForSky, o as moodForStyle, p as moodOf, q as moodWithSky, r as pickTier, s as rgbOf, t as shade, u as skyFrom, v as tint, w as touchOnly, x as vivid } from './moods-CROfsmd7.js';
|
|
2
|
+
|
|
3
|
+
declare const easeOutCubic: (t: number) => number;
|
|
4
|
+
declare const easeInCubic: (t: number) => number;
|
|
5
|
+
/** Overshoots its end a little and settles: a thing popping in. */
|
|
6
|
+
declare function easeOutBack(t: number, overshoot?: number): number;
|
|
7
|
+
/** Wobbles around its end: a thing landing on a spring. */
|
|
8
|
+
declare function easeOutElastic(t: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Squash and stretch of a thing that was just hit, picked up or landed: scale along its axis and across
|
|
11
|
+
* it over t = 0..1 (volume kept: wider when shorter). `power` is how far it squashes (0.25 is a lot).
|
|
12
|
+
*/
|
|
13
|
+
declare function squash(t: number, power?: number): {
|
|
14
|
+
along: number;
|
|
15
|
+
across: number;
|
|
16
|
+
};
|
|
17
|
+
/** A pulse 0 → 1 → 0 (a glow breathing, a coin winking). */
|
|
18
|
+
declare const pulse: (t: number) => number;
|
|
19
|
+
|
|
20
|
+
export { easeInCubic, easeOutBack, easeOutCubic, easeOutElastic, pulse, squash };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{d as AdaptiveQuality,a as TIERS,c as pickTier,b as touchOnly}from'./chunk-CJTRRUEK.js';import {f,c as c$1,d as d$1,e}from'./chunk-PYGRABBR.js';export{b as hexOf,d as hexOfHsl,c as hslOf,k as isDull,j as juicy,f as lum,e as mix,a as rgbOf,g as shade,h as tint,i as vivid}from'./chunk-PYGRABBR.js';var d=Object.freeze({day:{id:"day",skyTop:"#2f8cff",skyHorizon:"#bfe9ff",skyBottom:"#e4f6ff",sun:"#fff0cf",sunPower:2.55,ambientSky:"#a9d6ff",ambientGround:"#c9b58f",ambientPower:1.05,shadow:.55,rim:"#d8f0ff",rimPower:.55,vibrance:.6,exposure:1.05,saturation:1.15,contrast:1.1,bloom:.55,bloomThreshold:.86,vignette:.28,clouds:.55,cloudColor:"#ffffff",stars:0},cozy:{id:"cozy",skyTop:"#57b6ff",skyHorizon:"#ffe9c2",skyBottom:"#fff4dc",sun:"#ffe7b8",sunPower:2.45,ambientSky:"#bfe0ff",ambientGround:"#e2c29a",ambientPower:1.15,shadow:.5,rim:"#fff1d6",rimPower:.5,vibrance:.55,exposure:1.08,saturation:1.18,contrast:1.08,bloom:.6,bloomThreshold:.84,vignette:.24,clouds:.7,cloudColor:"#fff8ec",stars:0},sunset:{id:"sunset",skyTop:"#3d3a8c",skyHorizon:"#ff9a4d",skyBottom:"#ffc78a",sun:"#ffb066",sunPower:2.5,ambientSky:"#8f8ae0",ambientGround:"#c7764a",ambientPower:1.05,shadow:.6,rim:"#ffc98f",rimPower:.75,vibrance:.55,exposure:1.06,saturation:1.22,contrast:1.1,bloom:.75,bloomThreshold:.8,vignette:.36,clouds:.5,cloudColor:"#ffb88a",stars:0},"neon-night":{id:"neon-night",skyTop:"#070a24",skyHorizon:"#3a1f8a",skyBottom:"#1b1250",sun:"#9db8ff",sunPower:1.6,ambientSky:"#6f7cff",ambientGround:"#b03fd0",ambientPower:1.15,shadow:.65,rim:"#5fe8ff",rimPower:1.1,vibrance:.7,exposure:1.12,saturation:1.26,contrast:1.1,bloom:1.05,bloomThreshold:.62,vignette:.42,clouds:.18,cloudColor:"#5b3fc0",stars:.8}}),g=["day","cozy","sunset","neon-night"],m=o=>typeof o=="string"&&Object.prototype.hasOwnProperty.call(d,o),P=o=>m(o)?d[o]:d.day;function S(o){switch(o){case "sci-fi":return "neon-night";case "post-apocalypse":return "sunset";case "cozy":return "cozy";default:return "day"}}function z(o,e="day"){if(f(o)<.3)return "neon-night";let[t,n]=c$1(o);return n>.35&&(t<45||t>320)?"sunset":e==="neon-night"||e==="sunset"?"day":e}function c(o){let[e$1,t,n]=c$1(o);if(n<.3)return {top:d$1(e$1,Math.min(1,t+.1),Math.max(.03,n*.45)),horizon:d$1(e$1+18,Math.max(t,.55),Math.min(.42,n+.2)),bottom:d$1(e$1+10,Math.max(t,.5),Math.min(.3,n+.1))};let a=e(o,"#ffffff",.45);return {top:d$1(e$1-6,Math.min(1,Math.max(t,.6)+.12),n*.72),horizon:a,bottom:e(a,"#ffffff",.35)}}function I(o,e){let t=c(e);return {...o,skyTop:t.top,skyHorizon:t.horizon,skyBottom:t.bottom}}var s=o=>Math.min(1,Math.max(0,o)),T=o=>1-(1-s(o))**3,v=o=>s(o)**3;function C(o,e=1.70158){let t=s(o)-1;return 1+(e+1)*t*t*t+e*t*t}function B(o){let e=s(o);return e===0||e===1?e:2**(-10*e)*Math.sin((e*10-.75)*2*Math.PI/3)+1}function D(o,e=.2){let t=s(o),a=1-Math.sin(t*Math.PI*2)*(1-t)*e;return {along:a,across:1/Math.sqrt(Math.max(.2,a))}}var F=o=>.5-.5*Math.cos(s(o)*Math.PI*2);export{d as MOODS,g as MOOD_IDS,v as easeInCubic,C as easeOutBack,T as easeOutCubic,B as easeOutElastic,m as isMood,z as moodForSky,S as moodForStyle,P as moodOf,I as moodWithSky,F as pulse,c as skyFrom,D as squash};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
type GfxTier = "low" | "mid" | "high";
|
|
2
|
+
interface TierSettings {
|
|
3
|
+
readonly tier: GfxTier;
|
|
4
|
+
/** Canvas pixels per CSS pixel at most. */
|
|
5
|
+
readonly maxDensity: number;
|
|
6
|
+
/**
|
|
7
|
+
* The sun's shadow map: none (blob shadows instead), or a soft one (a blurred variance map; PCF where the
|
|
8
|
+
* GPU cannot draw it). "soft" on high is the same look on a map twice as fine.
|
|
9
|
+
*/
|
|
10
|
+
readonly shadows: "none" | "pcf" | "soft";
|
|
11
|
+
/** The shadow map's side in pixels (0 with no shadows). */
|
|
12
|
+
readonly shadowMap: number;
|
|
13
|
+
/** The frame post chain (glow, vignette, colour grade in one pass). */
|
|
14
|
+
readonly post: boolean;
|
|
15
|
+
/** Samples of the post chain's frame buffer (0: no multisampling). */
|
|
16
|
+
readonly msaa: number;
|
|
17
|
+
/** Share of particles a burst really emits (1 = all). */
|
|
18
|
+
readonly particles: number;
|
|
19
|
+
/** Drifting clouds and stars in the sky (a gradient alone costs nothing). */
|
|
20
|
+
readonly skyDetail: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare const TIERS: Readonly<Record<GfxTier, TierSettings>>;
|
|
23
|
+
/** Touch input only (a phone, a tablet): no mouse and no trackpad. */
|
|
24
|
+
declare function touchOnly(): boolean;
|
|
25
|
+
/** The tier a game starts at: the asked one, or by the device ("auto": a phone — mid, otherwise high). */
|
|
26
|
+
declare function pickTier(asked?: GfxTier | "auto" | null): GfxTier;
|
|
27
|
+
/** One thing a slow device can give up. Tried in the order given. */
|
|
28
|
+
interface QualityStep {
|
|
29
|
+
readonly name: string;
|
|
30
|
+
/** Turn the cheaper look on. */
|
|
31
|
+
apply(): void;
|
|
32
|
+
/** Back to the look before `apply` (the step is being tested, or was refused). */
|
|
33
|
+
revert(): void;
|
|
34
|
+
}
|
|
35
|
+
interface AdaptiveOptions {
|
|
36
|
+
/** Below this the device is slow (default 50). */
|
|
37
|
+
readonly minFps?: number;
|
|
38
|
+
/** Seconds one measurement lasts (default 2). */
|
|
39
|
+
readonly sampleSec?: number;
|
|
40
|
+
/** Seconds skipped after the start and after every switch: shaders compile, textures upload (default 1). */
|
|
41
|
+
readonly settleSec?: number;
|
|
42
|
+
/** The cheaper look must be this many times faster than BOTH measurements of the old one (default 1.15). */
|
|
43
|
+
readonly gain?: number;
|
|
44
|
+
/** A step was taken (kept) or refused (it did not help). */
|
|
45
|
+
readonly onStep?: (name: string, kept: boolean, fps: number) => void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Steps quality down on a slow device, and only when the step is proven to help: slow (A) → the cheaper
|
|
49
|
+
* look is measured (B) → the old look is measured again (A) → the step is kept only if B is faster than
|
|
50
|
+
* BOTH measurements of A by `gain`. ⚠ A plain "slow → cheaper" rule takes sharpness away for nothing:
|
|
51
|
+
* on the owner's phone the bottleneck was not the pixels at all, and once the rule fired from one slow
|
|
52
|
+
* start (docs/feature-history/mobile-game-frame-perf.md). A refused step is never tried again.
|
|
53
|
+
*
|
|
54
|
+
* Feed it every drawn frame's time. A frame longer than 0.25 s is a stall (a hidden tab draws 1–2
|
|
55
|
+
* frames a second, a level loads): the measurement starts over instead of counting it.
|
|
56
|
+
*/
|
|
57
|
+
declare class AdaptiveQuality {
|
|
58
|
+
private readonly steps;
|
|
59
|
+
private readonly minFps;
|
|
60
|
+
private readonly sampleSec;
|
|
61
|
+
private readonly settleSec;
|
|
62
|
+
private readonly gain;
|
|
63
|
+
private readonly onStep;
|
|
64
|
+
private index;
|
|
65
|
+
private phase;
|
|
66
|
+
private settle;
|
|
67
|
+
private time;
|
|
68
|
+
private frames;
|
|
69
|
+
private fpsA;
|
|
70
|
+
private fpsB;
|
|
71
|
+
/** Steps kept so far, by name. */
|
|
72
|
+
readonly taken: string[];
|
|
73
|
+
constructor(steps: readonly QualityStep[], options?: AdaptiveOptions);
|
|
74
|
+
/** Nothing left to try. */
|
|
75
|
+
get done(): boolean;
|
|
76
|
+
private restart;
|
|
77
|
+
frame(dt: number): void;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
type Hex = string;
|
|
81
|
+
declare function rgbOf(hex: Hex): [number, number, number];
|
|
82
|
+
declare const hexOf: (r: number, g: number, b: number) => Hex;
|
|
83
|
+
/** Hue in degrees 0..360, saturation and lightness 0..1. */
|
|
84
|
+
declare function hslOf(hex: Hex): [number, number, number];
|
|
85
|
+
declare function hexOfHsl(h: number, s: number, l: number): Hex;
|
|
86
|
+
/** a → b by t (0..1), straight in RGB. */
|
|
87
|
+
declare function mix(a: Hex, b: Hex, t: number): Hex;
|
|
88
|
+
/** Brightness 0..1 as the eye sees it. */
|
|
89
|
+
declare const lum: (c: Hex) => number;
|
|
90
|
+
/**
|
|
91
|
+
* A shade of a colour, k = 0..1: darker, a little more saturated, the hue leaning cool. Half way the
|
|
92
|
+
* saturation is lifted most, so a mid shadow is rich rather than muddy. k = 1 is the deepest shadow of
|
|
93
|
+
* the colour, never pure black.
|
|
94
|
+
*/
|
|
95
|
+
declare function shade(c: Hex, k: number): Hex;
|
|
96
|
+
/**
|
|
97
|
+
* A light on a colour, k = 0..1: brighter, the hue leaning warm, the colour kept. k = 1 is the brightest
|
|
98
|
+
* light on the colour, never chalk white (a grey does reach white).
|
|
99
|
+
*/
|
|
100
|
+
declare function tint(c: Hex, k: number): Hex;
|
|
101
|
+
/** The colour pushed to at least this saturation (greys are left alone). */
|
|
102
|
+
declare function vivid(c: Hex, minSaturation?: number): Hex;
|
|
103
|
+
/**
|
|
104
|
+
* A colour made juicy, k = 0..1: more saturated, and a pale colour pulled down to a full-bodied one (a
|
|
105
|
+
* pale colour cannot be saturated: there is no room left in it). A grey gets a cool slate tint (asphalt,
|
|
106
|
+
* concrete and stone in a casual game are blue-violet greys, never neutral ones). Near whites and near
|
|
107
|
+
* blacks are left alone. This is what turns a washed-out "#b9d98a" lawn into a green one.
|
|
108
|
+
*/
|
|
109
|
+
declare function juicy(c: Hex, k: number): Hex;
|
|
110
|
+
/**
|
|
111
|
+
* A colour that reads as grey on a game field: little saturation and neither near white nor near black.
|
|
112
|
+
* The key roles of a palette (the hero, the coin, the danger, the board's pieces) must not be dull.
|
|
113
|
+
*/
|
|
114
|
+
declare function isDull(c: Hex, minSaturation?: number): boolean;
|
|
115
|
+
|
|
116
|
+
type MoodId = "day" | "cozy" | "sunset" | "neon-night";
|
|
117
|
+
interface Mood {
|
|
118
|
+
readonly id: MoodId;
|
|
119
|
+
/** The sky straight up, at the horizon, and under it (the haze the far ground melts into). */
|
|
120
|
+
readonly skyTop: Hex;
|
|
121
|
+
readonly skyHorizon: Hex;
|
|
122
|
+
readonly skyBottom: Hex;
|
|
123
|
+
/** The sun: its colour and how strong it lights (a three.js directional light's intensity). */
|
|
124
|
+
readonly sun: Hex;
|
|
125
|
+
readonly sunPower: number;
|
|
126
|
+
/** The light of the sky from above and its bounce off the ground (a hemisphere light). */
|
|
127
|
+
readonly ambientSky: Hex;
|
|
128
|
+
readonly ambientGround: Hex;
|
|
129
|
+
readonly ambientPower: number;
|
|
130
|
+
/**
|
|
131
|
+
* How much of the sun a shadow takes away, 0..1 (a three.js light shadow's intensity). A casual game's
|
|
132
|
+
* shadow is light and soft: the ground in it keeps its colour, it only goes cooler and a little darker.
|
|
133
|
+
*/
|
|
134
|
+
readonly shadow: number;
|
|
135
|
+
/** The rim light on edges turned away from the camera (the sky's colour on a toy's silhouette). */
|
|
136
|
+
readonly rim: Hex;
|
|
137
|
+
readonly rimPower: number;
|
|
138
|
+
/** How far the colours of things are pushed to juicy ones, 0..1 (see `juicy`). */
|
|
139
|
+
readonly vibrance: number;
|
|
140
|
+
/** Tone mapping exposure. */
|
|
141
|
+
readonly exposure: number;
|
|
142
|
+
/** The frame grade: 1 = untouched. */
|
|
143
|
+
readonly saturation: number;
|
|
144
|
+
readonly contrast: number;
|
|
145
|
+
/** Glow: how strong, and from what brightness up (0..1). */
|
|
146
|
+
readonly bloom: number;
|
|
147
|
+
readonly bloomThreshold: number;
|
|
148
|
+
/** Darkening of the frame's corners, 0..1. */
|
|
149
|
+
readonly vignette: number;
|
|
150
|
+
/** Clouds in the sky, 0..1, and their colour. */
|
|
151
|
+
readonly clouds: number;
|
|
152
|
+
readonly cloudColor: Hex;
|
|
153
|
+
/** Stars, 0..1 (a night). */
|
|
154
|
+
readonly stars: number;
|
|
155
|
+
}
|
|
156
|
+
declare const MOODS: Readonly<Record<MoodId, Mood>>;
|
|
157
|
+
declare const MOOD_IDS: readonly MoodId[];
|
|
158
|
+
declare const isMood: (id: unknown) => id is MoodId;
|
|
159
|
+
/** A mood by id; an unknown id is the day. */
|
|
160
|
+
declare const moodOf: (id?: string | null) => Mood;
|
|
161
|
+
/** The mood of an art style / asset pack ("fantasy", "sci-fi", "cozy", "post-apocalypse"). */
|
|
162
|
+
declare function moodForStyle(style?: string | null): MoodId;
|
|
163
|
+
/**
|
|
164
|
+
* The mood a sky colour itself asks for, when a game's world brings its own sky: a dark sky is a
|
|
165
|
+
* night, an orange or pink one a sunset; any other keeps `fallback` (the pack's mood).
|
|
166
|
+
*/
|
|
167
|
+
declare function moodForSky(sky: Hex, fallback?: MoodId): MoodId;
|
|
168
|
+
/**
|
|
169
|
+
* A sky gradient out of ONE colour (a game's world says only "the sky is #8fd3ff"): the given colour
|
|
170
|
+
* is what the eye meets a little over the horizon, the zenith is deeper and richer, the horizon lighter.
|
|
171
|
+
*/
|
|
172
|
+
declare function skyFrom(sky: Hex): {
|
|
173
|
+
top: Hex;
|
|
174
|
+
horizon: Hex;
|
|
175
|
+
bottom: Hex;
|
|
176
|
+
};
|
|
177
|
+
/** A mood with the sky of a world's own colour (the light stays the mood's). */
|
|
178
|
+
declare function moodWithSky(mood: Mood, sky: Hex): Mood;
|
|
179
|
+
|
|
180
|
+
export { type AdaptiveOptions as A, type GfxTier as G, type Hex as H, MOODS as M, type QualityStep as Q, TIERS as T, AdaptiveQuality as a, MOOD_IDS as b, type Mood as c, type MoodId as d, type TierSettings as e, hexOfHsl as f, hslOf as g, hexOf as h, isDull as i, isMood as j, juicy as k, lum as l, mix as m, moodForSky as n, moodForStyle as o, moodOf as p, moodWithSky as q, pickTier as r, rgbOf as s, shade as t, skyFrom as u, tint as v, touchOnly as w, vivid as x };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
type GfxTier = "low" | "mid" | "high";
|
|
2
|
+
interface TierSettings {
|
|
3
|
+
readonly tier: GfxTier;
|
|
4
|
+
/** Canvas pixels per CSS pixel at most. */
|
|
5
|
+
readonly maxDensity: number;
|
|
6
|
+
/**
|
|
7
|
+
* The sun's shadow map: none (blob shadows instead), or a soft one (a blurred variance map; PCF where the
|
|
8
|
+
* GPU cannot draw it). "soft" on high is the same look on a map twice as fine.
|
|
9
|
+
*/
|
|
10
|
+
readonly shadows: "none" | "pcf" | "soft";
|
|
11
|
+
/** The shadow map's side in pixels (0 with no shadows). */
|
|
12
|
+
readonly shadowMap: number;
|
|
13
|
+
/** The frame post chain (glow, vignette, colour grade in one pass). */
|
|
14
|
+
readonly post: boolean;
|
|
15
|
+
/** Samples of the post chain's frame buffer (0: no multisampling). */
|
|
16
|
+
readonly msaa: number;
|
|
17
|
+
/** Share of particles a burst really emits (1 = all). */
|
|
18
|
+
readonly particles: number;
|
|
19
|
+
/** Drifting clouds and stars in the sky (a gradient alone costs nothing). */
|
|
20
|
+
readonly skyDetail: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare const TIERS: Readonly<Record<GfxTier, TierSettings>>;
|
|
23
|
+
/** Touch input only (a phone, a tablet): no mouse and no trackpad. */
|
|
24
|
+
declare function touchOnly(): boolean;
|
|
25
|
+
/** The tier a game starts at: the asked one, or by the device ("auto": a phone — mid, otherwise high). */
|
|
26
|
+
declare function pickTier(asked?: GfxTier | "auto" | null): GfxTier;
|
|
27
|
+
/** One thing a slow device can give up. Tried in the order given. */
|
|
28
|
+
interface QualityStep {
|
|
29
|
+
readonly name: string;
|
|
30
|
+
/** Turn the cheaper look on. */
|
|
31
|
+
apply(): void;
|
|
32
|
+
/** Back to the look before `apply` (the step is being tested, or was refused). */
|
|
33
|
+
revert(): void;
|
|
34
|
+
}
|
|
35
|
+
interface AdaptiveOptions {
|
|
36
|
+
/** Below this the device is slow (default 50). */
|
|
37
|
+
readonly minFps?: number;
|
|
38
|
+
/** Seconds one measurement lasts (default 2). */
|
|
39
|
+
readonly sampleSec?: number;
|
|
40
|
+
/** Seconds skipped after the start and after every switch: shaders compile, textures upload (default 1). */
|
|
41
|
+
readonly settleSec?: number;
|
|
42
|
+
/** The cheaper look must be this many times faster than BOTH measurements of the old one (default 1.15). */
|
|
43
|
+
readonly gain?: number;
|
|
44
|
+
/** A step was taken (kept) or refused (it did not help). */
|
|
45
|
+
readonly onStep?: (name: string, kept: boolean, fps: number) => void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Steps quality down on a slow device, and only when the step is proven to help: slow (A) → the cheaper
|
|
49
|
+
* look is measured (B) → the old look is measured again (A) → the step is kept only if B is faster than
|
|
50
|
+
* BOTH measurements of A by `gain`. ⚠ A plain "slow → cheaper" rule takes sharpness away for nothing:
|
|
51
|
+
* on the owner's phone the bottleneck was not the pixels at all, and once the rule fired from one slow
|
|
52
|
+
* start (docs/feature-history/mobile-game-frame-perf.md). A refused step is never tried again.
|
|
53
|
+
*
|
|
54
|
+
* Feed it every drawn frame's time. A frame longer than 0.25 s is a stall (a hidden tab draws 1–2
|
|
55
|
+
* frames a second, a level loads): the measurement starts over instead of counting it.
|
|
56
|
+
*/
|
|
57
|
+
declare class AdaptiveQuality {
|
|
58
|
+
private readonly steps;
|
|
59
|
+
private readonly minFps;
|
|
60
|
+
private readonly sampleSec;
|
|
61
|
+
private readonly settleSec;
|
|
62
|
+
private readonly gain;
|
|
63
|
+
private readonly onStep;
|
|
64
|
+
private index;
|
|
65
|
+
private phase;
|
|
66
|
+
private settle;
|
|
67
|
+
private time;
|
|
68
|
+
private frames;
|
|
69
|
+
private fpsA;
|
|
70
|
+
private fpsB;
|
|
71
|
+
/** Steps kept so far, by name. */
|
|
72
|
+
readonly taken: string[];
|
|
73
|
+
constructor(steps: readonly QualityStep[], options?: AdaptiveOptions);
|
|
74
|
+
/** Nothing left to try. */
|
|
75
|
+
get done(): boolean;
|
|
76
|
+
private restart;
|
|
77
|
+
frame(dt: number): void;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
type Hex = string;
|
|
81
|
+
declare function rgbOf(hex: Hex): [number, number, number];
|
|
82
|
+
declare const hexOf: (r: number, g: number, b: number) => Hex;
|
|
83
|
+
/** Hue in degrees 0..360, saturation and lightness 0..1. */
|
|
84
|
+
declare function hslOf(hex: Hex): [number, number, number];
|
|
85
|
+
declare function hexOfHsl(h: number, s: number, l: number): Hex;
|
|
86
|
+
/** a → b by t (0..1), straight in RGB. */
|
|
87
|
+
declare function mix(a: Hex, b: Hex, t: number): Hex;
|
|
88
|
+
/** Brightness 0..1 as the eye sees it. */
|
|
89
|
+
declare const lum: (c: Hex) => number;
|
|
90
|
+
/**
|
|
91
|
+
* A shade of a colour, k = 0..1: darker, a little more saturated, the hue leaning cool. Half way the
|
|
92
|
+
* saturation is lifted most, so a mid shadow is rich rather than muddy. k = 1 is the deepest shadow of
|
|
93
|
+
* the colour, never pure black.
|
|
94
|
+
*/
|
|
95
|
+
declare function shade(c: Hex, k: number): Hex;
|
|
96
|
+
/**
|
|
97
|
+
* A light on a colour, k = 0..1: brighter, the hue leaning warm, the colour kept. k = 1 is the brightest
|
|
98
|
+
* light on the colour, never chalk white (a grey does reach white).
|
|
99
|
+
*/
|
|
100
|
+
declare function tint(c: Hex, k: number): Hex;
|
|
101
|
+
/** The colour pushed to at least this saturation (greys are left alone). */
|
|
102
|
+
declare function vivid(c: Hex, minSaturation?: number): Hex;
|
|
103
|
+
/**
|
|
104
|
+
* A colour made juicy, k = 0..1: more saturated, and a pale colour pulled down to a full-bodied one (a
|
|
105
|
+
* pale colour cannot be saturated: there is no room left in it). A grey gets a cool slate tint (asphalt,
|
|
106
|
+
* concrete and stone in a casual game are blue-violet greys, never neutral ones). Near whites and near
|
|
107
|
+
* blacks are left alone. This is what turns a washed-out "#b9d98a" lawn into a green one.
|
|
108
|
+
*/
|
|
109
|
+
declare function juicy(c: Hex, k: number): Hex;
|
|
110
|
+
/**
|
|
111
|
+
* A colour that reads as grey on a game field: little saturation and neither near white nor near black.
|
|
112
|
+
* The key roles of a palette (the hero, the coin, the danger, the board's pieces) must not be dull.
|
|
113
|
+
*/
|
|
114
|
+
declare function isDull(c: Hex, minSaturation?: number): boolean;
|
|
115
|
+
|
|
116
|
+
type MoodId = "day" | "cozy" | "sunset" | "neon-night";
|
|
117
|
+
interface Mood {
|
|
118
|
+
readonly id: MoodId;
|
|
119
|
+
/** The sky straight up, at the horizon, and under it (the haze the far ground melts into). */
|
|
120
|
+
readonly skyTop: Hex;
|
|
121
|
+
readonly skyHorizon: Hex;
|
|
122
|
+
readonly skyBottom: Hex;
|
|
123
|
+
/** The sun: its colour and how strong it lights (a three.js directional light's intensity). */
|
|
124
|
+
readonly sun: Hex;
|
|
125
|
+
readonly sunPower: number;
|
|
126
|
+
/** The light of the sky from above and its bounce off the ground (a hemisphere light). */
|
|
127
|
+
readonly ambientSky: Hex;
|
|
128
|
+
readonly ambientGround: Hex;
|
|
129
|
+
readonly ambientPower: number;
|
|
130
|
+
/**
|
|
131
|
+
* How much of the sun a shadow takes away, 0..1 (a three.js light shadow's intensity). A casual game's
|
|
132
|
+
* shadow is light and soft: the ground in it keeps its colour, it only goes cooler and a little darker.
|
|
133
|
+
*/
|
|
134
|
+
readonly shadow: number;
|
|
135
|
+
/** The rim light on edges turned away from the camera (the sky's colour on a toy's silhouette). */
|
|
136
|
+
readonly rim: Hex;
|
|
137
|
+
readonly rimPower: number;
|
|
138
|
+
/** How far the colours of things are pushed to juicy ones, 0..1 (see `juicy`). */
|
|
139
|
+
readonly vibrance: number;
|
|
140
|
+
/** Tone mapping exposure. */
|
|
141
|
+
readonly exposure: number;
|
|
142
|
+
/** The frame grade: 1 = untouched. */
|
|
143
|
+
readonly saturation: number;
|
|
144
|
+
readonly contrast: number;
|
|
145
|
+
/** Glow: how strong, and from what brightness up (0..1). */
|
|
146
|
+
readonly bloom: number;
|
|
147
|
+
readonly bloomThreshold: number;
|
|
148
|
+
/** Darkening of the frame's corners, 0..1. */
|
|
149
|
+
readonly vignette: number;
|
|
150
|
+
/** Clouds in the sky, 0..1, and their colour. */
|
|
151
|
+
readonly clouds: number;
|
|
152
|
+
readonly cloudColor: Hex;
|
|
153
|
+
/** Stars, 0..1 (a night). */
|
|
154
|
+
readonly stars: number;
|
|
155
|
+
}
|
|
156
|
+
declare const MOODS: Readonly<Record<MoodId, Mood>>;
|
|
157
|
+
declare const MOOD_IDS: readonly MoodId[];
|
|
158
|
+
declare const isMood: (id: unknown) => id is MoodId;
|
|
159
|
+
/** A mood by id; an unknown id is the day. */
|
|
160
|
+
declare const moodOf: (id?: string | null) => Mood;
|
|
161
|
+
/** The mood of an art style / asset pack ("fantasy", "sci-fi", "cozy", "post-apocalypse"). */
|
|
162
|
+
declare function moodForStyle(style?: string | null): MoodId;
|
|
163
|
+
/**
|
|
164
|
+
* The mood a sky colour itself asks for, when a game's world brings its own sky: a dark sky is a
|
|
165
|
+
* night, an orange or pink one a sunset; any other keeps `fallback` (the pack's mood).
|
|
166
|
+
*/
|
|
167
|
+
declare function moodForSky(sky: Hex, fallback?: MoodId): MoodId;
|
|
168
|
+
/**
|
|
169
|
+
* A sky gradient out of ONE colour (a game's world says only "the sky is #8fd3ff"): the given colour
|
|
170
|
+
* is what the eye meets a little over the horizon, the zenith is deeper and richer, the horizon lighter.
|
|
171
|
+
*/
|
|
172
|
+
declare function skyFrom(sky: Hex): {
|
|
173
|
+
top: Hex;
|
|
174
|
+
horizon: Hex;
|
|
175
|
+
bottom: Hex;
|
|
176
|
+
};
|
|
177
|
+
/** A mood with the sky of a world's own colour (the light stays the mood's). */
|
|
178
|
+
declare function moodWithSky(mood: Mood, sky: Hex): Mood;
|
|
179
|
+
|
|
180
|
+
export { type AdaptiveOptions as A, type GfxTier as G, type Hex as H, MOODS as M, type QualityStep as Q, TIERS as T, AdaptiveQuality as a, MOOD_IDS as b, type Mood as c, type MoodId as d, type TierSettings as e, hexOfHsl as f, hslOf as g, hexOf as h, isDull as i, isMood as j, juicy as k, lum as l, mix as m, moodForSky as n, moodForStyle as o, moodOf as p, moodWithSky as q, pickTier as r, rgbOf as s, shade as t, skyFrom as u, tint as v, touchOnly as w, vivid as x };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var z=require('phaser');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var z__default=/*#__PURE__*/_interopDefault(z);var E=2;function k(){let r=typeof devicePixelRatio=="number"&&devicePixelRatio>0?devicePixelRatio:1;return Math.min(2,Math.max(1,r))}function A(r){let e=r.scale.zoom;return e>0?1/e:1}function H(r,e){if(e===1)return;let t=r.source[0];t&&(t.resolution=e);for(let n of r.getFrameNames(true)){let s=r.get(n);s.data.sourceSize.w=s.cutWidth/e,s.data.sourceSize.h=s.cutHeight/e;}}var c={dot:"gfx:dot",spark:"gfx:spark",puff:"gfx:puff",chip:"gfx:chip",ring:"gfx:ring",star:"gfx:star",glow:"gfx:glow",shadow:"gfx:shadow",vignette:"gfx:vignette"},p=64,d=(r,e="255,255,255",t=1)=>(n,s)=>{let i=s/2,a=n.createRadialGradient(i,i,0,i,i,i*t);for(let[o,l]of r)a.addColorStop(o,`rgba(${e},${l})`);n.fillStyle=a,n.fillRect(0,0,s,s);},R={[c.dot]:[p,d([[0,1],[.25,.85],[.6,.22],[1,0]])],[c.spark]:[p,(r,e)=>{let t=e/2;d([[0,1],[.5,.25],[1,0]],"255,255,255",.55)(r,e),r.fillStyle="rgba(255,255,255,0.95)";for(let n of [0,Math.PI/2])r.save(),r.translate(t,t),r.rotate(n),r.beginPath(),r.moveTo(-t*.96,0),r.quadraticCurveTo(0,-t*.1,t*.96,0),r.quadraticCurveTo(0,t*.1,-t*.96,0),r.fill(),r.restore();}],[c.puff]:[p,d([[0,.7],[.55,.42],[1,0]])],[c.chip]:[p,(r,e)=>{let t=e/2;r.fillStyle="#ffffff",r.beginPath(),r.roundRect(t*.3,t*.55,t*1.4,t*.9,t*.14),r.fill();}],[c.ring]:[p,(r,e)=>{let t=e/2;r.strokeStyle="#ffffff",r.lineWidth=t*.16,r.beginPath(),r.arc(t,t,t*.8,0,Math.PI*2),r.stroke();}],[c.star]:[p,(r,e)=>{let t=e/2;r.fillStyle="#ffffff",r.beginPath();for(let n=0;n<10;n++){let s=n%2===0?t*.92:t*.4,i=-Math.PI/2+n*Math.PI/5;r.lineTo(t+Math.cos(i)*s,t+Math.sin(i)*s);}r.closePath(),r.fill();}],[c.glow]:[128,d([[0,.9],[.3,.45],[.65,.12],[1,0]])],[c.shadow]:[p,d([[0,.8],[.35,.6],[.7,.22],[1,0]],"29,42,107")],[c.vignette]:[256,d([[0,0],[.55,0],[.82,.32],[1,.85]],"6,8,24",1.42)]};function f(r){for(let e of Object.values(c)){if(r.textures.exists(e))continue;let[t,n]=R[e],s=r.textures.createCanvas(e,t,t);s&&(n(s.context,t),s.refresh());}}var S=class{constructor(e,t=66,n=1){this.scene=e;this.depth=t;this.amount=n,f(e);}scene;depth;emitters=new Map;shot={tint:16777215,speedMin:0,speedMax:0,size:1,sizeEnd:0,life:400,lifeSpread:0,angleMin:0,angleMax:360};amount;emitter(e,t,n){let s=`${e}|${t?1:0}|${n}`,i=this.emitters.get(s);if(i)return i;let a=this.shot,o=(l,u)=>l+Math.random()*(u-l);return i=this.scene.add.particles(0,0,e,{emitting:false,lifespan:{onEmit:()=>a.life+Math.random()*a.lifeSpread},speed:{onEmit:()=>o(a.speedMin,a.speedMax)},angle:{onEmit:()=>o(a.angleMin,a.angleMax)},scale:{onEmit:()=>a.size/p,onUpdate:(l,u,m)=>(a.size+(a.sizeEnd-a.size)*m)/p},alpha:{onEmit:()=>1,onUpdate:(l,u,m)=>m<.65?1:1-(m-.65)/.35},rotate:{onEmit:()=>Math.random()*360},tint:{onEmit:()=>a.tint},gravityY:n,blendMode:t?z__default.default.BlendModes.ADD:z__default.default.BlendModes.NORMAL}),i.setDepth(this.depth),this.emitters.set(s,i),i}many(e){return Math.max(1,Math.round(e*this.amount))}fire(e,t,n,s,i,a,o){Object.assign(this.shot,{angleMin:0,angleMax:360,lifeSpread:0},o),this.emitter(e,t,n).explode(a,s,i);}burst(e){let t=this.many(e.n??12),n=e.size??60,s={speedMin:n*1.6,speedMax:n*4.2};this.fire(c.dot,false,n*9,e.x,e.y,Math.ceil(t*.65),{...s,tint:e.color,size:n*.26,sizeEnd:n*.06,life:380,lifeSpread:260}),this.fire(c.spark,true,n*5,e.x,e.y,Math.ceil(t*.35),{...s,tint:e.color,size:n*.5,sizeEnd:0,life:320,lifeSpread:220}),this.fire(c.dot,true,0,e.x,e.y,1,{tint:e.color,speedMin:0,speedMax:0,size:n*.9,sizeEnd:n*2.4,life:200});}confetti(e){let t=this.many(e.n??36),n=e.size??120,s=Math.max(1,Math.round(t/Math.max(1,e.colors.length)));for(let i of e.colors)this.fire(c.chip,false,n*5,e.x,e.y,s,{tint:i,speedMin:n*1.5,speedMax:n*4.5,angleMin:200,angleMax:340,size:n*.2,sizeEnd:n*.16,life:1100,lifeSpread:700});}sparkle(e){let t=e.size??40;this.fire(c.spark,true,-t*.6,e.x,e.y,this.many(e.n??5),{tint:e.color,speedMin:t*.3,speedMax:t*1.2,size:t*.55,sizeEnd:0,life:420,lifeSpread:320});}dust(e){let t=e.size??40;this.fire(c.puff,false,-t*.4,e.x,e.y,this.many(e.n??4),{tint:e.color,speedMin:t*.4,speedMax:t*1.3,angleMin:180,angleMax:360,size:t*.5,sizeEnd:t*1.3,life:380,lifeSpread:240});}ring(e){let t=e.size??60;this.fire(c.ring,true,0,e.x,e.y,1,{tint:e.color,speedMin:0,speedMax:0,size:t*.35,sizeEnd:t*1.5,life:380});}destroy(){for(let e of this.emitters.values())e.destroy();this.emitters.clear();}};var x=r=>Math.min(1,Math.max(0,r));function g(r){let e=/^#[0-9a-fA-F]{6}/.test(r)?r.slice(1,7):"ffffff";return [Number.parseInt(e.slice(0,2),16),Number.parseInt(e.slice(2,4),16),Number.parseInt(e.slice(4,6),16)]}var v=(r,e,t)=>`#${[r,e,t].map(n=>Math.round(Math.min(255,Math.max(0,n))).toString(16).padStart(2,"0")).join("")}`;function w(r){let[e,t,n]=g(r),s=e/255,i=t/255,a=n/255,o=Math.max(s,i,a),l=Math.min(s,i,a),u=(o+l)/2,m=o-l;if(m<1e-6)return [0,0,u];let M=m/(1-Math.abs(2*u-1)),h;return o===s?h=(i-a)/m%6:o===i?h=(a-s)/m+2:h=(s-i)/m+4,[(h*60+360)%360,x(M),u]}function b(r,e,t){let n=(r%360+360)%360,s=(1-Math.abs(2*t-1))*x(e),i=s*(1-Math.abs(n/60%2-1)),a=t-s/2,[o,l,u]=n<60?[s,i,0]:n<120?[i,s,0]:n<180?[0,s,i]:n<240?[0,i,s]:n<300?[i,0,s]:[s,0,i];return v((o+a)*255,(l+a)*255,(u+a)*255)}var D=.1,B=255,G=48;function P(r,e,t){let n=(e-r+540)%360-180;return r+Math.sign(n)*Math.min(Math.abs(n),t)}function F(r,e){let t=x(e);if(t===0)return v(...g(r));let[n,s,i]=w(r);return s<D?b(n,s,i+(Math.min(i,.05)-i)*t):b(P(n,B,34*t),x(s+(Math.max(s,.6)-s)*t+.14*Math.sin(Math.PI*t)),i+(Math.min(i,.07)-i)*t)}function T(r,e){let t=x(e);if(t===0)return v(...g(r));let[n,s,i]=w(r);return s<D?b(n,s,i+(1-i)*t):b(P(n,G,26*t),s+(Math.max(.5,s*.85)-s)*t,i+(Math.max(i,.95)-i)*t)}var y=class{constructor(e,t={}){this.steps=e;this.minFps=t.minFps??50,this.sampleSec=t.sampleSec??2,this.settleSec=t.settleSec??1,this.gain=t.gain??1.15,this.onStep=t.onStep,this.settle=this.settleSec*2;}steps;minFps;sampleSec;settleSec;gain;onStep;index=0;phase="watch";settle;time=0;frames=0;fpsA=0;fpsB=0;taken=[];get done(){return this.index>=this.steps.length}restart(e=0){this.time=0,this.frames=0,this.settle=e;}frame(e){if(this.done||!(e>0))return;if(e>.25){this.restart(this.settleSec);return}if(this.settle>0){this.settle-=e;return}if(this.time+=e,this.frames+=1,this.time<this.sampleSec)return;let t=this.frames/this.time,n=this.steps[this.index];if(this.phase==="watch"){if(t>=this.minFps){this.restart();return}this.fpsA=t,n.apply(),this.phase="try",this.restart(this.settleSec);return}if(this.phase==="try"){this.fpsB=t,n.revert(),this.phase="back",this.restart(this.settleSec);return}let s=this.fpsB>=Math.max(this.fpsA,t)*this.gain;s&&(n.apply(),this.taken.push(n.name)),this.onStep?.(n.name,s,this.fpsB),this.index+=1,this.phase="watch",this.restart(this.settleSec);}};function I(r,e,t,n=9e3){f(r);let s=e.vignette>0?r.add.image(0,0,c.vignette).setDepth(n).setAlpha(Math.min(1,e.vignette*1.5)).setScrollFactor(0):null,i=r.cameras.main,a=null,o=u=>{if(u===!!a)return;let m=i.filters?.external;m&&(u?(a=m.addColorMatrix(),a.colorMatrix.saturate(e.saturation-1),a.colorMatrix.contrast(e.contrast-1,true)):a&&(m.remove(a),a=null));},l=null;return t.post&&(e.saturation!==1||e.contrast!==1)&&(o(true),l=new y([{name:"post",apply:()=>o(false),revert:()=>o(true)}])),{resize(u,m,M=u/2,h=m/2){s?.setPosition(M,h).setDisplaySize(u,m);},setFilter:o,frame(u){l?.frame(u);},destroy(){o(false),s?.destroy();}}}function C(r,e,t,n,s,i=.6){return f(r),r.add.image(e,t,c.glow).setDisplaySize(n,n).setTint(s).setAlpha(i).setBlendMode(z__default.default.BlendModes.ADD)}function X(r,e,t,n,s=.32){return f(r),r.add.image(e,t,c.shadow).setDisplaySize(n,n*.3).setAlpha(s)}function _(r,e,t=-1e5){let n=`gfx:backdrop:${e}`;if(!r.textures.exists(n)){let o=r.textures.createCanvas(n,64,256);if(o){let l=o.context,u=l.createLinearGradient(0,0,0,256);u.addColorStop(0,T(e,.3)),u.addColorStop(.45,e),u.addColorStop(1,F(e,.32)),l.fillStyle=u,l.fillRect(0,0,64,256);let m=l.createRadialGradient(64/2,0,0,64/2,0,256*.7);m.addColorStop(0,"rgba(255,255,255,0.2)"),m.addColorStop(1,"rgba(255,255,255,0)"),l.fillStyle=m,l.fillRect(0,0,64,256),o.refresh();}}let s=r.textures.exists(n)?r.add.image(0,0,n).setDepth(t).setScrollFactor(0):null;return {resize(i,a,o=i/2,l=a/2){s?.setPosition(o,l).setDisplaySize(i,a);},destroy(){s?.destroy();}}}exports.FX=c;exports.FX_SIZE=p;exports.MAX_DENSITY=E;exports.Particles2D=S;exports.canvasDensity=A;exports.createBackdrop=_;exports.createFrameGrade=I;exports.ensureFxTextures=f;exports.glowSprite=C;exports.markDensity=H;exports.screenDensity=k;exports.shadowSprite=X;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import Phaser from 'phaser';
|
|
2
|
+
import { c as Mood, e as TierSettings } from '../moods-CROfsmd7.cjs';
|
|
3
|
+
|
|
4
|
+
/** Past this the screen is not sharper to the eye, only slower to fill. */
|
|
5
|
+
declare const MAX_DENSITY = 2;
|
|
6
|
+
/** The screen's density, capped. Baked art uses it once; the canvas may drop below it (see the controller). */
|
|
7
|
+
declare function screenDensity(): number;
|
|
8
|
+
/** The density the scene's canvas is drawn at right now (the Scale Manager's zoom is its inverse). */
|
|
9
|
+
declare function canvasDensity(scene: Phaser.Scene): number;
|
|
10
|
+
/**
|
|
11
|
+
* Tells Phaser a texture was drawn `k` times bigger than it should show: an image of it keeps the
|
|
12
|
+
* size it would have at `k = 1` (its `width`, `displayWidth`, `setDisplaySize`, hit area), only with
|
|
13
|
+
* `k` times the pixels. Phaser draws a texture divided by its source's `resolution` (that is how its
|
|
14
|
+
* own Text is sharp) but sizes a game object by the frame's `realWidth`, so both are set.
|
|
15
|
+
*
|
|
16
|
+
* ⚠ Only for textures shown by images and sprites. A particle emitter sizes its particles by the
|
|
17
|
+
* frame's PIXELS and ignores the resolution: a marked texture there comes out `k` times bigger.
|
|
18
|
+
* A TileSprite neither: it maps by pixels too (`Backdrop` scales its tiles itself).
|
|
19
|
+
*/
|
|
20
|
+
declare function markDensity(texture: Phaser.Textures.Texture, k: number): void;
|
|
21
|
+
|
|
22
|
+
declare const FX: {
|
|
23
|
+
readonly dot: "gfx:dot";
|
|
24
|
+
readonly spark: "gfx:spark";
|
|
25
|
+
readonly puff: "gfx:puff";
|
|
26
|
+
readonly chip: "gfx:chip";
|
|
27
|
+
readonly ring: "gfx:ring";
|
|
28
|
+
readonly star: "gfx:star";
|
|
29
|
+
/** A wide soft light: the halo behind a thing that shines. */
|
|
30
|
+
readonly glow: "gfx:glow";
|
|
31
|
+
/** A soft dark ellipse: the shadow under an actor. */
|
|
32
|
+
readonly shadow: "gfx:shadow";
|
|
33
|
+
/** Dark corners of the frame. */
|
|
34
|
+
readonly vignette: "gfx:vignette";
|
|
35
|
+
};
|
|
36
|
+
type FxTexture = (typeof FX)[keyof typeof FX];
|
|
37
|
+
/** Side of an effect picture, pixels. */
|
|
38
|
+
declare const FX_SIZE = 64;
|
|
39
|
+
/** Makes the effect pictures a scene's game does not have yet. Cheap to call again. */
|
|
40
|
+
declare function ensureFxTextures(scene: Phaser.Scene): void;
|
|
41
|
+
|
|
42
|
+
interface Burst2D {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
/** 0xRRGGBB. */
|
|
46
|
+
color: number;
|
|
47
|
+
/** How many (default 12). */
|
|
48
|
+
n?: number;
|
|
49
|
+
/** How far they fly, in the scene's units (default 60). */
|
|
50
|
+
size?: number;
|
|
51
|
+
}
|
|
52
|
+
declare class Particles2D {
|
|
53
|
+
private readonly scene;
|
|
54
|
+
private readonly depth;
|
|
55
|
+
private readonly emitters;
|
|
56
|
+
private readonly shot;
|
|
57
|
+
/** Share of a burst's particles really emitted (the tier's). */
|
|
58
|
+
amount: number;
|
|
59
|
+
constructor(scene: Phaser.Scene, depth?: number, amount?: number);
|
|
60
|
+
private emitter;
|
|
61
|
+
private many;
|
|
62
|
+
private fire;
|
|
63
|
+
/** Bright pieces flying out of a point and falling: a hit, a pickup, a thing breaking. */
|
|
64
|
+
burst(o: Burst2D): void;
|
|
65
|
+
/** Paper pieces of many colours thrown up and fluttering down: a win. */
|
|
66
|
+
confetti(o: {
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
colors: readonly number[];
|
|
70
|
+
n?: number;
|
|
71
|
+
size?: number;
|
|
72
|
+
}): void;
|
|
73
|
+
/** Glints twinkling around a point: a thing worth taking, a reward. */
|
|
74
|
+
sparkle(o: Burst2D): void;
|
|
75
|
+
/** A low cloud kicked up from the ground: a landing, a skid, running feet. */
|
|
76
|
+
dust(o: Burst2D): void;
|
|
77
|
+
/** A ring spreading from a point: a shock wave, a thing being placed. */
|
|
78
|
+
ring(o: Burst2D): void;
|
|
79
|
+
destroy(): void;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface FrameGrade {
|
|
83
|
+
/** The frame's size changed, in the scene's own units, and where its centre is. */
|
|
84
|
+
resize(width: number, height: number, centerX?: number, centerY?: number): void;
|
|
85
|
+
/** Drops the camera's colour pass (a slow device gives it up); the vignette stays. */
|
|
86
|
+
setFilter(on: boolean): void;
|
|
87
|
+
/**
|
|
88
|
+
* Feed it every frame's time in seconds and a slow device gives the colour pass up by itself, only
|
|
89
|
+
* when that is proven to help (AdaptiveQuality: A, B, A). A game that steps quality down itself does
|
|
90
|
+
* not call this.
|
|
91
|
+
*/
|
|
92
|
+
frame(dt: number): void;
|
|
93
|
+
destroy(): void;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The mood's saturation and contrast as ONE colour pass on the scene's main camera (mid and high tiers)
|
|
97
|
+
* and its vignette as a picture over the frame (every tier). `depth` must be above the game's field.
|
|
98
|
+
*/
|
|
99
|
+
declare function createFrameGrade(scene: Phaser.Scene, mood: Mood, tier: TierSettings, depth?: number): FrameGrade;
|
|
100
|
+
/** A soft light of a colour behind a thing that shines (a coin, a gem, a shot). `size` is its width. */
|
|
101
|
+
declare function glowSprite(scene: Phaser.Scene, x: number, y: number, size: number, color: number, alpha?: number): Phaser.GameObjects.Image;
|
|
102
|
+
/** A soft dark ellipse on the ground under an actor: `width` across, a third of it deep. */
|
|
103
|
+
declare function shadowSprite(scene: Phaser.Scene, x: number, y: number, width: number, alpha?: number): Phaser.GameObjects.Image;
|
|
104
|
+
interface Backdrop {
|
|
105
|
+
/** The frame's size changed, in the scene's own units, and where its centre is. */
|
|
106
|
+
resize(width: number, height: number, centerX?: number, centerY?: number): void;
|
|
107
|
+
destroy(): void;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The back of a frame out of ONE colour ("#rrggbb"): lighter and warmer at the top, deeper and cooler at
|
|
111
|
+
* the bottom, a soft light coming from above. A flat fill is what makes a puzzle's field look like a
|
|
112
|
+
* settings screen; this is one picture drawn first, on every tier. `depth` must be under the game's field.
|
|
113
|
+
*/
|
|
114
|
+
declare function createBackdrop(scene: Phaser.Scene, color: string, depth?: number): Backdrop;
|
|
115
|
+
|
|
116
|
+
export { type Backdrop, type Burst2D, FX, FX_SIZE, type FrameGrade, type FxTexture, MAX_DENSITY, Particles2D, canvasDensity, createBackdrop, createFrameGrade, ensureFxTextures, glowSprite, markDensity, screenDensity, shadowSprite };
|