Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7a18d31
Merge branch 'main' into weather
edpacca Jul 31, 2023
c35ba50
DEBUG draw clouds mode
edpacca Aug 31, 2023
d2a8c53
wip clouds
edpacca Oct 10, 2023
f856a98
Merge branch 'main' into weather
edpacca Oct 10, 2023
00bba3b
fix merge conflicts
edpacca Oct 10, 2023
c6cd831
create rain drawing class
edpacca Feb 5, 2025
6672b7f
add rain to weather scene - wip
edpacca Feb 5, 2025
cc50795
show weather tab again
edpacca Feb 5, 2025
416e186
Merge branch 'weather-2' into weather
edpacca Feb 14, 2025
6211555
wip convert to classes
edpacca Feb 21, 2025
703f0d7
set up scene again
edpacca Feb 23, 2025
22f557a
move draw functions to module
edpacca Feb 23, 2025
00be77f
set up animations correctly in scene
edpacca Feb 23, 2025
92cbe3d
remove log in compass
edpacca Feb 23, 2025
3661b53
util random rgb
edpacca Feb 23, 2025
4dcab7e
create cloud class
edpacca Feb 23, 2025
faffdb4
abstract precipitator class
edpacca Feb 23, 2025
75d6a11
get timeNoun from hour
edpacca Feb 23, 2025
a220a4b
add utils line at angle
edpacca Feb 23, 2025
209bfa9
use preciptator base for rain
edpacca Feb 23, 2025
8e657fd
create snow precipitator
edpacca Feb 23, 2025
48d1255
clean up tree code
edpacca Feb 23, 2025
66fccff
rough scene setup
edpacca Feb 23, 2025
07d8baa
thunderrrr
edpacca Feb 25, 2025
fcf1373
big icon button - weather button£
edpacca Feb 27, 2025
3f552d3
weather controls component
edpacca Feb 27, 2025
3ff3da3
create animator controller
edpacca Feb 27, 2025
1b43403
lint
edpacca Feb 27, 2025
e4a2b9f
refactor lib
edpacca Feb 27, 2025
5055f99
add set time to bluebody
edpacca Mar 2, 2025
9fd4fb6
fix thunder flash color
edpacca Mar 2, 2025
c3dda6c
craete framerate measure class
edpacca Mar 2, 2025
3aed019
use framerate and timeset
edpacca Mar 2, 2025
7d1244a
capture framerate
edpacca Mar 2, 2025
d07a984
return time with weather
edpacca Mar 2, 2025
dd39016
add controls to weather page
edpacca Mar 2, 2025
13e0b4f
fix image not full width on firefox
edpacca Apr 20, 2025
d2b0df8
fix imoprts
edpacca May 5, 2025
6c47e37
wip weather stuff
edpacca May 5, 2025
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
64 changes: 0 additions & 64 deletions src/Artist.ts

This file was deleted.

3 changes: 2 additions & 1 deletion src/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ declare global {
description?: string
}

type Points = [number, number][]
type Point = [number, number]
type Points = Point[]

type JSONValue = { [x: string]: string }

Expand Down
83 changes: 83 additions & 0 deletions src/lib/api/githubApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { error } from "@sveltejs/kit";
import { EXTERNAL_CODE_LANGS, getLangShortName } from "../data/codeLangData";

export async function ghGet(url: string, token: string) {
return await fetch(url, {
method: "GET",
mode: "cors",
credentials: "same-origin",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
"X-GitHub-Api-Version": "2022-11-28",
},
});
}

async function extractLanguageData(data: JSONArray, token: string) {
try {
const urls: string[] = data.flatMap((repo) => repo.languages_url);
const collated: Record<string, number>[] = [];
await Promise.all(
urls.map(async (url: string) => {
const response = await ghGet(url, token);
const data = (await response.json()) as Record<string, number>;
if (data) {
collated.push(data);
}
}),
);
return parseLanguageObject(collated);
} catch {
error(500, "Error parsing coding language data from github");
}
}

export async function getGhLanguageData(url: string, token: string) {
try {
const response = await ghGet(url, token);
const data = (await response.json()) as JSONArray;
const languages = await extractLanguageData(data, token);
return languages;
} catch {
error(500, "Error retrieving data from github");
}
}

