Skip to content

Host dev folder #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 131 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
65b8628
update sora font
YitingLiu97 May 21, 2024
ade2d63
installing dependency by using "npm install --legacy-peer-deps"
YitingLiu97 May 21, 2024
e665606
include video and image assets
YitingLiu97 May 21, 2024
1072160
testing mov does not work for now due to wrong codec- should be h 264
YitingLiu97 May 21, 2024
e47bf56
including test video as it works
YitingLiuSia May 22, 2024
082aca9
beautify the playground js
YitingLiuSia May 22, 2024
679d1ad
transparent background for both html and canvas renderers
YitingLiuSia May 22, 2024
69cf4fd
adding vesion number and migrating the folder for index to be the mai…
YitingLiuSia May 23, 2024
d50f532
testing text
YitingLiuSia May 23, 2024
64d3b0b
place assets in www folder
YitingLiuSia May 23, 2024
860fd98
remove the assets and revert back to the original file structure
YitingLiuSia May 23, 2024
9dee570
relative path
YitingLiuSia May 23, 2024
b872e0f
import video same as import image
YitingLiuSia May 23, 2024
9e43db2
add the video stuff and test
YitingLiuSia May 23, 2024
4aa35e6
convert to the video and color changes
YitingLiuSia May 23, 2024
18121d8
clear video code and color is working in production too
YitingLiuSia May 23, 2024
b352f46
removing the font in the html
YitingLiu97 May 24, 2024
841a937
trying to fix the font text and added a new one for comparison
YitingLiu97 May 24, 2024
97740bb
hide background color, hide the html selection since we wont use it
YitingLiu97 May 24, 2024
6b691a8
add sia test and it is working with sora font - statically
YitingLiu97 May 24, 2024
1f5be58
change font background to transparent
YitingLiu97 May 24, 2024
6dc91ea
add sora instead of monospace for placeholder - only works in canvas
YitingLiu97 May 24, 2024
474f890
gradient is slightly working in selection but not application
YitingLiu97 May 24, 2024
c9afe0c
gradient created with sia branding but it is not intersecting with th…
YitingLiu97 May 24, 2024
f2c175d
gradient selection not reflected on input
YitingLiu97 May 24, 2024
a510d31
font still has issue. i think it is the google font situation since t…
YitingLiuSia May 29, 2024
38eae3c
figured out the font is not monospaced for sora but the new one Rubik…
YitingLiuSia May 29, 2024
630a1a0
testing out font size and discovred selecting color would be better -…
YitingLiuSia May 29, 2024
294274c
very simple import image and video - better than the extensive UI sel…
YitingLiuSia May 29, 2024
decff80
able to download the video now
YitingLiuSia May 29, 2024
809a42b
creating an archive for dev folder
YitingLiuSia May 30, 2024
9bfb04a
adding simple interface instead - gradient picker and import vid imag…
YitingLiuSia May 30, 2024
36ecc0f
gradient succesfully saved and loaded
YitingLiuSia May 30, 2024
4e39068
wip on rendering at the same image id
YitingLiuSia May 30, 2024
9ef9c98
include aalib js and save image to canvas instead of html
YitingLiuSia May 30, 2024
4ec529a
adding canvas and html selections
YitingLiuSia May 30, 2024
54ca4da
update the image save with set id from index - generateID still funky
YitingLiuSia May 30, 2024
4f966e7
cleanup script
YitingLiuSia May 30, 2024
7e8936f
add font selection
YitingLiu97 May 31, 2024
60978c4
adding new fonts for font selction feature
YitingLiu97 Jun 3, 2024
61ec514
adding ttf font for sora
YitingLiu97 Jun 3, 2024
6a2ec01
preset loading
YitingLiu97 Jun 3, 2024
217fe76
adding other elements in html
YitingLiu97 Jun 3, 2024
f5a2fce
adding charset
YitingLiu97 Jun 3, 2024
8c6956f
elements update
YitingLiu97 Jun 3, 2024
771d221
engage with interactons with buttons
YitingLiu97 Jun 3, 2024
3ddad76
add updating preset info
YitingLiu97 Jun 3, 2024
dfaba91
save and load for preset both work just need to upload the loading
YitingLiu97 Jun 3, 2024
2976f5c
still need to work on the update on the UI
YitingLiu97 Jun 3, 2024
2a2d1b9
adding value to sliders
YitingLiu97 Jun 4, 2024
1e9d011
slider value upadted
YitingLiu97 Jun 4, 2024
7efe7fe
preset save and load with full function
YitingLiu97 Jun 4, 2024
b9819c7
wip resolution
YitingLiu97 Jun 4, 2024
1a592a3
removing unused code and working on the resolution
YitingLiu97 Jun 4, 2024
a7d48c0
testing for the load image and replace it without adding more
YitingLiuSia Jun 5, 2024
4929765
image manipulation is working but not the replacement of image yet
YitingLiuSia Jun 5, 2024
5497fad
image is replaceable upon slider change now and gradient
YitingLiuSia Jun 5, 2024
84ad274
update gradient on replaced image
YitingLiuSia Jun 5, 2024
b7b4dfe
updated sia brand color
YitingLiuSia Jun 5, 2024
98220c7
update elements for change
YitingLiuSia Jun 5, 2024
fad04c9
charset selection working and sia can be default
YitingLiuSia Jun 5, 2024
0d3a4eb
add mini step
YitingLiuSia Jun 5, 2024
c3d1b94
update default preset info json
YitingLiuSia Jun 5, 2024
a87936f
update the character selector
YitingLiuSia Jun 5, 2024
a3f1464
need to set the charset selection still
YitingLiuSia Jun 5, 2024
f58edc5
hide video and save gradient button
YitingLiuSia Jun 6, 2024
9df9a79
charset updated
YitingLiuSia Jun 6, 2024
001663d
all things updated upon the slider changes
YitingLiuSia Jun 6, 2024
1d87322
display imported image and processed image on the side and only displ…
YitingLiuSia Jun 6, 2024
09784af
image is updated
YitingLiuSia Jun 6, 2024
db91791
load gradient hidden
YitingLiuSia Jun 6, 2024
23b8abd
experiment with the image size
YitingLiuSia Jun 6, 2024
c548149
adding the ascii ratio wip
YitingLiuSia Jun 6, 2024
b7163d6
make better UI
YitingLiuSia Jun 6, 2024
d710b82
remove desaturation and desaturate since they are not useful
YitingLiuSia Jun 6, 2024
f703c87
update ui to be more interactive and beautiful
YitingLiuSia Jun 6, 2024
ee971e4
center the containers for sliders
YitingLiuSia Jun 6, 2024
fd241ba
beautiful the ui and it is more convenient to use
YitingLiuSia Jun 6, 2024
8d603e0
dont think font size is reflected
YitingLiuSia Jun 6, 2024
ecf3540
update the size
YitingLiu97 Jun 10, 2024
00faa88
html canvas can have the color but not the gradient yet
YitingLiu97 Jun 10, 2024
4414ce6
still only changing the color - gradient function is not working
YitingLiu97 Jun 10, 2024
7ec207a
imported fonts and font change the canvas or html change would reflec…
YitingLiu97 Jun 10, 2024
c8a73d0
update new fonts
YitingLiu97 Jun 10, 2024
3c021f6
update font selection - remove duplicates of brightnessele, add new p…
YitingLiu97 Jun 11, 2024
a456770
update the preset info to work well with Sora
YitingLiu97 Jun 11, 2024
d837f3b
update the preset for the filteres
YitingLiu97 Jun 11, 2024
0aaafbe
set up the character set
YitingLiu97 Jun 11, 2024
4b469e0
gradient now works by setting to the image width
YitingLiu97 Jun 11, 2024
a2909f6
update the preset when first loading the image
YitingLiuSia Jun 12, 2024
ec46645
save image as different sizes
YitingLiuSia Jun 12, 2024
31b121a
relatively working with resize of the image when changing the parameters
YitingLiuSia Jun 12, 2024
9b6c3b7
adding the scroll on y on image import
YitingLiuSia Jun 12, 2024
712ef86
removing the font family variable
YitingLiuSia Jun 12, 2024
8a87348
adding vertical scroll for the right side
YitingLiuSia Jun 12, 2024
b538f51
updating the image selection for gradients
YitingLiuSia Jun 12, 2024
d8bb019
set up font family for specific dropdown
YitingLiuSia Jun 12, 2024
2aa45df
update the sora font to the body
YitingLiuSia Jun 12, 2024
862e243
inculde sia branding
YitingLiuSia Jun 12, 2024
a42eb05
update more branding
YitingLiuSia Jun 12, 2024
4f4ec1e
sia new branding
YitingLiuSia Jun 12, 2024
b4d2f47
update the branding
YitingLiuSia Jun 12, 2024
a88591f
resize the image successfully!
YitingLiuSia Jun 13, 2024
8c51bd3
scroll bar rounding function working
YitingLiuSia Jun 13, 2024
7f116f5
mini tweak - center the image
YitingLiuSia Jun 13, 2024
fcc1ecc
testing quite weird
YitingLiuSia Jun 13, 2024
1c30d86
image to be the right side of the import image info
YitingLiu97 Jun 14, 2024
1461b83
image pos set
YitingLiu97 Jun 14, 2024
2381c6a
adjust image to be vertically fitting too
YitingLiu97 Jun 14, 2024
dfc2c66
finetweak again
YitingLiu97 Jun 14, 2024
e166f07
design tweak done
YitingLiu97 Jun 14, 2024
fb8fe40
update style for the buttons, and chat bottom
YitingLiu97 Jun 14, 2024
eaf3c29
image expanded to canvas but when you change the font parameters, can…
YitingLiuSia Jun 17, 2024
b9c2b17
make sure horizontal scroll bar has the same thickness, imported imag…
YitingLiuSia Jun 17, 2024
d8d86ef
change font selection to character setting
YitingLiuSia Jun 17, 2024
192e519
setting the processed image container to be separated
YitingLiuSia Jun 17, 2024
2fbce46
increasing preset size
YitingLiuSia Jun 17, 2024
0713489
resizing was working and updated preset info
YitingLiuSia Jun 17, 2024
3068c80
look for main js instead
YitingLiuSia Jun 17, 2024
762e19d
Set up base files
SimonAttfield Jun 17, 2024
58bf152
Building in dev folder
SimonAttfield Jun 17, 2024
dc5120a
Merge branch 'simple-fun-working-text' into host-dev-folder
SimonAttfield Jun 17, 2024
8417b04
seems to work
SimonAttfield Jun 18, 2024
0b281e3
remove main js in the index html for now
YitingLiu97 Jun 18, 2024
62e9ec9
adding proportional lineheight
YitingLiu97 Jun 18, 2024
4915447
adding temp three presets for selections
YitingLiu97 Jun 18, 2024
4437f6d
.
SimonAttfield Jun 18, 2024
24c70ba
Created bash script
SimonAttfield Jun 18, 2024
5942f40
Merge branch 'simple-fun-working-text' into host-dev-folder
SimonAttfield Jun 18, 2024
9f0967f
updating webpack
SimonAttfield Jun 18, 2024
9cd4d92
upload json file for the first preset
YitingLiu97 Jun 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.idea
*~
*~
.env
39 changes: 39 additions & 0 deletions _devCopy/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>aalib.js</title>
<script type="text/javascript" defer src="bundle.js"></script>
<style>
canvas {
border: 1px solid red;
}

