Compare commits
No commits in common. "55fa969bead36745e2e271d7b3eb9716720af17d" and "71528010d91f40b69ebd92257dd90255ffabdde3" have entirely different histories.
55fa969bea
...
71528010d9
|
@ -1,48 +0,0 @@
|
|||
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);
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
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,13 +1,43 @@
|
|||
import "transbeam-common.asy" as transbeam;
|
||||
real triangleRadius = 100;
|
||||
real borderInset = 6;
|
||||
|
||||
transbeamPrefs prefs;
|
||||
prefs.triangleRadius = 100;
|
||||
prefs.borderInset = 6;
|
||||
prefs.circleRadius = 12;
|
||||
prefs.bigBeamRadius = 36;
|
||||
prefs.smallBeamRadius = 25;
|
||||
prefs.beamCount = 12;
|
||||
prefs.beamAngle = 7;
|
||||
prefs.starterBeamAngle = 16;
|
||||
real circleRadius = 12;
|
||||
real bigBeamRadius = 36;
|
||||
real smallBeamRadius = 25;
|
||||
real beamCount = 12;
|
||||
real beamAngle = 7;
|
||||
real starterBeamAngle = 16;
|
||||
|
||||
drawTransbeam(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);
|
||||
|
|
|
@ -87,7 +87,7 @@ impl UploadedFile {
|
|||
/// through "Extra field length".
|
||||
fn shared_header_fields(&self, hash: Option<u32>) -> Vec<u8> {
|
||||
let mut fields = vec![
|
||||
45, 0, // Minimum version required to extract: 4.5 for ZIP64
|
||||
63, 0, // Minimum version required to extract: 6.3 for UTF-8 filenames
|
||||
0b00001000, // General purpose bit flag: bit 3 - size and CRC-32 in data descriptor
|
||||
0b00001000, // General purpose bit flag: bit 11 - UTF-8 filenames
|
||||
0, 0, // Compression method: none
|
||||
|
@ -138,7 +138,7 @@ impl UploadedFile {
|
|||
fn central_directory_header(&self, local_header_offset: u64, hash: u32) -> Vec<u8> {
|
||||
let mut header = vec![
|
||||
0x50, 0x4b, 0x01, 0x02, // Central directory file header signature
|
||||
45, 3, // Made by a Unix system supporting version 4.5
|
||||
63, 3, // Made by a Unix system supporting version 6.3
|
||||
];
|
||||
header.append(&mut self.shared_header_fields(Some(hash)));
|
||||
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
|
||||
eocd.append(&mut vec![
|
||||
45, 3, // Made by a Unix system supporting version 4.5
|
||||
45, 0, // Minimum version 4.5 to extract
|
||||
63, 3, // Made by a Unix system supporting version 6.3
|
||||
63, 0, // Minimum version 6.3 to extract
|
||||
]);
|
||||
append_0(&mut eocd, 8); // Two 4-byte disk numbers, both 0
|
||||
// Number of central directory records, on this disk and in total
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 31 KiB |
|
@ -9,8 +9,8 @@
|
|||
<body>
|
||||
<div>
|
||||
<label>
|
||||
<input type="file" multiple id="file_input"/>
|
||||
<span class="fake_button" id="file_input_message">Select files to upload...</span>
|
||||
<input type="file" multiple id="file_input"/>
|
||||
</label>
|
||||
</div>
|
||||
<button id="upload" disabled>Upload</button>
|
||||
|
|
|
@ -17,9 +17,8 @@ button:hover, .fake_button:hover {
|
|||
background-color: #aaa;
|
||||
}
|
||||
|
||||
button:disabled, input:disabled + .fake_button {
|
||||
button:disabled, button:disabled:hover, .fake_button:disabled, .fake_button:disabled:hover {
|
||||
color: #aaa;
|
||||
background-color: #eee;
|
||||
border-color: #ddd;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
|
|
@ -106,11 +106,11 @@ uploadButton.addEventListener('click', (e) => {
|
|||
|
||||
totalBytes = files.reduce((acc, file) => acc + file.size, 0);
|
||||
|
||||
socket = new WebSocket(`${window.location.protocol === 'http:' ? 'ws' : 'wss'}://${window.location.host}/upload`);
|
||||
socket = new WebSocket(`ws://${window.location.host}/upload`);
|
||||
socket.addEventListener('open', sendMetadata);
|
||||
socket.addEventListener('message', (msg) => {
|
||||
if (bytesSent === 0 && msg.data.match(/^[A-Za-z0-9]+$/)) {
|
||||
downloadLink.textContent = `${window.location.origin}/download/${msg.data}`;
|
||||
downloadLink.textContent = msg.data;
|
||||
sendData();
|
||||
} else if (msg.data === 'ack') {
|
||||
sendData();
|
||||
|
|
Loading…
Reference in a new issue