Trudy commited on
Commit
1f423ae
·
0 Parent(s):

Initial commit with Git LFS

Browse files
.dockerignore ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ Dockerfile
2
+ .dockerignore
3
+ node_modules
4
+ npm-debug.log
5
+ README.md
6
+ .next
7
+ .git
8
+ .env
9
+ .env.local
.gcloudignore ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file specifies files that are *not* uploaded to Google Cloud
2
+ # using gcloud. It follows the same syntax as .gitignore, with the addition of
3
+ # "#!include" directives (which insert the entries of the given .gitignore-style
4
+ # file at that point).
5
+ #
6
+ # For more information, run:
7
+ # $ gcloud topic gcloudignore
8
+ #
9
+ .gcloudignore
10
+ # If you would like to upload your .git directory, .gitignore file or files
11
+ # from your .gitignore file, remove the corresponding line
12
+ # below:
13
+ .git
14
+ .gitignore
15
+
16
+ # Node.js dependencies:
17
+ node_modules/
.gitattributes ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.png filter=lfs diff=lfs merge=lfs -text
37
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
38
+ *.gif filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+ /.pnp
6
+ .pnp.*
7
+ .yarn/*
8
+ !.yarn/patches
9
+ !.yarn/plugins
10
+ !.yarn/releases
11
+ !.yarn/versions
12
+
13
+ # testing
14
+ /coverage
15
+
16
+ # next.js
17
+ /.next/
18
+ /out/
19
+
20
+ # production
21
+ /build
22
+
23
+ # misc
24
+ .DS_Store
25
+ *.pem
26
+
27
+ # debug
28
+ npm-debug.log*
29
+ yarn-debug.log*
30
+ yarn-error.log*
31
+ .pnpm-debug.log*
32
+
33
+ # env files (can opt-in for committing if needed)
34
+ .env*
35
+ .env.local
36
+ # vercel
37
+ .vercel
38
+
39
+ # typescript
40
+ *.tsbuildinfo
41
+ next-env.d.ts
42
+
43
+ # app yaml
44
+ *.yaml
45
+ app.yaml
46
+
47
+ # large file
48
+ service-future-job-2/public/genpalsv1.mov
49
+ *.mov
50
+
CONTRIBUTING.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # How to contribute
2
+
3
+ We'd love to accept your patches and contributions to this project.
4
+
5
+ ## Before you begin
6
+
7
+ Sign our Contributor License Agreement
8
+ Contributions to this project must be accompanied by a Contributor License Agreement (CLA). You (or your employer) retain the copyright to your contribution; this simply gives us permission to use and redistribute your contributions as part of the project.
9
+
10
+ If you or your current employer have already signed the Google CLA (even if it was for a different project), you probably don't need to do it again.
11
+
12
+ Visit https://cla.developers.google.com/ to see your current agreements or to sign a new one.
13
+
14
+ ### Review our community guidelines
15
+ This project follows Google's Open Source Community Guidelines.
16
+
17
+ ## Contribution process
18
+
19
+ ###Code reviews
20
+ All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult GitHub Help for more information on using pull requests.
Dockerfile ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:18-alpine
2
+
3
+ WORKDIR /app
4
+
5
+ # Set up a new user named "user" with user ID 1000
6
+ RUN deluser --remove-home node \
7
+ && addgroup -S user -g 1000 \
8
+ && adduser -S -G user -u 1000 user \
9
+ && chown -R user:user /app
10
+
11
+ # Copy package files
12
+ COPY package*.json ./
13
+
14
+ # Install dependencies with legacy peer deps flag
15
+ RUN chown -R user:user /app && \
16
+ npm install --legacy-peer-deps
17
+
18
+ # Switch to user after npm install
19
+ USER user
20
+ ENV HOME=/home/user \
21
+ PATH=/home/user/.local/bin:$PATH
22
+
23
+ # Copy rest of the application with correct ownership
24
+ COPY --chown=user . .
25
+
26
+ # Build the Next.js application
27
+ RUN npm run build
28
+
29
+ # Expose the port the app runs on (Hugging Face Spaces requires port 7860)
30
+ EXPOSE 7860
31
+
32
+ # Start the application on port 7860
33
+ CMD ["npm", "run", "start", "--", "-p", "7860"]
LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
README.md ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Image to Code Generator 🎨
2
+
3
+ ![image-to-code-sketch](./readme/smoke.gif)
4
+
5
+ Get started with p5js sketches using Gemini 2.0 Flash. Upload any photo, and this web app uses Gemini 2.0 Flash to generate a p5.js sketch that captures the essence of the image in an interactive way.
6
+
7
+ ## Getting Started
8
+
9
+ ### 1. Clone this repository and install dependencies:
10
+
11
+ ```
12
+ git clone https://github.com/googlecreativelab/gemini-demos/
13
+ cd image-to-code-sketch
14
+ npm install
15
+ ```
16
+
17
+ ### 2. Create a .env.local file with your AI Studio API key:
18
+
19
+ Get your API key from [Google AI Studio](https://aistudio.google.com/apikey).
20
+
21
+ ```
22
+ GEMINI_API_KEY=your_api_key_here
23
+ ```
24
+
25
+ ### 3. Start the development server:
26
+
27
+ ```
28
+ npm run dev
29
+ ```
30
+
31
+ Open http://localhost:3000 and start uploading images!
32
+
33
+ ## Prompt Transparency
34
+
35
+ The prompt to transform images into p5js sketches can be found in `pages/index.js`.
36
+
37
+ ```
38
+ You are a creative coding expert who turns images into clever code sketches using p5js. A user will upload an image and you will generate a interactive p5js sketch that represents the image. The code sketch always has some sort of interactive element that connects to the nature of the object in the real world.
39
+
40
+ ## EXAMPLES
41
+
42
+ Here are some examples of what I mean by how the type of image could be turned into a clever creative coding sketch to capture the essence of the image.
43
+ - A photo of birds --> a boids flocking algorithm sketch where the boids follow your mouse
44
+ - A photo of a tree --> a recursive fractal tree that grows as you move your mouse up and down
45
+ - A photo of a pond --> a sketch that has a ripple animation on mouse click
46
+ - A photo of a wristwatch --> beautiful functioning clock that accesses system time and displays it like the wristwatch
47
+ - A photo of a lamp --> a sketch of the lamp, but when you click the screen the lamp turns on and off
48
+ - A photo of a zipper --> a sketch representing the shapes of the zipper, and when you move your mouse up and down the zipper opens and closes like a real zipper
49
+
50
+ ## PROCESS
51
+
52
+ To achieve creating this sketch, you reflect and meditate on the nature of the object BEFORE picking an algorithmic approach to represent the image. You are an agent that is thoughtful, clever, delightful, and playful.
53
+
54
+ Before you start, think about the image and the best way to represent it in p5js.
55
+
56
+ 1. Describe the behavioral properties of the image. List some ways it behaves in the real world or some patterns it exhibits. Describe the colors and vibe of the image as well.
57
+
58
+ 2. Given the behavorial properties of the image, identify a common creative coding algorithm that can be paired up to this image to make a delightful p5js sketch.
59
+
60
+ 3. State the bounding boxes of the important parts of the composition of the photo. We will need to use these bounding boxes to make sure our composition of our sketch resembles the composition of the photo uploaded. Our sketch's composition needs to resemble the composition of the uploaded photo.
61
+
62
+ 4. Implement a algorithm in p5js, using the properties of the image described earlier. Use either mouseMoved() or mouseClicked() to make it interactive. Generate a SINGLE, COMPLETE code snippet. We parse out the response you generate, so we should have only ONE code snippet that incorporates all of the information from steps 1 (behavioral description), 2 (creative coding algorithm to bring this to life), 3 (bounding boxes to preserve compositional integrity).
63
+
64
+ ## EXECUTION
65
+
66
+ Complete all of these steps. When you write your code, be sure to leave clear comments to describe the different parts of the code and what you are doing.
67
+
68
+ Do not EVER try to load in external images or any other libraries. Everything must be self contained in the one file and code snippet.
69
+
70
+ And don't be too verbose.
71
+ ```
72
+
73
+ ## Credits
74
+
75
+ Code by [Trudy Painter](https://www.trudy.computer/). Design by [Jose Guizar](https://joseguizar.com/).
76
+
77
+ ## Contributing 🤝
78
+
79
+ Contributions are welcome! See the `CONTRIBUTING.md` file for more information.
80
+
81
+ ## Disclaimer
82
+
83
+ This is an experiment showcasing Gemini 2.0's capabilities, not an official Google product. We'll do our best to support and maintain this experiment but your mileage may vary. We encourage open sourcing projects as a way of learning from each other. Please respect our and other creators' rights, including copyright and trademark rights when present, when sharing these works and creating derivative work. If you want more info on Google's policy, you can find that [here](https://www.google.com/permissions/).
84
+
85
+ ## License
86
+
87
+ Licensed under the Apache-2.0 license.
components/CodePreview.js ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright 2025 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React, { useState } from 'react';
18
+ import { Code2, Play, Copy, Check, MessageCircle } from 'lucide-react';
19
+ import Editor from '@monaco-editor/react';
20
+ import ReactMarkdown from 'react-markdown';
21
+ import remarkGfm from 'remark-gfm';
22
+ import ToggleButton from './ToggleButton';
23
+
24
+ const CodePreview = ({ output, onCodeChange, fullResponse }) => {
25
+ const [showCode, setShowCode] = useState(false);
26
+ const [showReasoning, setShowReasoning] = useState(false);
27
+ const [isCopied, setIsCopied] = useState(false);
28
+
29
+ const handleCopy = async () => {
30
+ try {
31
+ await navigator.clipboard.writeText(output.code);
32
+ setIsCopied(true);
33
+ setTimeout(() => setIsCopied(false), 2000);
34
+ } catch (err) {
35
+ console.error('Failed to copy code:', err);
36
+ }
37
+ };
38
+
39
+ const renderSketch = (code) => {
40
+ // Make sure we're working with a string
41
+ const codeString = typeof code === 'string' ? code : code.toString();
42
+
43
+ const wrappedCode = codeString.includes('function setup()') ? codeString : `
44
+ function setup() {
45
+ createCanvas(500, 500);
46
+ ${codeString}
47
+ }
48
+
49
+ function draw() {
50
+ // Add default draw function if not present
51
+ if (typeof window.draw !== 'function') {
52
+ window.draw = function() {};
53
+ }
54
+ }
55
+ `;
56
+
57
+ const formattedCodeResponse = `
58
+ <!DOCTYPE html>
59
+ <html lang="en">
60
+ <head>
61
+ <meta charset="UTF-8">
62
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
63
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script>
64
+ <title>p5.js Sketch</title>
65
+ <style>
66
+ body {
67
+ padding: 0;
68
+ margin: 0;
69
+ display: flex;
70
+ justify-content: center;
71
+ align-items: center;
72
+ min-height: 100vh;
73
+ overflow: hidden;
74
+ }
75
+ canvas {
76
+ max-width: 100% !important;
77
+ height: auto !important;
78
+ }
79
+ </style>
80
+ </head>
81
+ <body>
82
+ <script>
83
+ try {
84
+ ${wrappedCode}
85
+ // Immediately call setup if it hasn't been called
86
+ if (typeof window.setup === 'function') {
87
+ new p5();
88
+ }
89
+ } catch (error) {
90
+ console.error('Sketch error:', error);
91
+ document.body.innerHTML = '<div style="color: red; padding: 20px;"><h3>🔴 Error:</h3><pre>' + error.message + '</pre></div>';
92
+ }
93
+ </script>
94
+ </body>
95
+ </html>
96
+ `;
97
+
98
+ return (
99
+ <div className="relative w-full h-[500px] bg-gray-50 rounded-lg overflow-hidden">
100
+ <iframe
101
+ srcDoc={formattedCodeResponse}
102
+ title="p5.js Sketch"
103
+ width="100%"
104
+ height="100%"
105
+ style={{ border: "none" }}
106
+ className="absolute inset-0"
107
+ />
108
+ </div>
109
+ );
110
+ };
111
+
112
+ // Make sure we're passing the actual code string to renderSketch
113
+ const sketchCode = output?.code || '';
114
+
115
+ return (
116
+ <div className="mb-4 p-6 rounded-3xl bg-gray-100">
117
+ <div className="mb-4">
118
+ {showCode ? (
119
+ <div className="w-full h-[500px] rounded-lg overflow-hidden border">
120
+ <Editor
121
+ height="500px"
122
+ defaultLanguage="javascript"
123
+ value={sketchCode}
124
+ onChange={(value) => onCodeChange(output.id, value)}
125
+ theme="light"
126
+ options={{
127
+ minimap: { enabled: false },
128
+ fontSize: 12,
129
+ lineNumbers: 'off',
130
+ scrollBeyondLastLine: false,
131
+ automaticLayout: true,
132
+ tabSize: 2,
133
+ wordWrap: 'on',
134
+ padding: { top: 8, bottom: 8 }
135
+ }}
136
+ />
137
+ </div>
138
+ ) : showReasoning ? (
139
+ <div className="w-full h-[500px] rounded-lg overflow-y-auto border p-4 prose prose-xs max-w-none bg-white">
140
+ <ReactMarkdown
141
+ remarkPlugins={[remarkGfm]}
142
+ className="text-xs text-gray-700"
143
+ components={{
144
+ code: ({node, inline, className, children, ...props}) => (
145
+ <code className={`${className} ${inline ? 'text-[0.7rem] bg-slate-50 text-slate-900 px-1.5 py-0.5 rounded border border-slate-200' : ''}`} {...props}>
146
+ {children}
147
+ </code>
148
+ ),
149
+ pre: ({node, children, ...props}) => (
150
+ <pre className="text-[0.7rem] bg-slate-50 text-slate-900 p-3 rounded-md overflow-x-auto border border-slate-200" {...props}>
151
+ {children}
152
+ </pre>
153
+ ),
154
+ p: ({node, children}) => (
155
+ <p className="text-xs mb-2 text-gray-700">{children}</p>
156
+ ),
157
+ h1: ({node, children}) => (
158
+ <h1 className="text-sm font-bold mb-2 text-gray-900">{children}</h1>
159
+ ),
160
+ h2: ({node, children}) => (
161
+ <h2 className="text-xs font-bold mb-2 text-gray-900">{children}</h2>
162
+ ),
163
+ h3: ({node, children}) => (
164
+ <h3 className="text-xs font-semibold mb-1 text-gray-900">{children}</h3>
165
+ ),
166
+ ul: ({node, children}) => (
167
+ <ul className="text-xs list-disc pl-4 mb-2 text-gray-700">{children}</ul>
168
+ ),
169
+ ol: ({node, children}) => (
170
+ <ol className="text-xs list-decimal pl-4 mb-2 text-gray-700">{children}</ol>
171
+ ),
172
+ li: ({node, children}) => (
173
+ <li className="text-xs mb-1 text-gray-700">{children}</li>
174
+ )
175
+ }}
176
+ >
177
+ {fullResponse}
178
+ </ReactMarkdown>
179
+ </div>
180
+ ) : (
181
+ renderSketch(sketchCode)
182
+ )}
183
+ </div>
184
+
185
+ <div className="flex justify-between items-center mt-2">
186
+ <div className="inline-flex rounded-full bg-gray-200 gap-1">
187
+ <ToggleButton
188
+ icon={Play}
189
+ label="Preview"
190
+ isSelected={!showCode && !showReasoning}
191
+ onClick={() => {
192
+ setShowCode(false);
193
+ setShowReasoning(false);
194
+ }}
195
+ />
196
+ <ToggleButton
197
+ icon={MessageCircle}
198
+ label="Reasoning"
199
+ isSelected={showReasoning}
200
+ onClick={() => {
201
+ setShowCode(false);
202
+ setShowReasoning(true);
203
+ }}
204
+ />
205
+ <ToggleButton
206
+ icon={Code2}
207
+ label="Code"
208
+ isSelected={showCode}
209
+ onClick={() => {
210
+ setShowCode(true);
211
+ setShowReasoning(false);
212
+ }}
213
+ />
214
+ </div>
215
+ <button
216
+ type="button"
217
+ onClick={handleCopy}
218
+ className={`px-3.5 py-2.5 rounded-full transition-colors inline-flex text-sm border border-gray-300
219
+ items-center gap-1 ${
220
+ isCopied
221
+ ? "bg-gray-500 text-white"
222
+ : "bg-transparent text-gray-700 hover:bg-gray-100"
223
+ }`}
224
+ >
225
+ {isCopied ? (
226
+ <>
227
+ <Check size={14} />
228
+ Copied!
229
+ </>
230
+ ) : (
231
+ <>
232
+ <Copy size={14} />
233
+ Copy Code
234
+ </>
235
+ )}
236
+ </button>
237
+ </div>
238
+ </div>
239
+ );
240
+ };
241
+
242
+ export default CodePreview;
components/Header.js ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import { Github, Info } from 'lucide-react';
3
+
4
+ const Header = () => {
5
+ return (
6
+ <div className="fixed top-0 left-0 right-0 w-full bg-white p-4 z-50 ">
7
+ <div className="w-full flex justify-between items-center text-base">
8
+ <div className="text-gray-500">
9
+ <span className="text-black font-bold text-lg mr-2">Image to Code</span>
10
+ Built with <a
11
+ href="https://ai.google.dev"
12
+ target="_blank"
13
+ rel="noopener noreferrer"
14
+ className="underline hover:text-gray-800 transition-colors"
15
+ >
16
+ Gemini 2.0
17
+ </a>
18
+ </div>
19
+
20
+ <div className="flex items-center gap-3">
21
+ <a
22
+ href="https://github.com/googlecreativelab/gemini-demos/tree/main/image-to-code"
23
+ target="_blank"
24
+ rel="noopener noreferrer"
25
+ className="flex items-center gap-2 text-sm font-medium text-gray-700 hover:text-gray-900 transition-colors "
26
+ >
27
+ <Github size={18} className="text-gray-600" />
28
+ <span>GitHub Repository</span>
29
+ </a>
30
+ </div>
31
+ </div>
32
+ </div>
33
+ );
34
+ };
35
+
36
+ export default Header;
components/ToggleButton.js ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+
3
+ const ToggleButton = ({ icon: Icon, label, isSelected, onClick }) => {
4
+ const baseStyles = "inline-flex items-center gap-1 px-3.5 py-2.5 text-sm rounded-full transition-all duration-200";
5
+ const selectedStyles = "bg-black text-white";
6
+ const unselectedStyles = "bg-gray-200 text-gray-700";
7
+
8
+ return (
9
+ <button
10
+ type="button"
11
+ onClick={onClick}
12
+ className={`${baseStyles} ${isSelected ? selectedStyles : unselectedStyles}`}
13
+ >
14
+ {Icon && <Icon size={14} />}
15
+ {label}
16
+ </button>
17
+ );
18
+ };
19
+
20
+ export default ToggleButton;
jsconfig.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "paths": {
4
+ "@/*": ["./*"]
5
+ }
6
+ }
7
+ }
next.config.mjs ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright 2025 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /** @type {import('next').NextConfig} */
18
+ const nextConfig = {
19
+ // Override the default webpack configuration
20
+ webpack: (config) => {
21
+ // See https://webpack.js.org/configuration/resolve/#resolvealias
22
+ config.resolve.alias = {
23
+ ...config.resolve.alias,
24
+ "sharp$": false,
25
+ "onnxruntime-node$": false,
26
+ }
27
+ return config;
28
+ },
29
+ }
30
+
31
+ export default nextConfig;
package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
package.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "service-image-code-2",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "next dev --turbopack",
7
+ "build": "next build",
8
+ "start": "next start",
9
+ "lint": "next lint"
10
+ },
11
+ "dependencies": {
12
+ "@google/generative-ai": "^0.21.0",
13
+ "@monaco-editor/react": "^4.6.0",
14
+ "gh-pages": "^6.3.0",
15
+ "lucide-react": "^0.469.0",
16
+ "next": "15.1.3",
17
+ "react": "^19.0.0",
18
+ "react-dom": "^19.0.0",
19
+ "react-dropzone": "^14.3.5",
20
+ "react-markdown": "^9.0.3",
21
+ "remark-gfm": "^4.0.0"
22
+ },
23
+ "devDependencies": {
24
+ "@tailwindcss/typography": "^0.5.16",
25
+ "postcss": "^8",
26
+ "tailwindcss": "^3.4.1"
27
+ }
28
+ }
pages/_app.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright 2025 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import "@/styles/globals.css";
18
+
19
+ export default function App({ Component, pageProps }) {
20
+ return <Component {...pageProps} />;
21
+ }
pages/_document.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright 2025 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { Html, Head, Main, NextScript } from "next/document";
18
+
19
+ export default function Document() {
20
+ return (
21
+ <Html lang="en">
22
+ <Head />
23
+ <body className="antialiased">
24
+ <Main />
25
+ <NextScript />
26
+ </body>
27
+ </Html>
28
+ );
29
+ }
pages/api/hello.js ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright 2025 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ // Next.js API route support: https://nextjs.org/docs/api-routes/introduction
18
+
19
+ import { GoogleGenerativeAI } from "@google/generative-ai";
20
+
21
+ const MODEL_NAME = "gemini-2.0-flash-exp";
22
+
23
+ export const config = {
24
+ api: {
25
+ bodyParser: {
26
+ sizeLimit: '10mb',
27
+ },
28
+ },
29
+ };
30
+
31
+ export default async function handler(req, res) {
32
+ if (req.method !== 'POST') {
33
+ return res.status(405).json({ error: 'Method not allowed' });
34
+ }
35
+
36
+ try {
37
+ const { imageBase64, prompt, userInput } = req.body;
38
+
39
+ const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);
40
+ const model = genAI.getGenerativeModel({ model: MODEL_NAME });
41
+
42
+ const image = {
43
+ inlineData: {
44
+ data: imageBase64.split(",")[1],
45
+ mimeType: "image/jpeg",
46
+ },
47
+ };
48
+
49
+ const finalPrompt = userInput.trim()
50
+ ? `${prompt}\n\nUser input: ${userInput}`
51
+ : prompt;
52
+
53
+ const result = await model.generateContent([finalPrompt, image]);
54
+ const response = result.response.text();
55
+
56
+ const regex = /```(?:javascript|js)?\s*([\s\S]*?)```/g;
57
+ const match = regex.exec(response);
58
+ const extractedCode = match ? match[1].trim() : response;
59
+
60
+ res.status(200).json({
61
+ fullResponse: response,
62
+ code: extractedCode
63
+ });
64
+ } catch (error) {
65
+ console.error('Error:', error);
66
+ res.status(500).json({ error: 'Failed to generate code' });
67
+ }
68
+ }
pages/index.js ADDED
@@ -0,0 +1,439 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright 2025 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React, { useState, useCallback, useEffect } from "react";
18
+ import { useDropzone } from "react-dropzone";
19
+ import { ChevronDown, Image, Upload, Settings, Send, History, ArrowRight, Pen, Layers } from "lucide-react";
20
+ import Head from "next/head";
21
+ import CodePreview from "../components/CodePreview";
22
+ import Header from '../components/Header';
23
+
24
+ const SAMPLE_IMAGES = [
25
+ 'beeripple.jpeg',
26
+ 'bubbles.jpeg',
27
+ 'clock.png',
28
+ 'flower.jpeg',
29
+ 'garage.jpeg',
30
+ 'sconce.jpeg',
31
+ 'steam.jpeg',
32
+ 'tree.png',
33
+ "birds.jpeg",
34
+ "bubblemachine.png",
35
+ ];
36
+
37
+ // Helper function to generate code from image
38
+ async function generateCodeFromImage(imageBase64, prompt, userInput) {
39
+ const response = await fetch('/api/hello', {
40
+ method: 'POST',
41
+ headers: {
42
+ 'Content-Type': 'application/json',
43
+ },
44
+ body: JSON.stringify({
45
+ imageBase64,
46
+ prompt,
47
+ userInput
48
+ })
49
+ });
50
+
51
+ if (!response.ok) {
52
+ throw new Error('Failed to generate code');
53
+ }
54
+
55
+ return response.json();
56
+ }
57
+
58
+ export default function Home() {
59
+ const [imageBase64, setImageBase64] = useState("");
60
+ const [outputs, setOutputs] = useState([]);
61
+ const [loading, setLoading] = useState(false);
62
+ const [hasStartedGenerating, setHasStartedGenerating] = useState(false);
63
+ const [selectedOutput, setSelectedOutput] = useState(null);
64
+ const [concurrentRequests, setConcurrentRequests] = useState(5);
65
+ const [showPrompt, setShowPrompt] = useState(false);
66
+ const [prompt, setPrompt] = useState("");
67
+
68
+ // Load prompt from localStorage on initial render
69
+ useEffect(() => {
70
+ const savedPrompt = localStorage.getItem('savedPrompt');
71
+ if (savedPrompt) {
72
+ setPrompt(savedPrompt);
73
+ } else {
74
+ const defaultPrompt = `You are a creative coding expert who turns images into
75
+ clever code sketches using p5js. A user will upload an image and you will
76
+ generate a interactive p5js sketch that represents the image.
77
+ The code sketch always has some sort of interactive element that
78
+ connects to the nature of the object in the real world.
79
+
80
+ ## EXAMPLES
81
+
82
+ Here are some examples of what I mean by how the type of image could
83
+ be turned into a clever creative coding sketch to capture the essence of the image.
84
+ - A photo of birds --> a boids flocking algorithm sketch where the boids follow your mouse
85
+ - A photo of a tree --> a recursive fractal tree that grows as you move your mouse up and down
86
+ - A photo of a pond --> a sketch that has a ripple animation on mouse click
87
+ - A photo of a wristwatch --> beautiful functioning clock that
88
+ accesses system time and displays it like the wristwatch
89
+ - A photo of a lamp --> a sketch of the lamp, but when you click
90
+ the screen the lamp turns on and off
91
+ - A photo of a zipper --> a sketch representing the shapes of the zipper,
92
+ and when you move your mouse up and down the zipper opens and closes like a real zipper
93
+
94
+ ## PROCESS
95
+
96
+ To achieve creating this sketch, you reflect and
97
+ meditate on the nature of the object BEFORE picking an algorithmic
98
+ approach to represent the image. You are an agent that is thoughtful,
99
+ clever, delightful, and playful.
100
+
101
+ Before you start, think about the image and the best way to represent it in p5js.
102
+ 1. Describe the behavioral properties of the image. List some ways it
103
+ behaves in the real world or some patterns it exhibits. Describe the
104
+ colors and vibe of the image as well.
105
+ 2. Given the behavorial properties of the image, identify a common creative
106
+ coding algorithm that can be paired up to this image to make a delightful p5js sketch.
107
+ 3. State the bounding boxes of the important parts of the composition
108
+ of the photo. We will need to use these bounding boxes to make sure our
109
+ composition of our sketch resembles the composition of the photo uploaded.
110
+ Our sketch's composition needs to resemble the composition of the uploaded photo.
111
+ 4. Implement a algorithm in p5js, using the properties of the image described
112
+ earlier. Use either mouseMoved() or mouseClicked() to make it interactive.
113
+ Generate a SINGLE, COMPLETE code snippet. We parse out the response you generate,
114
+ so we should have only ONE code snippet that incorporates all of the information
115
+ from steps 1 (behavioral description), 2 (creative coding algorithm to bring this to life),
116
+ 3 (bounding boxes to preserve compositional integrity).
117
+
118
+ ## EXECUTION
119
+
120
+ Complete all of these steps. When you write your code, be sure to leave clear
121
+ comments to describe the different parts of the code and what you are doing.
122
+ Do not EVER try to load in external images or any other libraries.
123
+ Everything must be self contained in the one file and code snippet.
124
+ And don't be too verbose.`
125
+
126
+
127
+
128
+ .trim();
129
+ setPrompt(defaultPrompt);
130
+ localStorage.setItem('savedPrompt', defaultPrompt);
131
+ }
132
+ }, []);
133
+
134
+ // Save prompt to localStorage whenever it changes
135
+ useEffect(() => {
136
+ if (prompt) {
137
+ localStorage.setItem('savedPrompt', prompt);
138
+ }
139
+ }, [prompt]);
140
+
141
+ const [showSamples, setShowSamples] = useState(false);
142
+ const [selectedSample, setSelectedSample] = useState(null);
143
+ const [userInput, setUserInput] = useState("");
144
+ const [imageDetails, setImageDetails] = useState(null);
145
+
146
+ const onDrop = useCallback((acceptedFiles) => {
147
+ const file = acceptedFiles[0];
148
+ const reader = new FileReader();
149
+
150
+ reader.onload = (event) => {
151
+ const img = document.createElement("img");
152
+ img.src = event.target.result;
153
+
154
+ img.onload = () => {
155
+ const canvas = document.createElement("canvas");
156
+ const scaleFactor = 512 / img.width;
157
+ canvas.width = 512;
158
+ canvas.height = img.height * scaleFactor;
159
+ const ctx = canvas.getContext("2d");
160
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
161
+ setImageBase64(canvas.toDataURL());
162
+ setImageDetails({
163
+ name: file.name,
164
+ size: `${(file.size / 1024).toFixed(2)}kB`,
165
+ type: file.type
166
+ });
167
+ };
168
+ };
169
+
170
+ reader.readAsDataURL(file);
171
+ }, []);
172
+
173
+ const { getRootProps, getInputProps, isDragActive } = useDropzone({
174
+ onDrop,
175
+ accept: "image/*",
176
+ });
177
+
178
+ const generateCode = async () => {
179
+ if (!imageBase64) return;
180
+
181
+ setLoading(true);
182
+ setHasStartedGenerating(true);
183
+ setOutputs([]);
184
+ try {
185
+ const requests = Array(concurrentRequests)
186
+ .fill()
187
+ .map(() => generateCodeFromImage(imageBase64, prompt, userInput));
188
+
189
+ const results = await Promise.all(requests);
190
+ setOutputs(results.map((result, index) => ({
191
+ id: index + 1,
192
+ code: result.code,
193
+ fullResponse: result.fullResponse
194
+ })));
195
+ } catch (error) {
196
+ console.error("Error generating code:", error);
197
+ } finally {
198
+ setLoading(false);
199
+ }
200
+ };
201
+
202
+ const renderSketch = (code) => {
203
+ const formattedCodeResponse = `
204
+ <!DOCTYPE html>
205
+ <html lang="en">
206
+ <head>
207
+ <meta charset="UTF-8">
208
+ <meta name="viewport" content="width=512, initial-scale=1.0">
209
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script>
210
+ <title>p5.js Sketch</title>
211
+ <style> body {padding: 0; margin: 0;} </style>
212
+ </head>
213
+ <body>
214
+ <script>
215
+ window.onerror = function(message, source, lineno, colno, error) {
216
+ document.body.innerHTML += '<h3>🔴Error:</h3><pre>' + message + '</pre>';
217
+ };
218
+ ${code}
219
+ </script>
220
+ </body>
221
+ </html>
222
+ `;
223
+
224
+ return (
225
+ <iframe
226
+ srcDoc={formattedCodeResponse}
227
+ title="p5.js Sketch"
228
+ width="100%"
229
+ height="300"
230
+ style={{ border: "none" }}
231
+ />
232
+ );
233
+ };
234
+
235
+
236
+
237
+ const handleCodeChange = (id, newCode) => {
238
+ setOutputs((prevOutputs) =>
239
+ prevOutputs.map((output) =>
240
+ output.id === id ? { ...output, code: newCode } : output
241
+ )
242
+ );
243
+ };
244
+
245
+ const handleSampleSelect = async (imageName) => {
246
+ setSelectedSample(imageName);
247
+ try {
248
+ const response = await fetch(`/samples/${imageName}`);
249
+ const blob = await response.blob();
250
+ const reader = new FileReader();
251
+
252
+ reader.onload = (event) => {
253
+ const img = document.createElement("img");
254
+ img.src = event.target.result;
255
+
256
+ img.onload = () => {
257
+ const canvas = document.createElement("canvas");
258
+ const scaleFactor = 512 / img.width;
259
+ canvas.width = 512;
260
+ canvas.height = img.height * scaleFactor;
261
+ const ctx = canvas.getContext("2d");
262
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
263
+ setImageBase64(canvas.toDataURL());
264
+ };
265
+ };
266
+
267
+ reader.readAsDataURL(blob);
268
+ } catch (error) {
269
+ console.error('Error loading sample image:', error);
270
+ }
271
+ };
272
+
273
+ return (
274
+ <>
275
+ <Head>
276
+ <title>Image to Code</title>
277
+ </Head>
278
+ <div className="h-screen max-h-screen bg-white flex items-center justify-center overflow-y-hidden tracking-[-0.005em]">
279
+ <Header />
280
+
281
+ <div className="w-full h-full max-h-full overflow-hidden bg-white">
282
+ <div className={`flex flex-col md:flex-row gap-0 max-w-6xl mx-auto py-0 h-full transition-all duration-500 ${!hasStartedGenerating ? 'justify-center' : ''}`}>
283
+ <div className={`flex-1 h-full overflow-y-auto py-20 px-3 transition-all duration-500 ${!hasStartedGenerating ? 'md:max-w-2xl mx-auto' : ''}`}>
284
+ <section className="flex flex-col bg-gray-100 rounded-2xl p-4">
285
+ <div
286
+ {...getRootProps()}
287
+ className={`border-2 border-dashed bg-gray-100 rounded-2xl m-4 min-h-96 h-fit flex
288
+ flex-col items-center justify-center cursor-pointer hover:border-gray-400 transition-colors ${imageBase64 ? 'border-none' : 'border-gray-300'}`}
289
+ >
290
+ <input {...getInputProps()} />
291
+ {imageBase64 ? (
292
+ <img
293
+ src={imageBase64}
294
+ alt="Uploaded"
295
+ className="max-h-full max-w-full object-contain rounded-2xl"
296
+ />
297
+ ) : (
298
+ <>
299
+ <Upload className="w-12 h-12 text-gray-400 mb-4" />
300
+ <p className="text-gray-400">
301
+ {isDragActive
302
+ ? "Drop the image here"
303
+ : "Drag & drop an image here, or click to select one"}
304
+ </p>
305
+ </>
306
+ )}
307
+ </div>
308
+ <div className="max-w-xl mb-4">
309
+ <div className="flex overflow-x-auto gap-2 py-1 mx-4">
310
+ {SAMPLE_IMAGES.map((image) => (
311
+ <button
312
+ key={image}
313
+ type="button"
314
+ onClick={() => handleSampleSelect(image)}
315
+ className={`flex-shrink-0 w-14 h-14 bg-white rounded-lg hover:scale-110 transition-all ${selectedSample === image ? 'border-blue-500 ring-2 ring-blue-200' : 'border-gray-300'
316
+ }`}
317
+ >
318
+ <img
319
+ src={`/samples/${image}`}
320
+ alt={image}
321
+ className="w-full h-full object-cover rounded-lg"
322
+ />
323
+ </button>
324
+ ))}
325
+ </div>
326
+ </div>
327
+ </section>
328
+ <section className="mt-4 space-y-4 bg-gray-100 rounded-2xl p-4">
329
+ <div>
330
+ <button
331
+ type="button"
332
+ onClick={() => setShowSamples(!showSamples)}
333
+ className="flex items-center gap-2 text-sm text-gray-600 hover:text-gray-800 transition-colors"
334
+ >
335
+ {/* <Settings size={16} /> */}
336
+ <span className="font-bold">Advanced</span>
337
+ <ChevronDown
338
+ size={16}
339
+ className={`transform transition-transform ${showSamples ? 'rotate-180' : ''
340
+ }`}
341
+ />
342
+ </button>
343
+
344
+ {showSamples && (
345
+ <div className="my-2 rounded-lg">
346
+ <div className="space-y-2">
347
+ <div className="flex items-center justify-between">
348
+ <div className="flex items-center gap-2">
349
+ <Layers size={14} className="text-gray-600" />
350
+ <label htmlFor="concurrent-requests" className="text-sm font-medium text-gray-700">
351
+ Concurrent Requests: {concurrentRequests}
352
+ </label>
353
+ </div>
354
+ <input
355
+ id="concurrent-requests"
356
+ type="range"
357
+ min="1"
358
+ max="10"
359
+ value={concurrentRequests}
360
+ onChange={(e) => setConcurrentRequests(Number(e.target.value))}
361
+ className="w-1/2"
362
+ />
363
+ </div>
364
+
365
+ <button
366
+ type="button"
367
+ onClick={() => setShowPrompt(!showPrompt)}
368
+ className="flex items-center gap-2 text-sm text-gray-600 hover:text-gray-800 transition-colors"
369
+ >
370
+ <Pen size={14} />
371
+ <span>Edit System Prompt</span>
372
+ <ChevronDown
373
+ size={16}
374
+ className={`transform transition-transform ${showPrompt ? 'rotate-180' : ''}`}
375
+ />
376
+ </button>
377
+
378
+ {showPrompt && (
379
+ <textarea
380
+ value={prompt}
381
+ onChange={(e) => setPrompt(e.target.value)}
382
+ className="w-full h-64 p-2 border rounded-lg font-mono text-sm mt-2"
383
+ placeholder="Enter your prompt here..."
384
+ />
385
+ )}
386
+ </div>
387
+ </div>
388
+ )}
389
+ </div>
390
+
391
+ </section>
392
+ <section className="mt-4">
393
+ <button
394
+ type="button"
395
+ onClick={generateCode}
396
+ className="px-4 py-4 bg-gray-800 text-white rounded-2xl mb-8
397
+ hover:bg-gray-900 transition-colors w-full disabled:bg-gray-300 disabled:cursor-not-allowed
398
+ flex items-center justify-center gap-2 font-bold"
399
+ disabled={!imageBase64 || loading}
400
+ >
401
+ {/* <Send size={16} className={loading ? 'opacity-50' : ''} /> */}
402
+ <span>{loading ? "Generating..." : `Generate ${concurrentRequests} Code Snippet${concurrentRequests > 1 ? 's' : ''}`}</span>
403
+
404
+ </button>
405
+ </section>
406
+ </div>
407
+
408
+ {hasStartedGenerating && (
409
+ <div className="flex-1 h-full overflow-y-scroll py-20 px-3 animate-slide-in">
410
+ {loading ? (
411
+ // Loading skeletons for code previews
412
+ Array(concurrentRequests).fill().map((_, index) => (
413
+ <div key={`skeleton-${index}`} className="mb-4 p-6 rounded-3xl bg-gray-100 animate-pulse">
414
+ <div className="w-full h-[500px] bg-gray-200 rounded-lg mb-4" />
415
+ <div className="flex justify-between items-center">
416
+ <div className="h-10 w-32 bg-gray-200 rounded-full" />
417
+ <div className="h-10 w-24 bg-gray-200 rounded-full" />
418
+ </div>
419
+ </div>
420
+ ))
421
+ ) : (
422
+ outputs.map((output) => (
423
+ <CodePreview
424
+ key={output.id}
425
+ output={output}
426
+ onCodeChange={handleCodeChange}
427
+ fullResponse={output.fullResponse}
428
+ />
429
+ ))
430
+ )}
431
+ </div>
432
+ )}
433
+ </div>
434
+ </div>
435
+ </div>
436
+ </>
437
+ );
438
+ };
439
+
postcss.config.mjs ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright 2025 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /** @type {import('postcss-load-config').Config} */
18
+ const config = {
19
+ plugins: {
20
+ tailwindcss: {},
21
+ },
22
+ };
23
+
24
+ export default config;
public/favicon.ico ADDED
public/file.svg ADDED
public/globe.svg ADDED
public/next.svg ADDED
public/samples/beeripple.jpeg ADDED