canvas, pre {
font-size: 7px;
display: block;
text-align: center;
border: 1px solid #efefef;
}
</style>
</head>
<body>

hello im sia dev
<h1> Import Video</h1>
<p>Video Settings</p>
<input type="file" id="videoInput" accept="video/*">
<div id="video-container"></div>

<button id="startRecording">Start Recording</button>
<button id="stopAndDownload">Stop and Download</button>
<canvas id="video-scene"></canvas>

<h1>Import Image</h1>

<p>Image Settings</p>
<input type="file" id="imageInput" accept="image/*">
<div id="image-container"></div>

</body>
</html>
237 changes: 237 additions & 0 deletions _devCopy/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
import "rxjs/add/operator/do";

import ImageReader from "../src/readers/ImageReader";
import VideoReader from "../src/readers/VideoReader";
import ImageDataReader from "../src/readers/ImageDataReader";

import inverse from "../src/filters/inverse";
import contrast from "../src/filters/contrast";
import brightness from "../src/filters/brightness";
import linear from "../src/filters/linear";

import aa from "../src/aa";

import html, { ASCII_CHARSET } from "../src/renderers/HTMLRenderer";
import videoCanvas from "../src/renderers/CanvasRenderer";

import { appendToBody } from "./utils";

const charset = ASCII_CHARSET;
const resource = filename => `../resources/${ filename }`;

