git-hash-art 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,15 @@
1
1
  import { shapes } from "./canvas/shapes";
2
2
 
3
- export function gitHashToSeed(gitHash) {
3
+ export function gitHashToSeed(gitHash: string): number {
4
4
  return parseInt(gitHash.slice(0, 8), 16);
5
5
  }
6
6
 
7
- export function getRandomFromHash(hash, index, min, max) {
7
+ export function getRandomFromHash(
8
+ hash: string,
9
+ index: number,
10
+ min: number,
11
+ max: number,
12
+ ): number {
8
13
  const hexPair = hash.substr((index * 2) % hash.length, 2);
9
14
  const decimal = parseInt(hexPair, 16);
10
15
  return min + (decimal / 255) * (max - min);
@@ -20,18 +25,41 @@ export const Proportions = {
20
25
  PHI: (1 + Math.sqrt(5)) / 2,
21
26
  };
22
27
 
28
+ export type ProportionType = keyof typeof Proportions;
29
+
30
+ interface Pattern {
31
+ type: string;
32
+ config: any; // You might want to define a more specific type for config
33
+ }
34
+
35
+ interface LayerConfig {
36
+ baseSize: number;
37
+ baseOpacity?: number;
38
+ opacityReduction?: number;
39
+ rotationOffset?: number;
40
+ proportionType?: ProportionType;
41
+ }
42
+
23
43
  // Pattern combination utilities
24
44
  export class PatternCombiner {
25
- static getProportionalSize(baseSize, proportion) {
45
+ static getProportionalSize(baseSize: number, proportion: number): number {
26
46
  return baseSize * proportion;
27
47
  }
28
48
 
29
- static centerPattern(ctx, width, height) {
49
+ static centerPattern(
50
+ ctx: CanvasRenderingContext2D,
51
+ width: number,
52
+ height: number,
53
+ ): void {
30
54
  ctx.translate(width / 2, height / 2);
31
55
  }
32
56
 
33
57
  // Combines sacred geometry patterns with proper proportions
34
- static layerPatterns(ctx, patterns, config) {
58
+ static layerPatterns(
59
+ ctx: CanvasRenderingContext2D,
60
+ patterns: Pattern[],
61
+ config: LayerConfig,
62
+ ): void {
35
63
  const {
36
64
  baseSize,
37
65
  baseOpacity = 0.6,
@@ -43,7 +71,7 @@ export class PatternCombiner {
43
71
  patterns.forEach((pattern, index) => {
44
72
  const size = this.getProportionalSize(
45
73
  baseSize,
46
- Math.pow(Proportions[proportionType], index)
74
+ Math.pow(Proportions[proportionType], index),
47
75
  );
48
76
  const opacity = Math.max(0.1, baseOpacity - index * opacityReduction);
49
77
  const rotation = rotationOffset * index;
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "types": ["node"],
4
+ "moduleResolution": "node",
5
+ "esModuleInterop": true,
6
+ "target": "ES2020",
7
+ "module": "ES2020",
8
+ "lib": ["ES2020", "DOM"],
9
+ "strict": true,
10
+ "declaration": true,
11
+ "outDir": "./dist",
12
+ "skipLibCheck": true,
13
+ "forceConsistentCasingInFileNames": true
14
+ },
15
+ "include": ["global.d.ts", "src/**/*"]
16
+ }
package/eslint.config.mjs DELETED
@@ -1,29 +0,0 @@
1
- import { FlatCompat } from "@eslint/eslintrc";
2
- import js from "@eslint/js";
3
- import globals from "globals";
4
- import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
-
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = path.dirname(__filename);
9
- const compat = new FlatCompat({
10
- baseDirectory: __dirname,
11
- recommendedConfig: js.configs.recommended,
12
- allConfig: js.configs.all,
13
- });
14
-
15
- export default [
16
- ...compat.extends("eslint:recommended"),
17
- {
18
- languageOptions: {
19
- globals: {
20
- ...globals.browser,
21
- ...globals.node,
22
- },
23
-
24
- ecmaVersion: 12,
25
- sourceType: "module",
26
- },
27
- rules: {},
28
- },
29
- ];
@@ -1,173 +0,0 @@
1
- import { createCirclePoints } from "./utils";
2
-
3
- export const drawFlowerOfLife = (ctx, size) => {
4
- const radius = size / 6;
5
- const centers = [
6
- { x: 0, y: 0 },
7
- { x: radius * Math.sqrt(3), y: 0 },
8
- { x: radius * Math.sqrt(3) / 2, y: 1.5 * radius },
9
- { x: -radius * Math.sqrt(3) / 2, y: 1.5 * radius },
10
- { x: -radius * Math.sqrt(3), y: 0 },
11
- { x: -radius * Math.sqrt(3) / 2, y: -1.5 * radius },
12
- { x: radius * Math.sqrt(3) / 2, y: -1.5 * radius }
13
- ];
14
-
15
- ctx.beginPath();
16
- centers.forEach(center => {
17
- ctx.moveTo(center.x + radius, center.y);
18
- ctx.arc(center.x, center.y, radius, 0, Math.PI * 2);
19
- });
20
- };
21
-
22
- export const drawTreeOfLife = (ctx, size) => {
23
- const radius = size / 12;
24
- const spacing = radius * 2.5;
25
-
26
- // Sephirot positions (traditional layout)
27
- const positions = [
28
- { x: 0, y: -spacing * 2 }, // Kether
29
- { x: -spacing, y: -spacing }, // Chokmah
30
- { x: spacing, y: -spacing }, // Binah
31
- { x: -spacing, y: 0 }, // Chesed
32
- { x: spacing, y: 0 }, // Geburah
33
- { x: 0, y: 0 }, // Tiphereth
34
- { x: -spacing, y: spacing }, // Netzach
35
- { x: spacing, y: spacing }, // Hod
36
- { x: 0, y: spacing * 2 }, // Yesod
37
- { x: 0, y: spacing * 3 } // Malkuth
38
- ];
39
-
40
- // Draw circles
41
- ctx.beginPath();
42
- positions.forEach(pos => {
43
- ctx.moveTo(pos.x + radius, pos.y);
44
- ctx.arc(pos.x, pos.y, radius, 0, Math.PI * 2);
45
- });
46
-
47
- // Draw connecting lines
48
- ctx.moveTo(positions[0].x, positions[0].y);
49
- positions.forEach((pos, i) => {
50
- if (i > 0) {
51
- positions.slice(i + 1).forEach(nextPos => {
52
- ctx.moveTo(pos.x, pos.y);
53
- ctx.lineTo(nextPos.x, nextPos.y);
54
- });
55
- }
56
- });
57
- };
58
-
59
- export const drawMetatronsCube = (ctx, size) => {
60
- const radius = size / 3;
61
-
62
- // Create 13 points - one center and 12 vertices of an icosahedron
63
-
64
- // const phi = (1 + Math.sqrt(5)) / 2; // Golden ratio
65
-
66
- const vertices = [
67
- { x: 0, y: 0 }, // Center point
68
- ...createCirclePoints(0, 0, radius, 6), // Inner hexagon
69
- ...createCirclePoints(0, 0, radius * 1.5, 6) // Outer hexagon
70
- ];
71
-
72
- ctx.beginPath();
73
- // Draw all connecting lines
74
- vertices.forEach((v1, i) => {
75
- vertices.slice(i + 1).forEach(v2 => {
76
- ctx.moveTo(v1.x, v1.y);
77
- ctx.lineTo(v2.x, v2.y);
78
- });
79
- });
80
- };
81
-
82
- export const drawSriYantra = (ctx, size) => {
83
- const radius = size / 2;
84
- ctx.beginPath();
85
-
86
- // Draw outer triangles
87
- for (let i = 0; i < 9; i++) {
88
- const angle = (i / 9) * Math.PI * 2;
89
- const x1 = Math.cos(angle) * radius;
90
- const y1 = Math.sin(angle) * radius;
91
- const x2 = Math.cos(angle + Math.PI / 9) * radius;
92
- const y2 = Math.sin(angle + Math.PI / 9) * radius;
93
-
94
- ctx.moveTo(0, 0);
95
- ctx.lineTo(x1, y1);
96
- ctx.lineTo(x2, y2);
97
- ctx.lineTo(0, 0);
98
- }
99
-
100
- // Draw inner triangles
101
- const innerRadius = radius * 0.6;
102
- for (let i = 0; i < 9; i++) {
103
- const angle = (i / 9) * Math.PI * 2 + Math.PI / 18;
104
- const x1 = Math.cos(angle) * innerRadius;
105
- const y1 = Math.sin(angle) * innerRadius;
106
- const x2 = Math.cos(angle + Math.PI / 9) * innerRadius;
107
- const y2 = Math.sin(angle + Math.PI / 9) * innerRadius;
108
-
109
- ctx.moveTo(0, 0);
110
- ctx.lineTo(x1, y1);
111
- ctx.lineTo(x2, y2);
112
- ctx.lineTo(0, 0);
113
- }
114
- };
115
-
116
- export const drawSeedOfLife = (ctx, size) => {
117
- const radius = size / 4;
118
- const centers = [
119
- { x: 0, y: 0 },
120
- ...createCirclePoints(0, 0, radius * 2, 6)
121
- ];
122
-
123
- ctx.beginPath();
124
- centers.forEach(center => {
125
- ctx.moveTo(center.x + radius, center.y);
126
- ctx.arc(center.x, center.y, radius, 0, Math.PI * 2);
127
- });
128
- };
129
-
130
- export const drawVesicaPiscis = (ctx, size) => {
131
- const radius = size / 3;
132
- ctx.beginPath();
133
-
134
- // Draw two overlapping circles
135
- ctx.arc(-radius/2, 0, radius, 0, Math.PI * 2);
136
- ctx.arc(radius/2, 0, radius, 0, Math.PI * 2);
137
- };
138
-
139
- export const drawTorus = (ctx, size) => {
140
- const outerRadius = size / 2;
141
- const innerRadius = size / 4;
142
- const steps = 36;
143
-
144
- ctx.beginPath();
145
- for (let i = 0; i < steps; i++) {
146
- const angle1 = (i / steps) * Math.PI * 2;
147
- // const angle2 = ((i + 1) / steps) * Math.PI * 2;
148
-
149
- for (let j = 0; j < steps; j++) {
150
- const phi1 = (j / steps) * Math.PI * 2;
151
- const phi2 = ((j + 1) / steps) * Math.PI * 2;
152
-
153
- const x1 = (outerRadius + innerRadius * Math.cos(phi1)) * Math.cos(angle1);
154
- const y1 = (outerRadius + innerRadius * Math.cos(phi1)) * Math.sin(angle1);
155
- const x2 = (outerRadius + innerRadius * Math.cos(phi2)) * Math.cos(angle1);
156
- const y2 = (outerRadius + innerRadius * Math.cos(phi2)) * Math.sin(angle1);
157
-
158
- ctx.moveTo(x1, y1);
159
- ctx.lineTo(x2, y2);
160
- }
161
- }
162
- };
163
-
164
- // Add to the existing shapes map
165
- export const sacredShapes = {
166
- // flowerOfLife: drawFlowerOfLife,
167
- // treeOfLife: drawTreeOfLife,
168
- metatronsCube: drawMetatronsCube,
169
- sriYantra: drawSriYantra,
170
- seedOfLife: drawSeedOfLife,
171
- vesicaPiscis: drawVesicaPiscis,
172
- torus: drawTorus
173
- };
@@ -1,37 +0,0 @@
1
- export const degToRad = (degrees) => (degrees * Math.PI) / 180;
2
-
3
- export const applyTransforms = (ctx, size, config) => {
4
- ctx.save();
5
- ctx.translate(0, 0);
6
- if (config.rotation) {
7
- ctx.rotate(degToRad(config.rotation));
8
- }
9
- ctx.lineWidth = config.lineWidth;
10
- ctx.strokeStyle = config.strokeStyle;
11
- ctx.fillStyle = config.fillStyle;
12
- };
13
-
14
- export const restoreContext = (ctx) => {
15
- ctx.restore();
16
- };
17
-
18
- // Animation configuration stub for future use
19
- export const createAnimationConfig = (type) => ({
20
- enabled: false,
21
- duration: 1000,
22
- easing: "linear",
23
- type,
24
- // Add more animation-specific properties as needed
25
- });
26
-
27
- export const createCirclePoints = (cx, cy, radius, segments) => {
28
- const points = [];
29
- for (let i = 0; i < segments; i++) {
30
- const angle = (i / segments) * Math.PI * 2;
31
- points.push({
32
- x: cx + Math.cos(angle) * radius,
33
- y: cy + Math.sin(angle) * radius,
34
- });
35
- }
36
- return points;
37
- };