Skip to content

Commit 77e3c6d

Browse files
committed
added size pops to M3terHead and added function to generate attributes
1 parent b6a2c52 commit 77e3c6d

20 files changed

+1955
-1860
lines changed

docs/m3ter-alias.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Effortlessly create captivating names that instantly distinguish each device, an
1717
export default function Home() {
1818
return (
1919
<h2 style={{ "text-transform": "capitalize" }}>
20-
<M3terAlias seed={"device_DID_string"} />
20+
{M3terAlias(seed="device_DID_string")}
2121
</h2>
2222
);
2323
}

docs/m3ter-attributes.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# M3ter Attributes
2+
3+
Object describing m3ter-head attributes generated from the seed
4+
5+
### Usage:
6+
7+
1. Import the `m3terAttributes` component into your React code:
8+
9+
```javascript
10+
import * as React from "react";
11+
import { m3terAttributes } from "m3ters";
12+
```
13+
14+
2. Generate the attributes within your component, providing your input string:
15+
16+
```jsx
17+
export default function Home() {
18+
const attributes = m3terAttributes("device_DID_string");
19+
console.log(attributes);
20+
}
21+
```
22+
23+
3. Your function should return text content like shown below
24+
25+
```json
26+
{
27+
"name": "mighty distinct nanogear",
28+
"eyes": "happy",
29+
"mouth": "smile2",
30+
"texture": "dots",
31+
"color": "#0592f9",
32+
"seed": "device_DID_string"
33+
}
34+
```
35+
36+
## Licensing
37+
38+
You are free to embed under the terms of the [CC0 1.0 Universal](./LICENSE) License.

docs/m3ter-head.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Avatars to infuse a touch of whimsy and individuality into the M3tering Protocol
1717
export default function Home() {
1818
return (
1919
<>
20-
<M3terHead seed={"device_DID_string"} />
20+
<M3terHead seed={"device_DID_string"} size={80} />
2121
</>
2222
);
2323
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "m3ters",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"license": "CC0-1.0",
55
"author": "iChristwin",
66
"description": "React toolkit tailored to M3tering Protocol for handling ugly crypto strings",
@@ -47,4 +47,4 @@
4747
"files": [
4848
"dist"
4949
]
50-
}
50+
}

src/components/M3terAlias.jsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/components/M3terHead.jsx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
import React from "react";
2-
import seedrandom from "seedrandom";
32

43
import { Eyes } from "./Eyes";
54
import { Mouth } from "./Mouth";
65
import { Texture } from "./Texture";
6+
import { m3terProps } from "../utils/props";
77

8-
export const M3terHead = (seed) => {
9-
const random = seedrandom(seed);
10-
let eyes = Math.round(random() * 15);
11-
let mouth = Math.round(random() * 11);
12-
let texture = Math.round(random() * 5);
13-
let color = "#" + random().toString(16).slice(2, 8);
8+
export const M3terHead = ({ seed, size = 500 }) => {
9+
const { eyesIndex, mouthIndex, textureIndex, color } = m3terProps(seed);
1410

1511
return (
1612
<svg
1713
version="1.1"
18-
id="m3ter-head"
14+
id={seed}
1915
xmlns="http://www.w3.org/2000/svg"
20-
width="500"
21-
height="500"
16+
width={size}
17+
height={size}
2218
viewBox="-34 -15 250 250"
2319
>
2420
<mask id="facemask" mask-type="alpha" maskUnits="userSpaceOnUse">
@@ -32,10 +28,10 @@ export const M3terHead = (seed) => {
3228
</mask>
3329
<g mask="url(#facemask)">
3430
<rect x="-20" y="-20" width="225" height="220" fill={color} />
35-
<Texture type={texture} />
31+
<Texture type={textureIndex} />
3632
</g>
37-
<Eyes type={eyes} />
38-
<Mouth type={mouth} />
33+
<Eyes type={eyesIndex} />
34+
<Mouth type={mouthIndex} />
3935
</svg>
4036
);
4137
};

src/components/alias.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { m3terProps } from "../utils";
2+
import { Adjectives, Nouns } from "../words";
3+
4+
export const m3terAlias = (seed) => {
5+
const { adjIndex1, adjIndex2, nounIndex } = m3terProps(seed);
6+
return `${Adjectives[adjIndex1]} ${Adjectives[adjIndex2]} ${Nouns[nounIndex]}`;
7+
};

src/components/attributes.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { m3terAlias } from "./alias";
2+
import { m3terProps, eyeTypes, mouthType, textureType } from "../utils";
3+
4+
export const m3terAttributes = (seed) => {
5+
const { eyesIndex, mouthIndex, textureIndex, color } = m3terProps(seed);
6+
7+
return {
8+
name: m3terAlias(seed),
9+
eyes: eyeTypes[eyesIndex],
10+
mouth: mouthType[mouthIndex],
11+
texture: textureType[textureIndex],
12+
color,
13+
seed,
14+
};
15+
};

src/components/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from "react";
2-
3-
export * from "./M3terAlias.jsx";
1+
export * from "./alias";
2+
export * from "./attributes";
43
export * from "./M3terHead.jsx";

src/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
import React from "react";
2-
31
export * from "./components";
2+
export * from "./utils";

src/parts/Eyes/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from "react";
2-
31
export { Arturito } from "./Arturito";
42
export { Bulging } from "./Bulging";
53
export { Dizzy } from "./Dizzy";

src/parts/Mouths/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from "react";
2-
31
export { Arturito } from "./Arturito";
42
export { Bite } from "./Bite";
53
export { Diagram } from "./Diagram";

src/parts/Textures/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from "react";
2-
31
export { Camo1 } from "./Camo1";
42
export { Camo2 } from "./Camo2";
53
export { Dirty1 } from "./Dirty1";

src/utils/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./props";
2+
export * from "./types";

src/utils/props.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import seedrandom from "seedrandom";
2+
3+
export function m3terProps(seed) {
4+
const random = seedrandom(seed);
5+
const eyesIndex = Math.round(random() * 15);
6+
const mouthIndex = Math.round(random() * 11);
7+
const textureIndex = Math.round(random() * 5);
8+
const color = "#" + random().toString(16).slice(2, 8);
9+
10+
const adjIndex1 = Math.round(random() * 1808);
11+
const adjIndex2 = Math.round(random() * 1808);
12+
const nounIndex = Math.round(random() * 96);
13+
14+
return {
15+
eyesIndex,
16+
mouthIndex,
17+
textureIndex,
18+
color,
19+
adjIndex1,
20+
adjIndex2,
21+
nounIndex,
22+
};
23+
}

src/utils/types.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
export const eyeTypes = [
2+
"arturito",
3+
"bulging",
4+
"dizzy",
5+
"eva",
6+
"frame1",
7+
"frame2",
8+
"glow",
9+
"happy",
10+
"hearts",
11+
"robocop",
12+
"round",
13+
"roundFrame01",
14+
"roundFrame02",
15+
"sensor",
16+
"shade01",
17+
];
18+
19+
export const mouthType = [
20+
"none",
21+
"arturito",
22+
"bite",
23+
"diagram",
24+
"grill01",
25+
"grill02",
26+
"grill03",
27+
"robocop",
28+
"smile01",
29+
"smile02",
30+
"square01",
31+
"square02",
32+
];
33+
34+
export const textureType = [
35+
"none",
36+
"camo01",
37+
"camo02",
38+
"dirty01",
39+
"dirty02",
40+
"dots",
41+
];

0 commit comments

Comments
 (0)