
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
szafir-utils
Advanced tools
/**
Biblioteka narzędzi i komponentów dla aplikacji Vite + Preact z zaawansowanymi funkcjami generowania fraktali.
npm install szafir-utils
import {
generateMandelbrot,
DEFAULT_MANDELBROT_CONFIG,
} from "szafir-utils/fractals";
// Wygeneruj fraktal
const config = {
...DEFAULT_MANDELBROT_CONFIG,
width: 800,
height: 600,
maxIterations: 100,
};
const result = generateMandelbrot(config, (progress) => {
console.log(`Postęp: ${Math.round(progress * 100)}%`);
});
console.log(`Wygenerowano w ${result.generationTime}ms`);
console.log(`Punktów w zbiorze: ${result.stats.pointsInSet}`);
import { MandelbrotViewer } from "szafir-utils/components";
function App() {
return (
<div>
<h1>Fraktal Mandelbrot</h1>
<MandelbrotViewer
width={800}
height={600}
maxIterations={200}
showControls={true}
onGenerated={(result) => {
console.log("Fraktal wygenerowany!", result);
}}
/>
</div>
);
}
generateMandelbrot(config, onProgress?)Generuje fraktal Mandelbrot z zadaną konfiguracją.
Parametry:
config: FractalConfig - konfiguracja fraktalaonProgress?: (progress: number) => void - callback postępu (0-1)Zwraca: FractalResult
generateJulia(config, onProgress?)Generuje fraktal Julia.
Parametry:
config: JuliaConfig - konfiguracja z parametrem juliaConProgress?: (progress: number) => void - callback postępuZwraca: FractalResult
renderToCanvas(result, canvas, options?)Renderuje wynik fraktala na HTML Canvas.
Parametry:
result: FractalResult - wynik generacji fraktalacanvas: HTMLCanvasElement - element canvasoptions?: RenderOptions - opcje renderowaniaimport { complex, add, multiply, square, modulus } from "szafir-utils/fractals";
const c1 = complex(3, 4); // 3 + 4i
const c2 = complex(1, 2); // 1 + 2i
const sum = add(c1, c2); // 4 + 6i
const product = multiply(c1, c2); // -5 + 10i
const squared = square(c1); // -7 + 24i
const magnitude = modulus(c1); // 5
<MandelbrotViewer>Zaawansowany komponent do wyświetlania fraktala Mandelbrot z kontrolkami.
Props:
width?: number - szerokość (domyślnie 800)height?: number - wysokość (domyślnie 600)maxIterations?: number - maksymalne iteracje (domyślnie 100)showControls?: boolean - pokazuj kontrolki (domyślnie true)onGenerated?: (result) => void - callback po generacjionProgress?: (progress) => void - callback postępu<JuliaViewer>Komponent do wyświetlania fraktali Julia z predefiniowanymi presetami.
Props:
width?: numberheight?: numbermaxIterations?: numberjuliaC?: ComplexNumber - parametr CshowControls?: boolean<FractalCanvas>Uniwersalny komponent canvas do wyświetlania fraktali.
import { COLOR_PALETTES, renderToCanvas } from "szafir-utils/fractals";
const renderOptions = {
colorPalette: COLOR_PALETTES.FIRE, // CLASSIC, FIRE, OCEAN, RAINBOW, PURPLE, MONOCHROME
colorMode: "smooth", // 'iterations', 'smooth', 'binary'
brightness: 1.2,
contrast: 1.0,
};
renderToCanvas(fractalResult, canvas, renderOptions);
import { JULIA_PRESETS, generateJulia } from "szafir-utils/fractals";
// Użyj predefiniowanego presetu
const config = {
width: 800,
height: 600,
maxIterations: 100,
juliaC: JULIA_PRESETS.DRAGON, // DRAGON, SPIRAL, TREE, SYMMETRIC, DENDRITE, CLASSIC
};
const result = generateJulia(config);
import { generateMandelbrotChunk } from "szafir-utils/fractals";
const config = { width: 1920, height: 1080, maxIterations: 500 };
// Generuj w fragmentach dla lepszej wydajności
const chunks = [];
const chunkHeight = 100;
for (let y = 0; y < config.height; y += chunkHeight) {
const endY = Math.min(y + chunkHeight, config.height);
const chunk = generateMandelbrotChunk(config, y, endY);
chunks.push(chunk);
}
// Przyszłe API - generacja w Web Worker
const result = await generateMandelbrotAsync(config);
import { useState } from "preact/hooks";
import { MandelbrotViewer } from "szafir-utils/components";
function FractalExplorer() {
const [iterations, setIterations] = useState(100);
return (
<div>
<div>
<label>Iteracje: {iterations}</label>
<input
type="range"
min="10"
max="1000"
value={iterations}
onChange={(e) => setIterations(parseInt(e.target.value))}
/>
</div>
<MandelbrotViewer
width={1024}
height={768}
maxIterations={iterations}
showControls={true}
onProgress={(progress) => {
document.title = `Generowanie... ${Math.round(progress * 100)}%`;
}}
onGenerated={(result) => {
document.title = `Fraktal - ${result.generationTime.toFixed(0)}ms`;
}}
/>
</div>
);
}
import { generateMandelbrot, toImageDataUrl } from "szafir-utils/fractals";
const result = generateMandelbrot({
width: 1920,
height: 1080,
maxIterations: 500,
minReal: -2.5,
maxReal: 1.0,
minImaginary: -1.25,
maxImaginary: 1.25,
});
// Export jako Data URL
const imageUrl = toImageDataUrl(result, {
colorPalette: ["#000000", "#ff0000", "#ffff00", "#ffffff"],
colorMode: "smooth",
brightness: 1.3,
});
// Użyj w img lub pobierz
const link = document.createElement("a");
link.download = "mandelbrot.png";
link.href = imageUrl;
link.click();
Pełne wsparcie TypeScript z dokładnymi definicjami typów:
import type {
FractalConfig,
FractalResult,
ComplexNumber,
RenderOptions,
} from "szafir-utils/fractals";
const config: FractalConfig = {
width: 800,
height: 600,
maxIterations: 100,
minReal: -2.0,
maxReal: 2.0,
minImaginary: -2.0,
maxImaginary: 2.0,
escapeRadius: 4.0,
};
git clone https://github.com/szafir-team/szafir-utils.git
cd szafir-utils
npm install
npm run dev # development build
npm run build # production build
npm run test # run tests
MIT © Szafir Team
FAQs
Utility library with components and tools for Szafir Vite applications
We found that szafir-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.