Newer
Older
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
protected_dirs: ["assets", "style", "views", "standard"],
default_meta_keys: ["title", "description", "image", "open_graph", "json_ld"],
},
};
images_url: `/assets/images`,
data_url: `/assets/data`,
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
const MtlAnimation = require("./model/animation");
const MentaloEngine = require("./mentalo-engine");
const MtlScene = require("./model/scene");
const MtlGame = require("./model/game");
const MtlSoundTrack = require("./model/sound-track");
const SCENE_TYPES = require("./model/scene-types");
const MtlChoice = require("./model/choice");
const MtlGameObject = require("./model/game-object");
const FrameRateController = require("./lib/frame-rate-controller");
const font_tools = require("./lib/font-tools");
const color_tools = require("./lib/color-tools");
const shape_tools = require("./lib/shape-tools");
module.exports = {
MentaloEngine,
MtlAnimation,
MtlScene,
MtlGame,
MtlSoundTrack,
SCENE_TYPES,
MtlChoice,
MtlGameObject,
FrameRateController,
font_tools,
color_tools,
shape_tools,
};
},{"./lib/color-tools":5,"./lib/font-tools":6,"./lib/frame-rate-controller":7,"./lib/shape-tools":8,"./mentalo-engine":9,"./model/animation":10,"./model/choice":11,"./model/game":13,"./model/game-object":12,"./model/scene":17,"./model/scene-types":16,"./model/sound-track":18}],5:[function(require,module,exports){
"use strict";
/**
* Helpers to work with color values
*/
/**
* Get a RGB color value in String from either "rgb(x,x,x)" or #xxxxxx
* @param {String} color A RGB color value as String in the form: #ffffff or rgb(x,x,x)
* @returns {Array<Uint8>} An array of 3 values from 0 to 256 for [RED, GREEN, BLUE]
*/
function color_str_to_rgb_array(color) {
color = color.toLowerCase(0);
if (color.includes("rgb")) {
return color.replaceAll(/[a-z\(\)w]/g, "")
.split(",")
.slice(0, 3)
.map(n => parseInt(n));
} else {
return color.replace("#", "")
.match(/.{0,2}/g)
.slice(0, 3)
.map(hex => parseInt(hex, 16));
}
}
/**
* @param {String} color A color value (#xxxxxx or rbg(x,x,x))
* @returns The average between each tone of the given color.
*/
function get_average_rgb_color_tone(color) {
return color_str_to_rgb_array(color).reduce((tot, n) => tot + n / 3, 0);
}
/**
* Gets an array of 3 8bits integers for red green and blue and and return a color value as an hexadecimal string #xxxxxx
* @param {Array<Uint8>} rgb
* @returns {String} The hexacdecimal rgb value of the color including the hash character: #xxxxxx
*/
function rgb_array_to_hex(rgb) {
return `#${rgb.slice(0, 3).map(n => {
const hex = n.toString(16);
return hex.length < 2 ? '0' + hex : hex;
}).join('')}`;
}
/**
* Gets an array of 4 8bits integers for red green blue and transparency channel and return a color value as an hexadecimal string #xxxxxx
* @param {Array<Uint8>} rgb
* @returns {String} The hexacdecimal rgba value of the color including the hash character: #xxxxxxxx
*/
function rgba_array_to_hex(rgba) {
rgba = rgba.length === 4 ? rgba : rgba.concat([255])
return `#${rgba.slice(0, 4).map(n => {
const hex = n.toString(16);
return hex.length < 2 ? '0' + hex : hex;
}).join('')}`;
}
/**
* Gets a background color as argument and return a calculated optimal foreground color.
* For example if the background is dark the function will return a lighten version of the background.
* @param {String} base_color A RGB color value in hexadecimal form: #ffffff
* @returns
*/
function get_optimal_visible_foreground_color(base_color) {
// create a 2D 1px canvas context
const tmp_canvas = document.createElement("canvas");
tmp_canvas.width = 1;
tmp_canvas.height = 1;
const ctx = tmp_canvas.getContext("2d");
// fill it with the given color
ctx.fillStyle = base_color;
ctx.fillRect(0, 0, 1, 1);
// Get either a semi-transparent black or semi-transparent white regarding the base color is above or below an avg of 127
const superpo_color = get_average_rgb_color_tone(base_color) > 127 ? "#0000003f" : "#ffffff3f";
// Fill the pixel with the semi-transparent black or white on top of the base color
ctx.fillStyle = superpo_color;
ctx.fillRect(0, 0, 1, 1);
// Return the flatten result of the superposition
return rgb_array_to_hex(Array.from(ctx.getImageData(0, 0, 1, 1).data));
}
/**
* @param {Array<Uint8; 4>} col1 A RGBA color value as an array of 4 0 to 256 integers
* @param {Array<Uint8; 4>} col2 A RGBA color value as an array of 4 0 to 256 integers
* @returns {Boolean} true if the 2 colors are equals
*/
function same_rgba(col1, col2) {
return col1[0] === col2[0]
&& col1[1] === col2[1]
&& col1[2] === col2[2]
&& col1[3] === col2[3];
}
module.exports = {
get_average_rgb_color_tone,
get_optimal_visible_foreground_color,
color_str_to_rgb_array,
rgb_array_to_hex,
rgba_array_to_hex,
same_rgba,
};
},{}],6:[function(require,module,exports){
"use strict";
/**
* Helpers to works with default web fonts
*/
const FONT_FAMILIES = [
{
category: "Sans serif", values: [
{ value: "sans-serif", text: "sans-serif" },
{ text: "Arial", value: "Arial, sans-serif" },
{ text: "Helvetica", value: "Helvetica, sans-serif" },
{ text: "Verdana", value: "Verdana, sans-serif" },
{ text: "Trebuchet MS", value: "Trebuchet MS, sans-serif" },
{ text: "Noto Sans", value: "Noto Sans, sans-serif" },
{ text: "Gill Sans", value: "Gill Sans, sans-serif" },
{ text: "Avantgarde", value: "Avantgarde, TeX Gyre Adventor, URW Gothic L, sans-serif" },
{ text: "Optima", value: "Optima, sans-serif" },
{ text: "Arial Narrow", value: "Arial Narrow, sans-serif" }
],
},
{
category: "Serif", values: [
{ text: "serif", value: "serif" },
{ text: "Times", value: "Times, Times New Roman, serif" },
{ text: "Didot", value: "Didot, serif" },
{ text: "Georgia", value: "Georgia, serif" },
{ text: "Palatino", value: "Palatino, URW Palladio L, serif" },
{ text: "Bookman", value: "Bookman, URW Bookman L, serif" },
{ text: "New Century Schoolbook", value: "New Century Schoolbook, TeX Gyre Schola, serif" },
{ text: "American Typewriter", value: "American Typewriter, serif" }
],
},
{
category: "Monospace", values: [
{ text: "monospace", value: "monospace" },
{ text: "Andale Mono", value: "Andale Mono, monospace" },
{ text: "Courrier New", value: "Courier New, monospace" },
{ text: "Courrier", value: "Courier, monospace" },
{ text: "FreeMono", value: "FreeMono, monospace" },
{ text: "OCR A Std", value: "OCR A Std, monospace" },
{ text: "DejaVu Sans Mono", value: "DejaVu Sans Mono, monospace" },
],
},
{
Loading
Loading full blame...