git-hash-art 0.0.1
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.
- package/.release-it.json +17 -0
- package/README.md +138 -0
- package/bin/generateExamples.js +59 -0
- package/dist/main.js +974 -0
- package/dist/main.js.map +1 -0
- package/eslint.config.mjs +29 -0
- package/examples/angular-1024x1024-f31a6c3e.png +0 -0
- package/examples/banner-1920x480-d847ffd4.png +0 -0
- package/examples/complex-2048x2048-deadbeef.png +0 -0
- package/examples/instagram-square-1080x1080-ff00ff00.png +0 -0
- package/examples/instagram-story-1080x1920-abc123de.png +0 -0
- package/examples/linkedin-banner-1584x396-bbbbbbbb.png +0 -0
- package/examples/minimal-1024x1024-00000000.png +0 -0
- package/examples/phone-wallpaper-1170x2532-ffffffff.png +0 -0
- package/examples/react-1024x1024-46192e59.png +0 -0
- package/examples/tablet-wallpaper-2048x2732-12345678.png +0 -0
- package/examples/twitter-header-1500x500-77777777.png +0 -0
- package/examples/ultrawide-3440x1440-a3e126e5.png +0 -0
- package/package.json +32 -0
- package/src/index.js +226 -0
- package/src/lib/canvas/colors.js +102 -0
- package/src/lib/canvas/draw.js +73 -0
- package/src/lib/canvas/shapes/basic.js +93 -0
- package/src/lib/canvas/shapes/complex.js +205 -0
- package/src/lib/canvas/shapes/index.js +9 -0
- package/src/lib/canvas/shapes/sacred.js +173 -0
- package/src/lib/canvas/shapes/utils.js +37 -0
- package/src/lib/constants.js +138 -0
- package/src/lib/utils.js +59 -0
package/.release-it.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"npm": {
|
|
3
|
+
"publish": true
|
|
4
|
+
},
|
|
5
|
+
"github": {
|
|
6
|
+
"publish": true,
|
|
7
|
+
"release": true
|
|
8
|
+
},
|
|
9
|
+
"git": {
|
|
10
|
+
"requireBranch": "main",
|
|
11
|
+
"commitMessage": "chore: release v${version}"
|
|
12
|
+
},
|
|
13
|
+
"hooks": {
|
|
14
|
+
"before:init": ["git pull", "yarn lint"],
|
|
15
|
+
"after:bump": "npx auto-changelog -p"
|
|
16
|
+
}
|
|
17
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# git-hash-art
|
|
2
|
+
|
|
3
|
+
Generate beautiful, deterministic abstract art from git commit hashes. Perfect for creating unique visual representations of your project's commits, generating placeholder images, or creating artistic wallpapers.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Generate consistent, deterministic abstract art from any git hash
|
|
8
|
+
- Configurable canvas sizes and output formats
|
|
9
|
+
- Built-in presets for common social media and device sizes
|
|
10
|
+
- Harmonious color schemes based on hash values
|
|
11
|
+
- Grid-based composition system for balanced layouts
|
|
12
|
+
- Multiple shape types and layering effects
|
|
13
|
+
- Customizable output settings
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install git-hash-art
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Basic Usage
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import { generateImageFromHash } from 'git-hash-art';
|
|
25
|
+
|
|
26
|
+
// Generate art from a git hash with default settings
|
|
27
|
+
const gitHash = '46192e59d42f741c761cbea79462a8b3815dd905';
|
|
28
|
+
generateImageFromHash(gitHash);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Advanced Usage
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
// Custom configuration
|
|
35
|
+
const config = {
|
|
36
|
+
width: 1920,
|
|
37
|
+
height: 1080,
|
|
38
|
+
gridSize: 6,
|
|
39
|
+
layers: 7,
|
|
40
|
+
shapesPerLayer: 30,
|
|
41
|
+
minShapeSize: 20,
|
|
42
|
+
maxShapeSize: 180,
|
|
43
|
+
baseOpacity: 0.6,
|
|
44
|
+
opacityReduction: 0.1
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
generateImageFromHash(gitHash, config);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Configuration Options
|
|
51
|
+
|
|
52
|
+
| Option | Type | Default | Description |
|
|
53
|
+
|--------|------|---------|-------------|
|
|
54
|
+
| `width` | number | 1024 | Canvas width in pixels |
|
|
55
|
+
| `height` | number | 1024 | Canvas height in pixels |
|
|
56
|
+
| `gridSize` | number | 4 | Number of grid cells (gridSize x gridSize) |
|
|
57
|
+
| `layers` | number | 5 | Number of layers to generate |
|
|
58
|
+
| `shapesPerLayer` | number | - | Base number of shapes per layer (defaults to grid cells * 1.5) |
|
|
59
|
+
| `minShapeSize` | number | 20 | Minimum shape size |
|
|
60
|
+
| `maxShapeSize` | number | 180 | Maximum shape size |
|
|
61
|
+
| `baseOpacity` | number | 0.6 | Starting opacity for first layer |
|
|
62
|
+
| `opacityReduction` | number | 0.1 | How much to reduce opacity per layer |
|
|
63
|
+
|
|
64
|
+
## Preset Sizes
|
|
65
|
+
|
|
66
|
+
The package includes several preset configurations for common use cases:
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
import { PRESETS } from 'git-hash-art-generator';
|
|
70
|
+
|
|
71
|
+
// Generate an Instagram-sized image
|
|
72
|
+
generateImageFromHash(gitHash, PRESETS['instagram'].config);
|
|
73
|
+
|
|
74
|
+
// Generate a mobile wallpaper
|
|
75
|
+
generateImageFromHash(gitHash, PRESETS['phone-wallpaper'].config);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Available presets include:
|
|
79
|
+
- Standard (1024x1024)
|
|
80
|
+
- Banner (1920x480)
|
|
81
|
+
- Ultrawide (3440x1440)
|
|
82
|
+
- Instagram (1080x1080)
|
|
83
|
+
- Instagram Story (1080x1920)
|
|
84
|
+
- Twitter Header (1500x500)
|
|
85
|
+
- LinkedIn Banner (1584x396)
|
|
86
|
+
- Phone Wallpaper (1170x2532)
|
|
87
|
+
- Tablet Wallpaper (2048x2732)
|
|
88
|
+
- Print sizes (A4/A3 at 300 DPI)
|
|
89
|
+
|
|
90
|
+
## CLI Usage
|
|
91
|
+
|
|
92
|
+
The package includes a command-line interface:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Generate with default settings
|
|
96
|
+
npx git-hash-art current
|
|
97
|
+
|
|
98
|
+
# Generate from specific hash
|
|
99
|
+
npx git-hash-art generate <hash>
|
|
100
|
+
|
|
101
|
+
# Generate with custom size
|
|
102
|
+
npx git-hash-art generate <hash> --width 1920 --height 1080
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Integration Examples
|
|
106
|
+
|
|
107
|
+
### GitHub Actions
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
name: Generate Commit Art
|
|
111
|
+
on: [push]
|
|
112
|
+
jobs:
|
|
113
|
+
generate-art:
|
|
114
|
+
runs-on: ubuntu-latest
|
|
115
|
+
steps:
|
|
116
|
+
- uses: actions/checkout@v2
|
|
117
|
+
- uses: actions/setup-node@v2
|
|
118
|
+
- run: npm install git-hash-art-generator
|
|
119
|
+
- run: npx git-hash-art current --output artwork/
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Git Hooks
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
#!/bin/sh
|
|
126
|
+
# .git/hooks/post-commit
|
|
127
|
+
|
|
128
|
+
hash=$(git rev-parse HEAD)
|
|
129
|
+
npx git-hash-art generate $hash --output .git/artwork/
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Contributing
|
|
133
|
+
|
|
134
|
+
Contributions are welcome! Please see our [Contributing Guidelines](CONTRIBUTING.md) for more details.
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { generateImageFromHash, saveImageToFile } from '../dist/main.js';
|
|
4
|
+
import { PRESETS } from '../src/lib/constants.js';
|
|
5
|
+
|
|
6
|
+
const OUTPUT_DIR = './examples';
|
|
7
|
+
|
|
8
|
+
// Ensure the output directory exists
|
|
9
|
+
if (!fs.existsSync(OUTPUT_DIR)) {
|
|
10
|
+
fs.mkdirSync(OUTPUT_DIR, { recursive: true });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function generateTestCases() {
|
|
14
|
+
console.log("Generating test cases...");
|
|
15
|
+
console.log("Output directory:", path.resolve(OUTPUT_DIR));
|
|
16
|
+
|
|
17
|
+
const results = [];
|
|
18
|
+
for (const [label, testCase] of Object.entries(PRESETS)) {
|
|
19
|
+
try {
|
|
20
|
+
console.log(`Generating image for ${label}...`);
|
|
21
|
+
const imageBuffer = generateImageFromHash(testCase.hash, {
|
|
22
|
+
width: testCase.width,
|
|
23
|
+
height: testCase.height,
|
|
24
|
+
...testCase, // Include any additional configuration from the preset
|
|
25
|
+
});
|
|
26
|
+
const outputPath = saveImageToFile(imageBuffer, OUTPUT_DIR, testCase.hash, label, testCase.width, testCase.height);
|
|
27
|
+
results.push({ label, hash: testCase.hash, outputPath, success: true });
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error(`Failed to generate image for ${label}:`, error);
|
|
30
|
+
results.push({
|
|
31
|
+
label,
|
|
32
|
+
hash: testCase.hash,
|
|
33
|
+
success: false,
|
|
34
|
+
error: error.message,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.log("\nGeneration Summary:");
|
|
40
|
+
console.log("------------------");
|
|
41
|
+
results.forEach(({ label, success, outputPath, error }) => {
|
|
42
|
+
if (success) {
|
|
43
|
+
console.log(`✓ ${label}: ${outputPath}`);
|
|
44
|
+
} else {
|
|
45
|
+
console.log(`✗ ${label}: Failed - ${error}`);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Run the test cases
|
|
51
|
+
generateTestCases();
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
// const gitHash = '1234567890abcdef1234567890abcdef12345678';
|
|
56
|
+
// const imageBuffer = generateImageFromHash(gitHash, { width: 1024, height: 1024 });
|
|
57
|
+
// const savedImagePath = saveImageToFile(imageBuffer, './output', gitHash, 'example', 1024, 1024);
|
|
58
|
+
// console.log(`Image saved to: ${savedImagePath}`);
|
|
59
|
+
|