export function parseLanguageObject(
data: Record<string, number>[],
): Record<string, number> {
let total = 0;
const parsed: Record<string, number> = {};
for (const languages of data) {
for (const language of Object.keys(languages)) {
const lang = getLangShortName(language);
if (parsed[lang]) {
// use proportional lines of code intead
// parsed[lang] += parsed[key];
parsed[lang] += 1;
} else {
// use proportional lines of code intead
// parsed[lang] = parsed[key];
parsed[lang] = 1;
}
// total += parsed[key];
total += 1;
}
}

for (const language of Object.keys(EXTERNAL_CODE_LANGS)) {
const lang = getLangShortName(language);
if (parsed[lang]) {
parsed[lang] += EXTERNAL_CODE_LANGS[language];
} else {
parsed[lang] = EXTERNAL_CODE_LANGS[language];
}
total += EXTERNAL_CODE_LANGS[language];
}

for (const language of Object.keys(parsed)) {
parsed[language] = parsed[language] / total;
}
return parsed;
}
File renamed without changes.
9 changes: 9 additions & 0 deletions src/lib/canvas/Animator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export abstract class Animator {
ctx: CanvasRenderingContext2D;

constructor(context: CanvasRenderingContext2D) {
this.ctx = context;
}

abstract animate(): void;
}
68 changes: 68 additions & 0 deletions src/lib/canvas/Artist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { drawLine } from "$lib/canvas/canvasUtils";

export class Artist {
ctx: CanvasRenderingContext2D;
rootX: number;
rootY: number;
startX: number;
startY: number;
endX: number;
endY: number;

constructor(context: CanvasRenderingContext2D, x: number, y: number) {
this.startX = x;
this.startY = y;
this.endX = x;
this.endY = y;
this.rootX = x;
this.rootY = y;
this.ctx = context;
}

reset(xOffset: number, yOffset: number) {
this.startX = this.rootX + xOffset;
this.startY = this.rootY + yOffset;
}

drawNextLine(xOffset: number, yOffset: number) {
this.endX = this.startX + xOffset;
this.endY = this.startY + yOffset;
drawLine(this.ctx, this.startX, this.startY, this.endX, this.endY);
this.startX = this.endX;
this.startY = this.endY;
}

drawShape(
points: Points,
reflect: boolean,
xOffset: number,
yOffset: number,
lineWidth: number,
stroke?: string,
fill?: string | CanvasGradient,
) {
this.ctx.beginPath();
this.ctx.moveTo(this.startX, this.startY);
points.forEach((p) => this.drawNextLine(p[0], p[1]));
if (reflect) {
this.reset(xOffset, yOffset);
points.forEach((p) => this.drawReflection(p[0], p[1]));
}
this.ctx.closePath();

if (stroke) {
this.ctx.lineCap = "round";
this.ctx.lineWidth = lineWidth;
this.ctx.strokeStyle = stroke;
this.ctx.stroke();
}
if (fill) {
this.ctx.fillStyle = fill;
this.ctx.fill();
}
}

drawReflection(xOffset: number, yOffset: number) {
this.drawNextLine(xOffset * -1, yOffset);
}
}
44 changes: 44 additions & 0 deletions src/lib/canvas/canvasUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export function drawCircle(
context: CanvasRenderingContext2D,
x: number,
y: number,
radius: number,
stroke?: string,
fill?: string | CanvasGradient,
) {
context.beginPath();
context.arc(x, y, radius, 0, Math.PI * 2, false);
if (stroke) {
context.strokeStyle = stroke;
context.stroke();
}
if (fill) {
context.fillStyle = fill;
context.fill();
}
context.closePath();
}

export function drawLine(
context: CanvasRenderingContext2D,
startX: number,
startY: number,
endX: number,
endY: number,
) {
context.lineTo(startX, startY);
context.lineTo(endX, endY);
}

export function drawLineAtAngle(
context: CanvasRenderingContext2D,
x: number,
y: number,
length: number,
angle: number,
) {
const offsetX = length * Math.cos(angle);
const offsetY = length * Math.sin(angle);
context.moveTo(x, y);
context.lineTo(x - offsetX, y - offsetY);
}
Loading