You can now specify the glyph font by name in the URL.

This commit is contained in:
Rezmason
2021-12-21 15:00:15 -08:00
parent 38f29ad21b
commit 22f3ab4092
2 changed files with 15 additions and 18 deletions

View File

@@ -77,6 +77,7 @@ Now you know link fu. Here's a list of customization options:
- "operator" is more reminiscent of the matrix code as it appears in the first movie's opening titles, and on operators' screens: flatter, crowded, without a gradient, and with occasional effects (such as a square ripple). - "operator" is more reminiscent of the matrix code as it appears in the first movie's opening titles, and on operators' screens: flatter, crowded, without a gradient, and with occasional effects (such as a square ripple).
- "paradise" is how the Matrix's idyllic predecessor may have appeared: warm, simplistic, encompassing. - "paradise" is how the Matrix's idyllic predecessor may have appeared: warm, simplistic, encompassing.
- "nightmare" is how the Matrix may have appeared in the Merovingian's heyday: flashy, foreboding, relentless. - "nightmare" is how the Matrix may have appeared in the Merovingian's heyday: flashy, foreboding, relentless.
- **font** - the set of glyphs to draw. Current options are "matrixcode", "resurrections", "gothic", "coptic", "huberfishA", and "huberfishD".
- **width** - the number of columns (and rows) to draw. Default is 80. - **width** - the number of columns (and rows) to draw. Default is 80.
- **volumetric** - when set to "true", this renders the glyphs with depth, slowly approaching the eye. Default is "false". - **volumetric** - when set to "true", this renders the glyphs with depth, slowly approaching the eye. Default is "false".
- **density** - the number of 3D raindrops to draw, proportional to the default. Default is 1.0. - **density** - the number of 3D raindrops to draw, proportional to the default. Default is 1.0.

View File

@@ -82,12 +82,10 @@ const defaults = {
const versions = { const versions = {
classic: { classic: {
...defaults, font: "matrixcode",
...fonts.matrixcode,
}, },
operator: { operator: {
...defaults, font: "matrixcode",
...fonts.matrixcode,
bloomStrength: 0.75, bloomStrength: 0.75,
highPassThreshold: 0.0, highPassThreshold: 0.0,
cycleSpeed: 0.2, cycleSpeed: 0.2,
@@ -109,8 +107,7 @@ const versions = {
raindropLength: 1.5, raindropLength: 1.5,
}, },
nightmare: { nightmare: {
...defaults, font: "gothic",
...fonts.gothic,
highPassThreshold: 0.7, highPassThreshold: 0.7,
brightnessDecay: 0.75, brightnessDecay: 0.75,
fallSpeed: 1.2, fallSpeed: 1.2,
@@ -127,8 +124,7 @@ const versions = {
slant: (22.5 * Math.PI) / 180, slant: (22.5 * Math.PI) / 180,
}, },
paradise: { paradise: {
...defaults, font: "coptic",
...fonts.coptic,
bloomStrength: 1, bloomStrength: 1,
highPassThreshold: 0, highPassThreshold: 0,
cycleSpeed: 0.1, cycleSpeed: 0.1,
@@ -149,8 +145,7 @@ const versions = {
raindropLength: 0.4, raindropLength: 0.4,
}, },
resurrections: { resurrections: {
...defaults, font: "matrixcode",
...fonts.matrixcode,
resurrectingCodeRatio: 0.25, resurrectingCodeRatio: 0.25,
glyphVerticalSpacing: 1.5, glyphVerticalSpacing: 1.5,
effect: "resurrections", effect: "resurrections",
@@ -159,8 +154,7 @@ const versions = {
fallSpeed: 0.4, fallSpeed: 0.4,
}, },
updated: { updated: {
...defaults, font: "resurrections",
...fonts.resurrections,
numColumns: 108, numColumns: 108,
fallSpeed: 0.35, fallSpeed: 0.35,
cycleStyle: "cycleRandomly", cycleStyle: "cycleRandomly",
@@ -176,8 +170,7 @@ const versions = {
cursorEffectThreshold: 0.8, cursorEffectThreshold: 0.8,
}, },
palimpsest: { palimpsest: {
...defaults, font: "huberfishA",
...fonts.huberfishA,
bloomStrength: 0.2, bloomStrength: 0.2,
numColumns: 40, numColumns: 40,
raindropLength: 1.2, raindropLength: 1.2,
@@ -191,8 +184,7 @@ const versions = {
], ],
}, },
twilight: { twilight: {
...defaults, font: "huberfishD",
...fonts.huberfishD,
bloomStrength: 0.3, bloomStrength: 0.3,
numColumns: 50, numColumns: 50,
raindropLength: 0.9, raindropLength: 0.9,
@@ -210,8 +202,7 @@ const versions = {
}, },
holoplay: { holoplay: {
...defaults, font: "resurrections",
...fonts.resurrections,
numColumns: 20, numColumns: 20,
fallSpeed: 0.35, fallSpeed: 0.35,
cycleStyle: "cycleRandomly", cycleStyle: "cycleRandomly",
@@ -244,6 +235,7 @@ const nullNaN = (f) => (isNaN(f) ? null : f);
const paramMapping = { const paramMapping = {
version: { key: "version", parser: (s) => s }, version: { key: "version", parser: (s) => s },
font: { key: "font", parser: (s) => s },
effect: { key: "effect", parser: (s) => s }, effect: { key: "effect", parser: (s) => s },
width: { key: "numColumns", parser: (s) => nullNaN(parseInt(s)) }, width: { key: "numColumns", parser: (s) => nullNaN(parseInt(s)) },
numColumns: { key: "numColumns", parser: (s) => nullNaN(parseInt(s)) }, numColumns: { key: "numColumns", parser: (s) => nullNaN(parseInt(s)) },
@@ -291,9 +283,13 @@ export default (urlParams) => {
); );
const version = validParams.version in versions ? versions[validParams.version] : versions.classic; const version = validParams.version in versions ? versions[validParams.version] : versions.classic;
const fontName = [validParams.font, version.font, defaults.font].find((name) => name in fonts);
const font = fonts[fontName];
return { return {
...defaults,
...version, ...version,
...font,
...validParams, ...validParams,
}; };
}; };