Skip to content

Instantly share code, notes, and snippets.

View gkucmierz's full-sized avatar
💻

Grzegorz Kućmierz gkucmierz

💻
View GitHub Profile
{
init: function(elevators, floors) {
// Wykrywamy wyzwania oparte na limicie ruchów (Challenge #6 i #7)
this.clearConditionIsMoves = ["#challenge=6", "#challenge=7"].includes(location.hash);
// Zakres pięter
const minFloorNum = Math.min.apply(null, floors.map(floor => floor.floorNum()));
const maxFloorNum = Math.max.apply(null, floors.map(floor => floor.floorNum()));
/**
* Shannon-Hartley Theorem: Channel Capacity Calculator
*
* Formula: C = B * log2(1 + SNR)
*
* Where:
* - C = Channel Capacity (bits per second)
* - B = Bandwidth (Hz)
* - SNR = Signal-to-Noise Ratio (linear)
// Perrin Number Sequence Interactive Canvas Visualization
// instacode-app compatible
const { canvas, getContext, onResize, onPointerMove } = require('canvas');
const ctx = getContext('2d');
let width = canvas.width;
let height = canvas.height;
// Track canvas size
import { getContext, onResize, onPointerDown } from 'canvas';
// --- CONFIGURATION CONSTANTS ---
const MAX_POINTS = 50000; // Total number of fractal points to generate
const STAGE_1_POINTS = 15; // Number of points in slow educational phase
const STAGE_1_DELAY_MS = 400; // Delay between steps in slow phase (milliseconds)
const STAGE_2_POINTS = 100; // Number of points in normal phase (1 point/frame)
const STAGE_3_POINTS = 500; // Number of points in medium phase (10 points/frame)
const STAGE_4_SPEED = 250; // Number of points generated per frame in fast phase
import { getContext, onResize } from 'canvas';
// Obtain the 2D rendering context
const ctx = getContext('2d');
let width = 400;
let height = 400;
let theta = 0; // Current angle in radians
let animationSpeed = 0.015; // Speed of rotation
let isAnimating = true;
// Visualization of Euler's Identity e^(i * pi) = -1
// Animate the point e^(i * theta) moving along the unit circle in the complex plane.
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
async function main() {
console.log("=== EULER'S IDENTITY VISUALIZATION ===");
console.log("Euler's Formula: e^(i * theta) = cos(theta) + i * sin(theta)");
console.log("For theta = pi: e^(i * pi) = -1 + 0i = -1\n");
await sleep(1500);
// Dichroic Glass X-Cube Optical Prism with Interactive Drag-to-Rotate
// Built using Three.js inside Instacode Web Worker
import { canvas, onResize, getDisplaySize, onPointerDown, onPointerMove, onPointerUp } from 'canvas';
import * as THREE from 'three';
// ==========================================
// CONFIGURATION CONSTANTS (Adjust these to customize your X-Cube!)
// ==========================================
const BG_COLOR = 0xf3f2f8; // Soft light studio background color (#f3f2f8)
// Glassmorphism 3D Rotating Cube for Instacode
// Features: Dual-cube perspective engine, global depth sorting, Phong lighting, and specular glass gradients
import { canvas, getContext, onResize } from 'canvas';
const ctx = getContext('2d');
let width = 600;
let height = 400;
// Handle canvas resizing
// Mandelbrot Explorer for Instacode
// Features: Smooth zoom animation, continuous coloring, and HUD info display
import { canvas, getContext, onResize } from 'canvas';
const ctx = getContext('2d');
let width = 600;
let height = 400;
// Dynamic configuration
import { canvas, onResize } from 'canvas';
const ctx = canvas.getContext('2d');
let width = 300;
let height = 150;
// Handle canvas resizing automatically
onResize((w, h) => {
width = w;