Git LFS Details

  • SHA256: ced63e94c150eed8afe03d7cb1ae29cedc6fb1c6482c3c24e21a5dfb29523f47
  • Pointer size: 132 Bytes
  • Size of remote file: 3.04 MB
public/samples/birds.jpeg ADDED

Git LFS Details

  • SHA256: 7c894405afc7331b97392e0a54f91f7467fb8c81b950ef1d8a01feb02fcb85d8
  • Pointer size: 131 Bytes
  • Size of remote file: 727 kB
public/samples/bubblemachine.png ADDED

Git LFS Details

  • SHA256: 47f298e251c6eae0ffae19ad57f5cfdc2dfbdfe50361d760dd39a0065f9a7e7f
  • Pointer size: 132 Bytes
  • Size of remote file: 7.4 MB
public/samples/bubbles.jpeg ADDED

Git LFS Details

  • SHA256: b0a041d8518013390639c711b11b55d484376c249bccce4e3c5067d26db25261
  • Pointer size: 132 Bytes
  • Size of remote file: 2 MB
public/samples/clock.png ADDED

Git LFS Details

  • SHA256: 0e309fd829af3922b26f5396cb0bc30189ff7115682fef9fdca9f1f398ecbd33
  • Pointer size: 132 Bytes
  • Size of remote file: 5.05 MB
