This repository has been archived by the owner on Jan 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex-en.html
252 lines (210 loc) · 8.55 KB
/
index-en.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>txt2img</title>
<link rel="stylesheet" href="./style.css">
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css"
href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css"/>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r121/three.min.js" integrity="sha512-yNJzAsg5JyP91u+sLHlUDULMBd3hmEiVkYeeN1cQBKaLZ7EyT6oH2u5THNIRM2Fu6VKcZJv+F/QAp1h/qzy9Ow==" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css"
integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
</head>
<body>
<a id="info" class="info" >
<span class="fab fas fa-info-circle"></span>
<span class="text">About</span>
</a>
<a id="screenshot" class="info" >
<span class="fab fas fa-camera-retro fa-2x"></span>
<span class="text">Save image</span>
</a>
<!------------------------------------------------------>
<!-- <a id="btn" class="info"> -->
<!-- <span class="fab fas fa-plus-circle "></span> -->
<!-- <span class="text">Add background image</span> -->
<!-- </a> -->
<!------------------------------------------------------>
<a id="btn2" class="info" >
<span class="fab fas fa-align-center "></span>
<span class="text">Toggle editor</span>
</a>
<div id="addSourceImage" class="modal">
<div class="modal-header">
<p>Visible Image</p>
<span class="close">×
</span>
</div>
<div class="modal-content">
<form enctype="multipart/form-data">
<input class="button" id="uploadSource" type="file"/>
<label for="uploadSource">Upload image that will be visible</label>
</form>
</div>
</div>
<div id="showInfo" class="modal">
<div class="modal-header">
<h2>CAblam</h2>
<span class="close">×
</span>
</div>
<div class="modal-content">
<form enctype="multipart/form-data">
<p> This tool was created for the <a href="https://hyperlink.academy/courses/digital-alchemy/89">Digital Alchemy Course</a>.
<h3>WHAT</h3>
It is a Livecoding environment for creating visual effects while writing ASCII characters.
<p>It was built to create an environment language-agnostic for performing. It uses <a href="https://en.wikipedia.org/wiki/Cellular_automaton">Cellular automaton</a> simulation over source (webcam capture/image) </p>
<h3>HOW</h3>
<p>Write on the floating black square</p>
<p>ASCII characters are being interpretated as numbers, updating CA rules.</p>
<p>Special charaters defined in the <b>Controls</b> folder are mapped to handle: </p>
<ul>
<li>rule threshold: controls the <i>amount</i> of effect</li>
<li>pixel size </li>
<li>saturation: controls the color saturation</li>
<li>hue: performs hue shifts</li>
</ul>
</form>
</div>
</div>
<a href="https://github.com/solsarratea/CAblam" class="info"
title="View source on Github" target="_blank">
<span class="fab fa-github"></span>
<span class="text">View source</span>
</a>
<a href="https://twitter.com/share?ref_src=twsrc%5Etfw" class="info" id="tweetB" target="_blank">
<i class="fab fa-twitter"></i>
<span class="text">Share</span>
</a>
<a href='https://ko-fi.com/Q5Q62LLVG' class="info" target="_blank">
<span class="fab fa-gratipay"></span>
<span class="text">Support </span>
</a>
<div class="editor" id="editor">
<textarea
id=textarea
spellcheck=false
oninput="update(this.value)"
placeholder="Write your text"
autofocus
></textarea>
</div>
<div id="shadercollab"></div>
<canvas id="canvas"></canvas>
<script id="vertex" type="x-shader/x-vertex">
varying vec2 texCoordVarying;
void main() {
texCoordVarying = uv;
gl_Position = projectionMatrix*modelViewMatrix*vec4(position,1.0);
}
</script>
<script id="copy" type="x-shader/x-fragment">
varying vec2 texCoordVarying;
uniform sampler2D channel0;
vec2 rotate(vec2 v, float a) {
return mat2(cos(a), -sin(a), sin(a), cos(a))*v;
}
void main() {
vec4 inText = texture2D(channel0,texCoordVarying);
gl_FragColor = inText;
}
</script>
<script id="diffusion" type="x-shader/x-fragment">
uniform sampler2D webcam;
uniform sampler2D backbuffer;
uniform float time;
uniform float resoluton;
uniform int rule[18];
uniform float offset1;
uniform float offset2;
uniform float offset3;
uniform float offset4;
uniform bool modo1;
varying vec2 texCoordVarying;
uniform vec2 resolution;
const vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 hsv2rgb(vec3 c) {
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
vec3 hueShift( vec3 color, float hueAdjust ){
const vec3 kRGBToYPrime = vec3 (0.299, 0.587, 0.114);
const vec3 kRGBToI = vec3 (0.596, -0.275, -0.321);
const vec3 kRGBToQ = vec3 (0.212, -0.523, 0.311);
const vec3 kYIQToR = vec3 (1.0, 0.956, 0.621);
const vec3 kYIQToG = vec3 (1.0, -0.272, -0.647);
const vec3 kYIQToB = vec3 (1.0, -1.107, 1.704);
float YPrime = dot (color, kRGBToYPrime);
float I = dot (color, kRGBToI);
float Q = dot (color, kRGBToQ);
float hue = atan (Q, I);
float chroma = sqrt (I * I + Q * Q);
hue += hueAdjust;
Q = chroma * sin (hue);
I = chroma * cos (hue);
vec3 yIQ = vec3 (YPrime, I, Q);
return vec3( dot (yIQ, kYIQToR), dot (yIQ, kYIQToG), dot (yIQ, kYIQToB) );
}
precision highp float;
#define M_PI 3.1415926535897932384626433832795
vec3 satur(vec3 cin, float amount ){
const vec3 W = vec3(0.2125, 0.7154, 0.0721);
vec3 intensity = vec3(dot(cin.rgb, W));
return mix(intensity, cin.rgb, amount);
}
vec2 modulate(vec2 st, vec2 tex, float amount){
return st+ tex*amount;
}
vec3 modulate(vec3 st, vec3 tex, float amount){
return st+ tex*amount;
}
float luma(vec3 color) {
return dot(color, vec3(0.299, 0.587, 0.114));
}
void main() {
vec2 pixel = gl_FragCoord.xy / resolution;
vec3 finalColor;
vec3 webcamCapture = texture2D(webcam, pixel).rgb;
vec3 lastFrame = texture2D(backbuffer, pixel).rgb;
vec3 color = texture2D(backbuffer, pixel).rgb;
color = hsv2rgb(color);
float pixelSize = 1.+mix(-.5,200.,offset2);
vec2 pos =
vec2(floor(gl_FragCoord.x / pixelSize) * pixelSize + pixelSize / 2.0,
floor(gl_FragCoord.y / pixelSize) * pixelSize + pixelSize / 2.0);
float threshold = 0.49 +mix(-.5,.5,offset1);
float neighbors = 0.0;
for (float y = -1.0; y <= 1.0; y++) {
for (float x = -1.0; x <= 1.0; x++) {
vec4 pixelC = texture2D(
backbuffer, (pos + vec2(x * pixelSize, y * pixelSize)) / resolution);
neighbors += step(threshold, pixelC.r);
}
};
float status = step(threshold, color.r); //status = previousState
neighbors -= status; //neighbors == total
int ruleIndex = int(mix(neighbors, 2.*neighbors, 1.-status));
float newState = float(rule[ruleIndex]);
vec3 webAfter = texture2D(webcam, pixel+newState*0.05*vec2(cos(time*0.5),sin(time*0.5))).rgb;
vec3 render = mix(webAfter, max(webcamCapture,lastFrame), 1.-luma(color));
render = satur(render, mix(0.,3.,offset3));
render = hueShift(render, mix(0.,3.,offset4));
vec3 bb = texture2D(backbuffer, pixel).rgb;
render = mix(mix(render,bb*bb-bb*4.,0.2), webAfter, newState)*float(1.-float(modo1));
gl_FragColor = vec4(mix(render,webcamCapture,float(modo1)),1.);
}
</script>
<!-- partial -->
<script type="text/javascript" src="libs/dat.gui.min.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js'></script>
<script src="./libs/controls.js"></script>
<script src="./libs/fileSaver.js"></script>
<script src="./script.js"></script>
</body>
</html>