const RES = {
MONA: resource("mona.png"),
LENNA: resource("lenna.png"),
MARYLIN: resource("marylin.jpg"),
BBB: resource("bbb_720x480_30mb.mp4")
};

function pipeline(...args) {
const src = args.shift();

args
.reduce((acc, it) => acc.map(it), src)
.subscribe();
}

function mona() {
pipeline(
ImageReader.fromURL(RES.MONA),
aa({ width: 200, height: 160, colored: false }),
html({ charset }),
appendToBody
);
}


function idata() {
const drawingCanvas = document.createElement("canvas");
drawingCanvas.width = "320";
drawingCanvas.height = "240";
appendToBody(drawingCanvas);

const ctx = drawingCanvas.getContext("2d");
ctx.fillStyle = "#222";
ctx.fillRect(0, 0, 160, 240);
ctx.fillStyle = "#eee";
ctx.fillRect(160, 0, 160, 240);
ctx.fillStyle = "#999";
ctx.fillRect(160-40, 120-40, 80, 80);

ImageDataReader.fromCanvas(drawingCanvas)
.map(aa({ width: 80, height: 25, colored: false }))
.map(html({ charset }))
.do(appendToBody)
.subscribe();
}

function localImage() {
const filePicker = document.createElement("input");
filePicker.type = "file";
filePicker.addEventListener("change", createFileHandler(createAA));

appendToBody(filePicker);

function createFileHandler(createAA) {
return (e) => {
const file = e.target.files[0];
const reader = new FileReader();
reader.onload = (e) => {
createAA(e.target.result);
};

reader.readAsDataURL(file);
};
}

function createAA(imageUrl) {
ImageReader.fromURL(imageUrl)
.map(aa({ width: 210, height: 105, colored: false }))
.map(html({ charset }))
.do((el) => {
filePicker.parentNode.insertBefore(el, filePicker.nextSibling);
})
.subscribe();
}
}