public/samples/flower.jpeg ADDED

Git LFS Details

  • SHA256: f98658690be0404a04114716f5ea27d4f6ec80fce4bca054343ae8cc06f2caba
  • Pointer size: 131 Bytes
  • Size of remote file: 564 kB
public/samples/garage.jpeg ADDED

Git LFS Details

  • SHA256: 998c539a94ec7a04bbc6cc8c35671397e1480952dbd517dcc0f847063fe6d79e
  • Pointer size: 132 Bytes
  • Size of remote file: 2.15 MB
public/samples/sconce.jpeg ADDED

Git LFS Details

  • SHA256: 818a59ff2a9fc608560855934932497995ecf8fe13dd519cbf2a5f41dd501f54
  • Pointer size: 132 Bytes
  • Size of remote file: 1.47 MB
public/samples/steam.jpeg ADDED

Git LFS Details

  • SHA256: 8744396c34bb9adacd7405326dd9f4db650d30d897922a85575c4b413120d1ac
  • Pointer size: 131 Bytes
  • Size of remote file: 795 kB
public/samples/tree.png ADDED

Git LFS Details

  • SHA256: 9e2f2a8db5c326879b221b368b8a7b4278b4b97035ba42134b759fa69fc06a23
  • Pointer size: 132 Bytes
  • Size of remote file: 2.31 MB
