Compare commits
4 commits
71528010d9
...
55fa969bea
Author | SHA1 | Date | |
---|---|---|---|
xenofem | 55fa969bea | ||
xenofem | 43cffcd54c | ||
xenofem | 7191b4df96 | ||
xenofem | 9545ceb4f4 |
48
resources/transbeam-common.asy
Normal file
48
resources/transbeam-common.asy
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
struct transbeamPrefs {
|
||||||
|
real triangleRadius;
|
||||||
|
real borderInset;
|
||||||
|
real circleRadius;
|
||||||
|
real bigBeamRadius;
|
||||||
|
real smallBeamRadius;
|
||||||
|
real beamCount;
|
||||||
|
real beamAngle;
|
||||||
|
real starterBeamAngle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawTransbeam(transbeamPrefs prefs) {
|
||||||
|
unravel prefs;
|
||||||
|
|
||||||
|
pen transBlue = rgb("55cdfc");
|
||||||
|
pen transPink = rgb("f7a8b8");
|
||||||
|
|
||||||
|
pen bigBeamColor = transPink;
|
||||||
|
pen smallBeamColor = transBlue;
|
||||||
|
|
||||||
|
path borderTriangle = dir(90)--dir(210)--dir(330)--cycle;
|
||||||
|
path outerBorder = scale(triangleRadius)*borderTriangle;
|
||||||
|
fill(outerBorder, white);
|
||||||
|
|
||||||
|
path beam(real angle, real innerRadius, real outerRadius) {
|
||||||
|
return arc((0,0), outerRadius, angle/2, -angle/2)--arc((0,0), innerRadius, -angle/2, angle/2)--cycle;
|
||||||
|
}
|
||||||
|
|
||||||
|
path bigBeam = beam(beamAngle, circleRadius, bigBeamRadius);
|
||||||
|
path smallBeam = beam(beamAngle, circleRadius, smallBeamRadius);
|
||||||
|
|
||||||
|
for (int i = 0; i < beamCount; ++i) {
|
||||||
|
if (i > 0) {
|
||||||
|
fill(rotate(360*i/beamCount)*bigBeam, bigBeamColor);
|
||||||
|
}
|
||||||
|
fill(rotate(360*(i+0.5)/beamCount)*smallBeam, smallBeamColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
pair starterBeamTrianglePoint(real angle) {
|
||||||
|
pair circlePoint = circleRadius*dir(angle);
|
||||||
|
return intersectionpoint(circlePoint--(circlePoint+(triangleRadius,0)), outerBorder);
|
||||||
|
}
|
||||||
|
|
||||||
|
fill(starterBeamTrianglePoint(-starterBeamAngle/2)--arc((0,0), circleRadius, -starterBeamAngle/2, starterBeamAngle/2)--starterBeamTrianglePoint(starterBeamAngle/2)--cycle, bigBeamColor);
|
||||||
|
|
||||||
|
draw(outerBorder, transPink+(2*borderInset));
|
||||||
|
draw(scale(triangleRadius-borderInset)*borderTriangle, transBlue+borderInset);
|
||||||
|
}
|
13
resources/transbeam-favicon.asy
Normal file
13
resources/transbeam-favicon.asy
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import "transbeam-common.asy" as transbeam;
|
||||||
|
|
||||||
|
transbeamPrefs prefs;
|
||||||
|
prefs.triangleRadius = 100;
|
||||||
|
prefs.borderInset = 14;
|
||||||
|
prefs.circleRadius = 12;
|
||||||
|
prefs.bigBeamRadius = 36;
|
||||||
|
prefs.smallBeamRadius = 36;
|
||||||
|
prefs.beamCount = 3;
|
||||||
|
prefs.beamAngle = 40;
|
||||||
|
prefs.starterBeamAngle = 80;
|
||||||
|
|
||||||
|
drawTransbeam(prefs);
|
|
@ -1,43 +1,13 @@
|
||||||
real triangleRadius = 100;
|
import "transbeam-common.asy" as transbeam;
|
||||||
real borderInset = 6;
|
|
||||||
|
|
||||||
real circleRadius = 12;
|
transbeamPrefs prefs;
|
||||||
real bigBeamRadius = 36;
|
prefs.triangleRadius = 100;
|
||||||
real smallBeamRadius = 25;
|
prefs.borderInset = 6;
|
||||||
real beamCount = 12;
|
prefs.circleRadius = 12;
|
||||||
real beamAngle = 7;
|
prefs.bigBeamRadius = 36;
|
||||||
real starterBeamAngle = 16;
|
prefs.smallBeamRadius = 25;
|
||||||
|
prefs.beamCount = 12;
|
||||||
|
prefs.beamAngle = 7;
|
||||||
|
prefs.starterBeamAngle = 16;
|
||||||
|
|
||||||
pen transBlue = rgb("55cdfc");
|
drawTransbeam(prefs);
|
||||||
pen transPink = rgb("f7a8b8");
|
|
||||||
|
|
||||||
pen bigBeamColor = transPink;
|
|
||||||
pen smallBeamColor = transBlue;
|
|
||||||
|
|
||||||
path borderTriangle = dir(90)--dir(210)--dir(330)--cycle;
|
|
||||||
path outerBorder = scale(triangleRadius)*borderTriangle;
|
|
||||||
fill(outerBorder, white);
|
|
||||||
|
|
||||||
path beam(real angle, real innerRadius, real outerRadius) {
|
|
||||||
return arc((0,0), outerRadius, angle/2, -angle/2)--arc((0,0), innerRadius, -angle/2, angle/2)--cycle;
|
|
||||||
}
|
|
||||||
|
|
||||||
path bigBeam = beam(beamAngle, circleRadius, bigBeamRadius);
|
|
||||||
path smallBeam = beam(beamAngle, circleRadius, smallBeamRadius);
|
|
||||||
|
|
||||||
for (int i = 0; i < beamCount; ++i) {
|
|
||||||
if (i > 0) {
|
|
||||||
fill(rotate(360*i/beamCount)*bigBeam, bigBeamColor);
|
|
||||||
}
|
|
||||||
fill(rotate(360*(i+0.5)/beamCount)*smallBeam, smallBeamColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
pair starterBeamTrianglePoint(real angle) {
|
|
||||||
pair circlePoint = circleRadius*dir(angle);
|
|
||||||
return intersectionpoint(circlePoint--(circlePoint+(triangleRadius,0)), outerBorder);
|
|
||||||
}
|
|
||||||
|
|
||||||
fill(starterBeamTrianglePoint(-starterBeamAngle/2)--arc((0,0), circleRadius, -starterBeamAngle/2, starterBeamAngle/2)--starterBeamTrianglePoint(starterBeamAngle/2)--cycle, bigBeamColor);
|
|
||||||
|
|
||||||
draw(outerBorder, transPink+(2*borderInset));
|
|
||||||
draw(scale(triangleRadius-borderInset)*borderTriangle, transBlue+borderInset);
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ impl UploadedFile {
|
||||||
/// through "Extra field length".
|
/// through "Extra field length".
|
||||||
fn shared_header_fields(&self, hash: Option<u32>) -> Vec<u8> {
|
fn shared_header_fields(&self, hash: Option<u32>) -> Vec<u8> {
|
||||||
let mut fields = vec![
|
let mut fields = vec![
|
||||||
63, 0, // Minimum version required to extract: 6.3 for UTF-8 filenames
|
45, 0, // Minimum version required to extract: 4.5 for ZIP64
|
||||||
0b00001000, // General purpose bit flag: bit 3 - size and CRC-32 in data descriptor
|
0b00001000, // General purpose bit flag: bit 3 - size and CRC-32 in data descriptor
|
||||||
0b00001000, // General purpose bit flag: bit 11 - UTF-8 filenames
|
0b00001000, // General purpose bit flag: bit 11 - UTF-8 filenames
|
||||||
0, 0, // Compression method: none
|
0, 0, // Compression method: none
|
||||||
|
@ -138,7 +138,7 @@ impl UploadedFile {
|
||||||
fn central_directory_header(&self, local_header_offset: u64, hash: u32) -> Vec<u8> {
|
fn central_directory_header(&self, local_header_offset: u64, hash: u32) -> Vec<u8> {
|
||||||
let mut header = vec![
|
let mut header = vec![
|
||||||
0x50, 0x4b, 0x01, 0x02, // Central directory file header signature
|
0x50, 0x4b, 0x01, 0x02, // Central directory file header signature
|
||||||
63, 3, // Made by a Unix system supporting version 6.3
|
45, 3, // Made by a Unix system supporting version 4.5
|
||||||
];
|
];
|
||||||
header.append(&mut self.shared_header_fields(Some(hash)));
|
header.append(&mut self.shared_header_fields(Some(hash)));
|
||||||
append_0(&mut header, 8); // Comment length, disk number, internal attributes, DOS external attributes
|
append_0(&mut header, 8); // Comment length, disk number, internal attributes, DOS external attributes
|
||||||
|
@ -169,8 +169,8 @@ fn end_of_central_directory(files: &[UploadedFile]) -> Vec<u8> {
|
||||||
];
|
];
|
||||||
append_0(&mut eocd, 7); // pad out the rest of the size field
|
append_0(&mut eocd, 7); // pad out the rest of the size field
|
||||||
eocd.append(&mut vec![
|
eocd.append(&mut vec![
|
||||||
63, 3, // Made by a Unix system supporting version 6.3
|
45, 3, // Made by a Unix system supporting version 4.5
|
||||||
63, 0, // Minimum version 6.3 to extract
|
45, 0, // Minimum version 4.5 to extract
|
||||||
]);
|
]);
|
||||||
append_0(&mut eocd, 8); // Two 4-byte disk numbers, both 0
|
append_0(&mut eocd, 8); // Two 4-byte disk numbers, both 0
|
||||||
// Number of central directory records, on this disk and in total
|
// Number of central directory records, on this disk and in total
|
||||||
|
|
BIN
static/favicon.ico
Normal file
BIN
static/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
|
@ -9,8 +9,8 @@
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<div>
|
||||||
<label>
|
<label>
|
||||||
<span class="fake_button" id="file_input_message">Select files to upload...</span>
|
|
||||||
<input type="file" multiple id="file_input"/>
|
<input type="file" multiple id="file_input"/>
|
||||||
|
<span class="fake_button" id="file_input_message">Select files to upload...</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<button id="upload" disabled>Upload</button>
|
<button id="upload" disabled>Upload</button>
|
||||||
|
|
|
@ -17,8 +17,9 @@ button:hover, .fake_button:hover {
|
||||||
background-color: #aaa;
|
background-color: #aaa;
|
||||||
}
|
}
|
||||||
|
|
||||||
button:disabled, button:disabled:hover, .fake_button:disabled, .fake_button:disabled:hover {
|
button:disabled, input:disabled + .fake_button {
|
||||||
color: #aaa;
|
color: #aaa;
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
border-color: #ddd;
|
border-color: #ddd;
|
||||||
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,11 +106,11 @@ uploadButton.addEventListener('click', (e) => {
|
||||||
|
|
||||||
totalBytes = files.reduce((acc, file) => acc + file.size, 0);
|
totalBytes = files.reduce((acc, file) => acc + file.size, 0);
|
||||||
|
|
||||||
socket = new WebSocket(`ws://${window.location.host}/upload`);
|
socket = new WebSocket(`${window.location.protocol === 'http:' ? 'ws' : 'wss'}://${window.location.host}/upload`);
|
||||||
socket.addEventListener('open', sendMetadata);
|
socket.addEventListener('open', sendMetadata);
|
||||||
socket.addEventListener('message', (msg) => {
|
socket.addEventListener('message', (msg) => {
|
||||||
if (bytesSent === 0 && msg.data.match(/^[A-Za-z0-9]+$/)) {
|
if (bytesSent === 0 && msg.data.match(/^[A-Za-z0-9]+$/)) {
|
||||||
downloadLink.textContent = msg.data;
|
downloadLink.textContent = `${window.location.origin}/download/${msg.data}`;
|
||||||
sendData();
|
sendData();
|
||||||
} else if (msg.data === 'ack') {
|
} else if (msg.data === 'ack') {
|
||||||
sendData();
|
sendData();
|
||||||
|
|
Loading…
Reference in a new issue