GeoffVague commited on
Commit
9bad642
β€’
1 Parent(s): ec44a4c

Add 4 files

Browse files
Files changed (4) hide show
  1. README.md +5 -8
  2. app.js +82 -0
  3. index.html +1 -19
  4. style.css +25 -22
README.md CHANGED
@@ -1,11 +1,8 @@
1
  ---
 
2
  title: Crazy Hip Hop Christmas AI Image Prompt Generator
3
- emoji: πŸ¦€
4
- colorFrom: purple
5
- colorTo: blue
6
  sdk: static
7
- pinned: false
8
- license: mit
9
- ---
10
-
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ license: apache-2.0
3
  title: Crazy Hip Hop Christmas AI Image Prompt Generator
 
 
 
4
  sdk: static
5
+ emoji: πŸ‘¨β€πŸ’»
6
+ colorFrom: yellow
7
+ colorTo: green
8
+ ---
 
app.js ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { createApp, ref, onMounted } from "alpinejs";
2
+ import { gsap } from "gsap";
3
+ import { VisualRecognitionV3 } from "@WatsonService/watson-vision-combined";
4
+ import * as Three from "three";
5
+ import "../style/index.css";
6
+
7
+ const App = {
8
+ setup() {
9
+ const image = ref(null);
10
+ const camera = ref(null);
11
+ const renderer = ref(null);
12
+ const scene = ref(null);
13
+
14
+ onMounted(() => {
15
+ const ctx = setupCanvas();
16
+ init();
17
+ animate();
18
+ });
19
+
20
+ function setupCanvas() {
21
+ const ctx = document.createElement("canvas").getContext("2d");
22
+ ctx.canvas.width = window.innerWidth;
23
+ ctx.canvas.height = window.innerHeight;
24
+ ctx.imageSmoothingEnabled = true;
25
+ return ctx;
26
+ }
27
+
28
+ function init() {
29
+ camera = Three.PerspectiveCamera(
30
+ 30,
31
+ window.innerWidth / window.innerHeight,
32
+ 0.1,
33
+ 1000
34
+ );
35
+
36
+ scene = new Three.Scene();
37
+
38
+ const geometry = new Three.BoxGeometry(0.1, 0.1, 0.1);
39
+ const material = new Three.MeshBasicMaterial({
40
+ color: 0x000000,
41
+ wireframe: true,
42
+ });
43
+ const cube = new Three.Mesh(geometry, material);
44
+ scene.add(cube);
45
+
46
+ renderer = new Three.WebGLRenderer({
47
+ canvas: ctx.canvas,
48
+ });
49
+ renderer.setSize(window.innerWidth, window.innerHeight);
50
+ renderer.setClearColor(0x000000, 1);
51
+
52
+ document.body.appendChild(renderer.domElement);
53
+ }
54
+
55
+ function animate() {
56
+ requestAnimationFrame(animate);
57
+
58
+ const time = performance.now() * 0.3;
59
+ camera.position.x = Math.sin(time) * 1;
60
+ camera.position.y = Math.sin(time) * 1;
61
+ camera.position.z = Math.sin(time) * 1;
62
+ camera.lookAt(scene.position);
63
+
64
+ renderer.render(scene, camera);
65
+ }
66
+ },
67
+ methods: {
68
+ generateImage() {
69
+ image.value = new FormData();
70
+ const request = new XMLHttpRequest();
71
+ request.open("POST", "/api/generate", true);
72
+ request.send(image.value);
73
+ request.onload = () => {
74
+ let img = new Image();
75
+ img.src = URL.createObjectURL(request.response.image);
76
+ document.body.appendChild(img);
77
+ };
78
+ },
79
+ },
80
+ };
81
+
82
+ createApp(App);
index.html CHANGED
@@ -1,19 +1 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
1
+ <html><head><link href="https://cdn.jsdelivr.net/npm/daisyui@3.1.6/dist/full.css" rel="stylesheet" type="text/css" /><script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script><script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio"></script><script defer src="https://cdnjs.cloudflare.com/ajax/libs/three.js/0.156.1/three.min.js"></script><script type="module" src="main.js"></script><title>Crazy Hip Hop Christmas AI Image Prompt Generator</title></head><body><main class="prose" data-path="/app/index.js"></main><footer class="footer text-sm gray-600"><button type="button" class="py-3 px-4 border border-gray-500 font-medium text-sm rounded text-gray-700 bg-gray-200 hover:bg-gray-300 active:bg-gray-300 transition duration-150 ease-in-out">Generate Image</button></footer></body></html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
style.css CHANGED
@@ -1,28 +1,31 @@
1
- body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
4
- }
5
-
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
9
  }
10
 
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
  }
17
 
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
  }
25
 
26
- .card p:last-child {
27
- margin-bottom: 0;
28
- }
 
 
 
 
 
 
 
 
 
1
+ * {
2
+ box-sizing: border-box;
3
+ margin: 0;
4
+ padding: 0;
 
 
 
 
5
  }
6
 
7
+ body {
8
+ background-color: #f0f0f0;
9
+ padding: 20px;
10
+ font-family: Arial, sans-serif;
 
11
  }
12
 
13
+ .prose {
14
+ margin: 20px auto;
15
+ padding: 10px;
16
+ background-color: #fafafa;
17
+ border: 1px solid #ddd;
18
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
19
  }
20
 
21
+ footer {
22
+ position: fixed;
23
+ bottom: 0;
24
+ left: 0;
25
+ right: 0;
26
+ height: 60px;
27
+ background-color: #333;
28
+ color: #fff;
29
+ text-align: center;
30
+ font-size: 24px;
31
+ }