function bbb() {
const scene = document.createElement("canvas");
const video = document.createElement("video");
video.src = "../resources/bbb_720x480_30mb.mp4";
video.controls = true;

appendToBody(video);
appendToBody(scene);

VideoReader.fromVideoElement(video, { autoplay: false })
.map(aa({ width: 165, height: 68, colored: true }))
.map(videoCanvas({
charset,
width: 696,
height: 476,
el: scene
}))
.subscribe();
}



let videoCanvasElement = document.getElementById('video-scene');
let mediaRecorder;
let recordedChunks = [];
setupMediaRecorder(videoCanvasElement);
document.getElementById('startRecording').addEventListener('click', startRecording);
document.getElementById('stopAndDownload').addEventListener('click', stopRecording);

function setupMediaRecorder(canvas) {
const stream = canvas.captureStream(25); // Capture at 25 fps
mediaRecorder = new MediaRecorder(stream, { mimeType: 'video/webm; codecs=vp9' });

mediaRecorder.ondataavailable = function (event) {
if (event.data.size > 0) {
recordedChunks.push(event.data);
}
};

mediaRecorder.onstop = function () {
const blob = new Blob(recordedChunks, {
type: 'video/mp4'
});
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
a.download = 'downloaded_video.mp4';
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
recordedChunks = []; // Clear the recorded chunks
};
} function startRecording() {
mediaRecorder.start();
console.log("Recording started");
}

function stopRecording() {
mediaRecorder.stop();
console.log("Recording stopped");
}
function fromVideoFile(file) {
return new Promise((resolve, reject) => {
const video = document.createElement('video');
console.log("url ", URL.createObjectURL(file));
video.src = URL.createObjectURL(file);
video.controls = true; // Add controls so users can play/pause
video.autoplay = true; // Set autoplay to true to start playing automatically
video.muted = true; // Mute the video to allow autoplay in most browsers
video.loop = true; // Optional: Loop the video

video.onloadedmetadata = () => {
document.getElementById('video-container').appendChild(video); // Append to a specific container
resolve(video);
};

video.onerror = () => {
reject(new Error("Failed to load video"));
};
});
}

document.getElementById('videoInput').addEventListener('change', function (event) {
const file = event.target.files[0];
if (file) {
fromVideoFile(file).then(video => {
console.log("video", video);
aalib.read.video.fromVideoElement(video)
.map(aalib.aa({ width: 165, height: 68 }))
.map(aalib.render.canvas({
width: 696,
height: 476,
fontFamily: "Sora",
el: document.querySelector("#video-scene")
}))
.subscribe();
}).catch(error => {
console.error("Error loading video:", error);
});
}
});

document.getElementById('imageInput').addEventListener('change', function (event) {
const file = event.target.files[0];
if (file && file.type.startsWith('image/')) {
const reader = new FileReader();

reader.onload = function (e) {
const img = new Image();

img.src = e.target.result;
img.alt = 'Uploaded Image';
img.onload = function () {
// Image is loaded and can be manipulated or displayed
aalib.read.image.fromURL(img.src)
.map(aalib.aa({ width: 200, height: 59, colored: false }))
.map(aalib.render.html({ background: "new rgba(0,0,0,)", color: 'red', fontFamily: "Sora" }))
.do(function (el) {
document.body.appendChild(el);
})
.subscribe(); // Optionally, you can now process the image further

};
};

reader.onerror = function () {
console.error('Error loading the image');
};

reader.readAsDataURL(file);
} else {
console.error('File is not an image');
}
});
mona();
bbb();
idata();
localImage();
4 changes: 4 additions & 0 deletions _devCopy/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function appendToBody(el) {
el.className = "aa";
document.body.appendChild(el);
}
15 changes: 15 additions & 0 deletions _devCopy/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const path = require("path");

module.exports = {
entry: path.resolve(__dirname, "main.js"),
output: {
path: __dirname,
publicPath: path.basename(__dirname) + "/"
},
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }
]
},
devtool: "#cheap-module-inline-source-map"
};
2 changes: 2 additions & 0 deletions dev/bundle.js

Large diffs are not rendered by default.

Loading