diff --git a/examples/canvas-svg.ts b/examples/canvas-svg.ts index d8fcea2..ac2fc4d 100644 --- a/examples/canvas-svg.ts +++ b/examples/canvas-svg.ts @@ -22,7 +22,6 @@ applyDark(win.window); win.ctx.scale(15, 15); win.onDraw = (ctx) => { - // from https://github.com/microsoft/fluentui-emoji/blob/main/assets/Avocado/Flat/avocado_flat.svg ctx.fillStyle = "#44911B"; ctx.fill( diff --git a/examples/cube2.ts b/examples/cube2.ts index 3992c1e..663ef07 100644 --- a/examples/cube2.ts +++ b/examples/cube2.ts @@ -21,7 +21,6 @@ win.window.setIcon(decode(new Uint8Array(await img.arrayBuffer()))); applyMicaAlt(win.window); applyDark(win.window); - const ctx = win.ctx; ctx.fillStyle = "#fff"; ctx.strokeStyle = "#fff"; diff --git a/examples/imgui2.ts b/examples/imgui2.ts index a918a6f..6fdb710 100644 --- a/examples/imgui2.ts +++ b/examples/imgui2.ts @@ -56,76 +56,76 @@ for (let i = -step * steps / 2; i < step * steps; i += step) { } win.onDraw = (ctx) => { - theta += 3; - if (theta > 360) { - theta = 0; + theta += 3; + if (theta > 360) { + theta = 0; + } + thetaY = theta * Math.PI / 180; + thetaZ = theta * Math.PI / 180; + thetaX = theta * Math.PI / 180; + const matrix2 = []; + for (const column of matrix) { + const column2 = []; + for (const row of column) { + const row2 = []; + for (const point of row) { + let x = point[0]; + let y = point[1]; + let z = point[2]; + x = x * Math.cos(thetaX) - z * Math.sin(thetaX); + z = point[0] * Math.sin(thetaX) + z * Math.cos(thetaX); + y = y * Math.cos(thetaY) - z * Math.sin(thetaY); + z = point[1] * Math.sin(thetaY) + z * Math.cos(thetaY); + const x2 = x; + x = x * Math.cos(thetaZ) - y * Math.sin(thetaZ); + y = x2 * Math.sin(thetaZ) + y * Math.cos(thetaZ); + + ctx.beginPath(); + ctx.arc(x + d, y + d, 5, 0, 2 * Math.PI, false); + ctx.fill(); + row2.push([x + d, y + d]); + } + column2.push(row2); } - thetaY = theta * Math.PI / 180; - thetaZ = theta * Math.PI / 180; - thetaX = theta * Math.PI / 180; - const matrix2 = []; - for (const column of matrix) { - const column2 = []; - for (const row of column) { - const row2 = []; - for (const point of row) { - let x = point[0]; - let y = point[1]; - let z = point[2]; - x = x * Math.cos(thetaX) - z * Math.sin(thetaX); - z = point[0] * Math.sin(thetaX) + z * Math.cos(thetaX); - y = y * Math.cos(thetaY) - z * Math.sin(thetaY); - z = point[1] * Math.sin(thetaY) + z * Math.cos(thetaY); - const x2 = x; - x = x * Math.cos(thetaZ) - y * Math.sin(thetaZ); - y = x2 * Math.sin(thetaZ) + y * Math.cos(thetaZ); - + matrix2.push(column2); + } + + for (let i = 0; i < matrix2.length; i++) { + for (let j = 0; j < matrix2[i].length; j++) { + for (let k = 0; k < matrix2[i][j].length; k++) { + const point = matrix2[i][j][k]; + const point2 = matrix2[i][j][k + 1]; + if (point2) { ctx.beginPath(); - ctx.arc(x + d, y + d, 5, 0, 2 * Math.PI, false); - ctx.fill(); - row2.push([x + d, y + d]); + ctx.moveTo(point[0], point[1]); + ctx.lineTo(point2[0], point2[1]); + ctx.stroke(); } - column2.push(row2); } - matrix2.push(column2); - } - - for (let i = 0; i < matrix2.length; i++) { - for (let j = 0; j < matrix2[i].length; j++) { + const point = matrix2[i][j]; + const point2 = matrix2[i][j + 1]; + if (point2) { for (let k = 0; k < matrix2[i][j].length; k++) { - const point = matrix2[i][j][k]; - const point2 = matrix2[i][j][k + 1]; - if (point2) { - ctx.beginPath(); - ctx.moveTo(point[0], point[1]); - ctx.lineTo(point2[0], point2[1]); - ctx.stroke(); - } - } - const point = matrix2[i][j]; - const point2 = matrix2[i][j + 1]; - if (point2) { - for (let k = 0; k < matrix2[i][j].length; k++) { - ctx.beginPath(); - ctx.moveTo(point[k][0], point[k][1]); - ctx.lineTo(point2[k][0], point2[k][1]); - ctx.stroke(); - } + ctx.beginPath(); + ctx.moveTo(point[k][0], point[k][1]); + ctx.lineTo(point2[k][0], point2[k][1]); + ctx.stroke(); } } - const point = matrix2[i]; - const point2 = matrix2[i + 1]; - if (point2) { - for (let j = 0; j < matrix2[i].length; j++) { - for (let k = 0; k < matrix2[i][j].length; k++) { - ctx.beginPath(); - ctx.moveTo(point[j][k][0], point[j][k][1]); - ctx.lineTo(point2[j][k][0], point2[j][k][1]); - ctx.stroke(); - } + } + const point = matrix2[i]; + const point2 = matrix2[i + 1]; + if (point2) { + for (let j = 0; j < matrix2[i].length; j++) { + for (let k = 0; k < matrix2[i][j].length; k++) { + ctx.beginPath(); + ctx.moveTo(point[j][k][0], point[j][k][1]); + ctx.lineTo(point2[j][k][0], point2[j][k][1]); + ctx.stroke(); } } } + } }; await mainloop(() => { diff --git a/ext/styles/darwin.ts b/ext/styles/darwin.ts index 3a46f42..b128b95 100644 --- a/ext/styles/darwin.ts +++ b/ext/styles/darwin.ts @@ -1,7 +1,6 @@ import { StylePlatform } from "./platform.ts"; import { DwmWindow } from "../../mod.ts"; - function applyBlur(win: DwmWindow) { console.warn("blur not implemented for this system"); } diff --git a/ext/styles/linux.ts b/ext/styles/linux.ts index 3a46f42..b128b95 100644 --- a/ext/styles/linux.ts +++ b/ext/styles/linux.ts @@ -1,7 +1,6 @@ import { StylePlatform } from "./platform.ts"; import { DwmWindow } from "../../mod.ts"; - function applyBlur(win: DwmWindow) { console.warn("blur not implemented for this system"); } diff --git a/ext/styles/platform.ts b/ext/styles/platform.ts index 346b922..904c275 100644 --- a/ext/styles/platform.ts +++ b/ext/styles/platform.ts @@ -1,11 +1,11 @@ import { DwmWindow } from "../../mod.ts"; export interface StylePlatform { - applyBlur(win: DwmWindow): void; - clearBlur(win: DwmWindow): void; - applyMica(win: DwmWindow): void; - applyDark(win: DwmWindow): void; - applyLight(win: DwmWindow): void; - applyMicaAlt(win: DwmWindow): void; - clearMica(win: DwmWindow): void; -} \ No newline at end of file + applyBlur(win: DwmWindow): void; + clearBlur(win: DwmWindow): void; + applyMica(win: DwmWindow): void; + applyDark(win: DwmWindow): void; + applyLight(win: DwmWindow): void; + applyMicaAlt(win: DwmWindow): void; + clearMica(win: DwmWindow): void; +}