public/vercel.svg ADDED
public/window.svg ADDED
readme/smoke.gif ADDED

Git LFS Details

  • SHA256: a0294bf861f4747ae109b49b8f8224ed650b2c41c3ec8dc3a10905fb6b9ad84e
  • Pointer size: 132 Bytes
  • Size of remote file: 6.39 MB
styles/globals.css ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright 2025 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ @tailwind base;
18
+ @tailwind components;
19
+ @tailwind utilities;
20
+
21
+ :root {
22
+ --background: #ffffff;
23
+ --foreground: #171717;
24
+ }
25
+
26
+ @media (prefers-color-scheme: dark) {
27
+ :root {
28
+ --background: #0a0a0a;
29
+ --foreground: #ededed;
30
+ }
31
+ }
32
+
33
+ body {
34
+ color: var(--foreground);
35
+ background: var(--background);
36
+ font-family: Arial, Helvetica, sans-serif;
37
+ }
tailwind.config.js ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright 2025 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /** @type {import('tailwindcss').Config} */
18
+ module.exports = {
19
+ content: [
20
+ './pages/**/*.{js,ts,jsx,tsx,mdx}',
21
+ './components/**/*.{js,ts,jsx,tsx,mdx}',
22
+ './app/**/*.{js,ts,jsx,tsx,mdx}',
23
+ ],
24
+ theme: {
25
+ extend: {
26
+ keyframes: {
27
+ 'fade-in-out': {
28
+ '0%': { opacity: '0', transform: 'translateY(-10px)' },
29
+ '10%': { opacity: '1', transform: 'translateY(0)' },
30
+ '90%': { opacity: '1' },
31
+ '100%': { opacity: '0' }
32
+ },
33
+ 'slide-in': {
34
+ '0%': { transform: 'translateX(100%)' },
35
+ '100%': { transform: 'translateX(0)' }
36
+ }
37
+ },
38
+ animation: {
39
+ 'fade-in-out': 'fade-in-out 5s ease-in-out',
40
+ 'slide-in': 'slide-in 0.5s ease-out'
41
+ },
42
+ typography: {
43
+ xs: {
44
+ css: {
45
+ fontSize: '0.75rem',
46
+ lineHeight: '1.2',
47
+ color: '#374151',
48
+ p: {
49
+ marginBottom: '0.5rem',
50
+ },
51
+ h1: {
52
+ fontSize: '1rem',
53
+ marginBottom: '0.75rem',
54
+ },
55
+ h2: {
56
+ fontSize: '0.875rem',
57
+ marginBottom: '0.5rem',
58
+ },
59
+ h3: {
60
+ fontSize: '0.75rem',
61
+ marginBottom: '0.5rem',
62
+ },
63
+ 'code': {
64
+ fontSize: '0.7rem !important',
65
+ padding: '0.1rem 0.2rem',
66
+ backgroundColor: '#f8fafc',
67
+ color: '#0f172a !important',
68
+ borderRadius: '0.25rem',
69
+ border: '1px solid #e2e8f0',
70
+ },
71
+ 'pre': {
72
+ fontSize: '0.7rem !important',
73
+ padding: '0.75rem',
74
+ marginBottom: '0.75rem',
75
+ backgroundColor: '#f8fafc',
76
+ color: '#0f172a',
77
+ border: '1px solid #e2e8f0',
78
+ code: {
79
+ fontSize: '0.7rem !important',
80
+ backgroundColor: 'transparent',
81
+ padding: 0,
82
+ border: 'none',
83
+ color: '#0f172a',
84
+ }
85
+ },
86
+ 'ul': {
87
+ marginBottom: '0.75rem',
88
+ },
89
+ 'ol': {
90
+ marginBottom: '0.75rem',
91
+ },
92
+ 'li': {
93
+ marginBottom: '0.25rem',
94
+ }
95
+ }
96
+ }
97
+ }
98
+ },
99
+ },
100
+ plugins: [
101
+ require('@tailwindcss/typography'),
102
+ ],
103
+ }
tailwind.config.mjs ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright 2025 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /** @type {import('tailwindcss').Config} */
18
+ export default {
19
+ content: [
20
+ "./pages/**/*.{js,ts,jsx,tsx,mdx}",
21
+ "./components/**/*.{js,ts,jsx,tsx,mdx}",
22
+ "./app/**/*.{js,ts,jsx,tsx,mdx}",
23
+ ],
24
+ theme: {
25
+ extend: {
26
+ colors: {
27
+ background: "var(--background)",
28
+ foreground: "var(--foreground)",
29
+ },
30
+ },
31
+ },
32
+ plugins: [],
33
+ };