Skip to content

Commit d085dfe

Browse files
v1.1.1
added metaverse shop
2 parents 7b57c48 + d22654e commit d085dfe

File tree

15 files changed

+1797
-2
lines changed

15 files changed

+1797
-2
lines changed

dist/admin/add-project/ide.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ EditorFiles.prototype.attach = function() {
144144

145145
this.active = -1;
146146
this.setActive(0);
147-
//this.focus();
147+
this.focus();
148148

149149
this.ui.menu.addEventListener('click', this.toggleMenu.bind(this));
150150
this.ui.menu.addEventListener('mouseover', this.preShowMenu.bind(this));

dist/admin/add-project/index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@
4444
<line x1="5" y1="12" x2="19" y2="12" /></svg>
4545
</a>
4646
</button>
47+
<button class="notification-btn">
48+
<a class="notification-btn" href="../metaverse/index.html" style="margin-top: 10px;">
49+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" class="bi bi-meta" viewBox="0 0 24 24">
50+
<path fill-rule="evenodd" d="M8.217 5.243C9.145 3.988 10.171 3 11.483 3 13.96 3 16 6.153 16.001 9.907c0 2.29-.986 3.725-2.757 3.725-1.543 0-2.395-.866-3.924-3.424l-.667-1.123-.118-.197a54.944 54.944 0 0 0-.53-.877l-1.178 2.08c-1.673 2.925-2.615 3.541-3.923 3.541C1.086 13.632 0 12.217 0 9.973 0 6.388 1.995 3 4.598 3c.319 0 .625.039.924.122.31.086.611.22.913.407.577.359 1.154.915 1.782 1.714Zm1.516 2.224c-.252-.41-.494-.787-.727-1.133L9 6.326c.845-1.305 1.543-1.954 2.372-1.954 1.723 0 3.102 2.537 3.102 5.653 0 1.188-.39 1.877-1.195 1.877-.773 0-1.142-.51-2.61-2.87l-.937-1.565ZM4.846 4.756c.725.1 1.385.634 2.34 2.001A212.13 212.13 0 0 0 5.551 9.3c-1.357 2.126-1.826 2.603-2.581 2.603-.777 0-1.24-.682-1.24-1.9 0-2.602 1.298-5.264 2.846-5.264.091 0 .181.006.27.018Z"/>
51+
</svg>
52+
</a>
53+
</button>
4754
<button class="profile-btn">
4855
<img src="https://straight-code.github.io/assets/straight-code.png" />
4956
<span>straight-code2</span>

dist/admin/index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@
3939
<line x1="5" y1="12" x2="19" y2="12" /></svg>
4040
</a>
4141
</button>
42-
42+
<button class="notification-btn">
43+
<a class="notification-btn" href="./metaverse/index.html" style="margin-top: 10px;">
44+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" class="bi bi-meta" viewBox="0 0 24 24">
45+
<path fill-rule="evenodd" d="M8.217 5.243C9.145 3.988 10.171 3 11.483 3 13.96 3 16 6.153 16.001 9.907c0 2.29-.986 3.725-2.757 3.725-1.543 0-2.395-.866-3.924-3.424l-.667-1.123-.118-.197a54.944 54.944 0 0 0-.53-.877l-1.178 2.08c-1.673 2.925-2.615 3.541-3.923 3.541C1.086 13.632 0 12.217 0 9.973 0 6.388 1.995 3 4.598 3c.319 0 .625.039.924.122.31.086.611.22.913.407.577.359 1.154.915 1.782 1.714Zm1.516 2.224c-.252-.41-.494-.787-.727-1.133L9 6.326c.845-1.305 1.543-1.954 2.372-1.954 1.723 0 3.102 2.537 3.102 5.653 0 1.188-.39 1.877-1.195 1.877-.773 0-1.142-.51-2.61-2.87l-.937-1.565ZM4.846 4.756c.725.1 1.385.634 2.34 2.001A212.13 212.13 0 0 0 5.551 9.3c-1.357 2.126-1.826 2.603-2.581 2.603-.777 0-1.24-.682-1.24-1.9 0-2.602 1.298-5.264 2.846-5.264.091 0 .181.006.27.018Z"/>
46+
</svg>
47+
</a>
48+
</button>
4349
<button class="profile-btn">
4450
<img src="https://straight-code.github.io/assets/straight-code.png" />
4551
<span>straight-code2</span>
247 KB
Loading
731 KB
Loading
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!DOCTYPE html>
2+
<html lang="en" >
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Are you sure?</title>
6+
<link href="https://straight-code.github.io/assets/straight-code.png" rel="shortcut icon" />
7+
8+
<link rel="preconnect" href="https://fonts.gstatic.com" />
9+
<link
10+
href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap"
11+
rel="stylesheet"
12+
/>
13+
14+
<meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="./style.css">
15+
16+
</head>
17+
<body>
18+
<!-- partial:index.partial.html -->
19+
<!-- Canvas -->
20+
<canvas class="orb-canvas"></canvas>
21+
<!-- Overlay -->
22+
<div class="overlay">
23+
<!-- Overlay inner wrapper -->
24+
<div class="overlay__inner">
25+
<!-- Title -->
26+
<h1 class="overlay__title">
27+
confirmation needed, are you sure you want to
28+
<span class="text-gradient">buy</span> this item ?
29+
</h1>
30+
<!-- Description -->
31+
<p class="overlay__description">
32+
</strong>
33+
34+
</p>
35+
<!-- Buttons -->
36+
<div class="overlay__btns">
37+
38+
<button class="overlay__btn overlay__btn--transparent">
39+
<a href="../../index.html" target="_blank">
40+
41+
Go Home
42+
</a>
43+
</button>
44+
<button class="overlay__btn overlay__btn--transparent">
45+
<a href="https://straight-code.sellix.io/product/623cfa785560e">
46+
Yes, Buy Jumper Now
47+
</a>
48+
</button>
49+
50+
<button class="overlay__btn overlay__btn--transparent">
51+
<a href="https://straight-code.sellix.io/product/623cfb52a3603">
52+
Yes, Buy Hoodie Now
53+
</a>
54+
</button>
55+
56+
57+
58+
<button class="overlay__btn overlay__btn--colors">
59+
<span>Have some fun </span>
60+
<span class="overlay__btn-emoji"></span>
61+
</button>
62+
</div>
63+
</div>
64+
</div>
65+
<!-- partial -->
66+
<script type="module" src="./script.js"></script>
67+
68+
</body>
69+
</html>
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
import * as PIXI from "https://cdn.skypack.dev/pixi.js";
2+
import { KawaseBlurFilter } from "https://cdn.skypack.dev/@pixi/filter-kawase-blur";
3+
import SimplexNoise from "https://cdn.skypack.dev/simplex-noise";
4+
import hsl from "https://cdn.skypack.dev/hsl-to-hex";
5+
import debounce from "https://cdn.skypack.dev/debounce";
6+
7+
// return a random number within a range
8+
function random(min, max) {
9+
return Math.random() * (max - min) + min;
10+
}
11+
12+
// map a number from 1 range to another
13+
function map(n, start1, end1, start2, end2) {
14+
return ((n - start1) / (end1 - start1)) * (end2 - start2) + start2;
15+
}
16+
17+
// Create a new simplex noise instance
18+
const simplex = new SimplexNoise();
19+
20+
// ColorPalette class
21+
class ColorPalette {
22+
constructor() {
23+
this.setColors();
24+
this.setCustomProperties();
25+
}
26+
27+
setColors() {
28+
// pick a random hue somewhere between 220 and 360
29+
this.hue = ~~random(220, 360);
30+
this.complimentaryHue1 = this.hue + 30;
31+
this.complimentaryHue2 = this.hue + 60;
32+
// define a fixed saturation and lightness
33+
this.saturation = 95;
34+
this.lightness = 50;
35+
36+
// define a base color
37+
this.baseColor = hsl(this.hue, this.saturation, this.lightness);
38+
// define a complimentary color, 30 degress away from the base
39+
this.complimentaryColor1 = hsl(
40+
this.complimentaryHue1,
41+
this.saturation,
42+
this.lightness
43+
);
44+
// define a second complimentary color, 60 degrees away from the base
45+
this.complimentaryColor2 = hsl(
46+
this.complimentaryHue2,
47+
this.saturation,
48+
this.lightness
49+
);
50+
51+
// store the color choices in an array so that a random one can be picked later
52+
this.colorChoices = [
53+
this.baseColor,
54+
this.complimentaryColor1,
55+
this.complimentaryColor2
56+
];
57+
}
58+
59+
randomColor() {
60+
// pick a random color
61+
return this.colorChoices[~~random(0, this.colorChoices.length)].replace(
62+
"#",
63+
"0x"
64+
);
65+
}
66+
67+
setCustomProperties() {
68+
// set CSS custom properties so that the colors defined here can be used throughout the UI
69+
document.documentElement.style.setProperty("--hue", this.hue);
70+
document.documentElement.style.setProperty(
71+
"--hue-complimentary1",
72+
this.complimentaryHue1
73+
);
74+
document.documentElement.style.setProperty(
75+
"--hue-complimentary2",
76+
this.complimentaryHue2
77+
);
78+
}
79+
}
80+
81+
// Orb class
82+
class Orb {
83+
// Pixi takes hex colors as hexidecimal literals (0x rather than a string with '#')
84+
constructor(fill = 0x000000) {
85+
// bounds = the area an orb is "allowed" to move within
86+
this.bounds = this.setBounds();
87+
// initialise the orb's { x, y } values to a random point within it's bounds
88+
this.x = random(this.bounds["x"].min, this.bounds["x"].max);
89+
this.y = random(this.bounds["y"].min, this.bounds["y"].max);
90+
91+
// how large the orb is vs it's original radius (this will modulate over time)
92+
this.scale = 1;
93+
94+
// what color is the orb?
95+
this.fill = fill;
96+
97+
// the original radius of the orb, set relative to window height
98+
this.radius = random(window.innerHeight / 6, window.innerHeight / 3);
99+
100+
// starting points in "time" for the noise/self similar random values
101+
this.xOff = random(0, 1000);
102+
this.yOff = random(0, 1000);
103+
// how quickly the noise/self similar random values step through time
104+
this.inc = 0.002;
105+
106+
// PIXI.Graphics is used to draw 2d primitives (in this case a circle) to the canvas
107+
this.graphics = new PIXI.Graphics();
108+
this.graphics.alpha = 0.825;
109+
110+
// 250ms after the last window resize event, recalculate orb positions.
111+
window.addEventListener(
112+
"resize",
113+
debounce(() => {
114+
this.bounds = this.setBounds();
115+
}, 250)
116+
);
117+
}
118+
119+
setBounds() {
120+
// how far from the { x, y } origin can each orb move
121+
const maxDist =
122+
window.innerWidth < 1000 ? window.innerWidth / 3 : window.innerWidth / 5;
123+
// the { x, y } origin for each orb (the bottom right of the screen)
124+
const originX = window.innerWidth / 1.25;
125+
const originY =
126+
window.innerWidth < 1000
127+
? window.innerHeight
128+
: window.innerHeight / 1.375;
129+
130+
// allow each orb to move x distance away from it's x / y origin
131+
return {
132+
x: {
133+
min: originX - maxDist,
134+
max: originX + maxDist
135+
},
136+
y: {
137+
min: originY - maxDist,
138+
max: originY + maxDist
139+
}
140+
};
141+
}
142+
143+
update() {
144+
// self similar "psuedo-random" or noise values at a given point in "time"
145+
const xNoise = simplex.noise2D(this.xOff, this.xOff);
146+
const yNoise = simplex.noise2D(this.yOff, this.yOff);
147+
const scaleNoise = simplex.noise2D(this.xOff, this.yOff);
148+
149+
// map the xNoise/yNoise values (between -1 and 1) to a point within the orb's bounds
150+
this.x = map(xNoise, -1, 1, this.bounds["x"].min, this.bounds["x"].max);
151+
this.y = map(yNoise, -1, 1, this.bounds["y"].min, this.bounds["y"].max);
152+
// map scaleNoise (between -1 and 1) to a scale value somewhere between half of the orb's original size, and 100% of it's original size
153+
this.scale = map(scaleNoise, -1, 1, 0.5, 1);
154+
155+
// step through "time"
156+
this.xOff += this.inc;
157+
this.yOff += this.inc;
158+
}
159+
160+
render() {
161+
// update the PIXI.Graphics position and scale values
162+
this.graphics.x = this.x;
163+
this.graphics.y = this.y;
164+
this.graphics.scale.set(this.scale);
165+
166+
// clear anything currently drawn to graphics
167+
this.graphics.clear();
168+
169+
// tell graphics to fill any shapes drawn after this with the orb's fill color
170+
this.graphics.beginFill(this.fill);
171+
// draw a circle at { 0, 0 } with it's size set by this.radius
172+
this.graphics.drawCircle(0, 0, this.radius);
173+
// let graphics know we won't be filling in any more shapes
174+
this.graphics.endFill();
175+
}
176+
}
177+
178+
// Create PixiJS app
179+
const app = new PIXI.Application({
180+
// render to <canvas class="orb-canvas"></canvas>
181+
view: document.querySelector(".orb-canvas"),
182+
// auto adjust size to fit the current window
183+
resizeTo: window,
184+
// transparent background, we will be creating a gradient background later using CSS
185+
transparent: true
186+
});
187+
188+
// Create colour palette
189+
const colorPalette = new ColorPalette();
190+
191+
app.stage.filters = [new KawaseBlurFilter(30, 10, true)];
192+
193+
// Create orbs
194+
const orbs = [];
195+
196+
for (let i = 0; i < 10; i++) {
197+
const orb = new Orb(colorPalette.randomColor());
198+
199+
app.stage.addChild(orb.graphics);
200+
201+
orbs.push(orb);
202+
}
203+
204+
// Animate!
205+
if (!window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
206+
app.ticker.add(() => {
207+
orbs.forEach((orb) => {
208+
orb.update();
209+
orb.render();
210+
});
211+
});
212+
} else {
213+
orbs.forEach((orb) => {
214+
orb.update();
215+
orb.render();
216+
});
217+
}
218+
219+
document
220+
.querySelector(".overlay__btn--colors")
221+
.addEventListener("click", () => {
222+
colorPalette.setColors();
223+
colorPalette.setCustomProperties();
224+
225+
orbs.forEach((orb) => {
226+
orb.fill = colorPalette.randomColor();
227+
});
228+
});

0 commit comments

Comments
 (0)