Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add Wave Function Collapse #5

Merged
merged 32 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8198e7b
:sparkles: Add Wave Function Collapse
matyo91 Sep 8, 2024
588ec40
:sparkles: Add symfony live component
Sep 10, 2024
08ba65d
:sparkles: update
Sep 10, 2024
51ef566
:art: Add layout
Sep 10, 2024
388ec0e
:bug: fix scrap
matyo91 Sep 10, 2024
e8a3ada
:bug: fix scrap
matyo91 Sep 10, 2024
ee1d3ad
:art: Update twig layout
matyo91 Sep 10, 2024
3802cac
:heavy_plus_sign: Add SassBundle
matyo91 Sep 10, 2024
1cd484e
:heavy_plus_sign: Add SassBundle
matyo91 Sep 10, 2024
df0ed0a
:art: Use symfony ux icons
matyo91 Sep 15, 2024
a2d1cc5
:hammer: Update live event
matyo91 Sep 15, 2024
2d4f375
:art: Update symfony ux layout
matyo91 Sep 16, 2024
3524260
:white_check_mark: Fix CI
matyo91 Sep 16, 2024
95ee7a7
:ambulance: SymfonyInsight
matyo91 Sep 18, 2024
c6b2b30
:recycle: Rename UrlContent
matyo91 Sep 18, 2024
306885e
:lipstick: Use base template
matyo91 Sep 18, 2024
8be5207
:sparkles: Add WFC structure
matyo91 Sep 18, 2024
abc0cb5
:hammer: add code transpiled skeleton
matyo91 Oct 2, 2024
da06e86
:white_check_mark: Collapse work
matyo91 Oct 5, 2024
36e6864
:art: map titles sets
matyo91 Oct 5, 2024
1b82cf8
:heavy_plus_sign: Add auto-collapse button
matyo91 Oct 5, 2024
bc5f1e2
:white_check_mark: Make CI pass
matyo91 Oct 5, 2024
3086f68
:ambulance: Symfonyinsight
matyo91 Oct 6, 2024
1aad510
:art: generate texture
Oct 7, 2024
97dc0a0
:art: reduce WFC container
matyo91 Oct 7, 2024
3e6fb7c
:art: generate artistic texture
Oct 8, 2024
235fd91
:fire: Remove SocialBuilder
Oct 15, 2024
beb53f1
:recycle: Move Board as a model
matyo91 Oct 20, 2024
f9ae1d1
:art: Add Mp4Job
matyo91 Oct 20, 2024
91b6256
:recycle: Refactor jobs
matyo91 Oct 20, 2024
535a931
:sparkles: Add Daily Flow generation task
matyo91 Oct 26, 2024
c55ad2c
:lipstick: Update cron every day at 7
matyo91 Oct 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
###> symfony/mailer ###
# MAILER_DSN=null://null
###< symfony/mailer ###

TWITTER_DSN=twitter://API_KEY:API_SECRET:ACCESS_TOKEN:ACCESS_SECRET@default
3 changes: 3 additions & 0 deletions .symfony.local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
workers:
sass:
cmd: ['symfony', 'console', 'sass:build', '--watch']
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
dev: ## Start dev server
composer dev

build: ## Build
php bin/console sass:build
php bin/console asset-map:compile

docs-serve: ## Start documentation server locally
composer docs-serve

Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<a href="https://github.com/matyo91/flow-live">
<img src="public/logo.png" width="auto" height="128px" alt="Flow">
<img src="assets/images/logo.png" width="auto" height="128px" alt="Flow">
</a>
</p>

Expand Down Expand Up @@ -45,6 +45,16 @@ Flow as a container for PHP-ETL, for more details, please visit: [https://php-et
bin/console app:php-etl
```

### Wave Function Collapse

Inspired by
- https://github.com/CodingTrain/Wave-Function-Collapse
- https://github.com/FeatheredSnek/phpwfc

```
bin/console app:wave-function-collapse
```

## License

Live Flow is released under the MIT License.
11 changes: 1 addition & 10 deletions assets/app.js
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
import './bootstrap.js';
/*
* Welcome to your app's main JavaScript file!
*
* This file will be included onto the page via the importmap() Twig function,
* which should already be in your base.html.twig.
*/
import './styles/app.css';

console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉');
import './bootstrap.js';
9 changes: 9 additions & 0 deletions assets/controllers.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"controllers": {
"@symfony/ux-live-component": {
"live": {
"enabled": true,
"fetch": "eager",
"autoimport": {
"@symfony/ux-live-component/dist/live.min.css": true
}
}
},
"@symfony/ux-turbo": {
"turbo-core": {
"enabled": true,
Expand Down
Binary file added assets/fonts/Jost-400-Book.otf
Binary file not shown.
Binary file added assets/fonts/Jost-400-BookItalic.otf
Binary file not shown.
Binary file added assets/fonts/Jost-500-Medium.otf
Binary file not shown.
Binary file added assets/fonts/Jost-500-MediumItalic.otf
Binary file not shown.
Binary file added assets/fonts/Jost-600-Semi.otf
Binary file not shown.
Binary file added assets/fonts/Jost-600-SemiItalic.otf
Binary file not shown.
Binary file added assets/fonts/Jost-700-Bold.otf
Binary file not shown.
Binary file added assets/fonts/Jost-700-BoldItalic.otf
Binary file not shown.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/wave-function-collapse/circuit/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/wave-function-collapse/circuit/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/wave-function-collapse/circuit/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/wave-function-collapse/circuit/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/wave-function-collapse/circuit/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/wave-function-collapse/circuit/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/wave-function-collapse/circuit/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/wave-function-collapse/circuit/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/wave-function-collapse/circuit/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/wave-function-collapse/circuit/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/wave-function-collapse/circuit/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/wave-function-collapse/circuit/8.png
Binary file added assets/images/wave-function-collapse/circuit/9.png
Binary file added assets/images/wave-function-collapse/demo/0.png
Binary file added assets/images/wave-function-collapse/demo/1.png
Binary file added assets/images/wave-function-collapse/demo/2.png
Binary file added assets/images/wave-function-collapse/demo/3.png
Binary file added assets/images/wave-function-collapse/demo/4.png
Binary file added assets/images/wave-function-collapse/floor/0.png
Binary file added assets/images/wave-function-collapse/floor/1.png
Binary file added assets/images/wave-function-collapse/floor/10.png
Binary file added assets/images/wave-function-collapse/floor/11.png
Binary file added assets/images/wave-function-collapse/floor/12.png
Binary file added assets/images/wave-function-collapse/floor/13.png
Binary file added assets/images/wave-function-collapse/floor/14.png
Binary file added assets/images/wave-function-collapse/floor/15.png
Binary file added assets/images/wave-function-collapse/floor/16.png
Binary file added assets/images/wave-function-collapse/floor/2.png
Binary file added assets/images/wave-function-collapse/floor/3.png
Binary file added assets/images/wave-function-collapse/floor/4.png
Binary file added assets/images/wave-function-collapse/floor/5.png
Binary file added assets/images/wave-function-collapse/floor/6.png
Binary file added assets/images/wave-function-collapse/floor/7.png
Binary file added assets/images/wave-function-collapse/floor/8.png
Binary file added assets/images/wave-function-collapse/floor/9.png
Binary file added assets/images/wave-function-collapse/pipes/0.png
Binary file added assets/images/wave-function-collapse/pipes/1.png
Binary file added assets/images/wave-function-collapse/pipes/4.png
Binary file added assets/images/wave-function-collapse/polka/0.png
Binary file added assets/images/wave-function-collapse/polka/1.png
Binary file added assets/images/wave-function-collapse/polka/2.png
Binary file added assets/images/wave-function-collapse/polka/3.png
Binary file added assets/images/wave-function-collapse/polka/4.png
Binary file added assets/images/wave-function-collapse/roads/0.png
Binary file added assets/images/wave-function-collapse/roads/1.png
Binary file added assets/images/wave-function-collapse/roads/2.png
Binary file added assets/images/wave-function-collapse/roads/3.png
Binary file added assets/images/wave-function-collapse/roads/4.png
Binary file added assets/images/wave-function-collapse/space/0.png
Binary file added assets/images/wave-function-collapse/space/1.png
Binary file added assets/images/wave-function-collapse/space/10.png
Binary file added assets/images/wave-function-collapse/space/11.png
Binary file added assets/images/wave-function-collapse/space/12.png
Binary file added assets/images/wave-function-collapse/space/13.png
Binary file added assets/images/wave-function-collapse/space/14.png
Binary file added assets/images/wave-function-collapse/space/15.png
Binary file added assets/images/wave-function-collapse/space/19.png
Binary file added assets/images/wave-function-collapse/space/2.png
Binary file added assets/images/wave-function-collapse/space/20.png
Binary file added assets/images/wave-function-collapse/space/21.png
Binary file added assets/images/wave-function-collapse/space/22.png
Binary file added assets/images/wave-function-collapse/space/23.png
Binary file added assets/images/wave-function-collapse/space/24.png
Binary file added assets/images/wave-function-collapse/space/25.png
Binary file added assets/images/wave-function-collapse/space/26.png
Binary file added assets/images/wave-function-collapse/space/27.png
Binary file added assets/images/wave-function-collapse/space/28.png
Binary file added assets/images/wave-function-collapse/space/29.png
Binary file added assets/images/wave-function-collapse/space/3.png
Binary file added assets/images/wave-function-collapse/space/30.png
Binary file added assets/images/wave-function-collapse/space/31.png
Binary file added assets/images/wave-function-collapse/space/32.png
Binary file added assets/images/wave-function-collapse/space/33.png
Binary file added assets/images/wave-function-collapse/space/36.png
Binary file added assets/images/wave-function-collapse/space/37.png
Binary file added assets/images/wave-function-collapse/space/38.png
Binary file added assets/images/wave-function-collapse/space/39.png
Binary file added assets/images/wave-function-collapse/space/4.png
Binary file added assets/images/wave-function-collapse/space/42.png
Binary file added assets/images/wave-function-collapse/space/43.png
Binary file added assets/images/wave-function-collapse/space/44.png
Binary file added assets/images/wave-function-collapse/space/45.png
Binary file added assets/images/wave-function-collapse/space/46.png
Binary file added assets/images/wave-function-collapse/space/47.png
Binary file added assets/images/wave-function-collapse/space/48.png
Binary file added assets/images/wave-function-collapse/space/49.png
Binary file added assets/images/wave-function-collapse/space/5.png
Binary file added assets/images/wave-function-collapse/space/50.png
Binary file added assets/images/wave-function-collapse/space/51.png
Binary file added assets/images/wave-function-collapse/space/52.png
Binary file added assets/images/wave-function-collapse/space/53.png
Binary file added assets/images/wave-function-collapse/space/54.png
Binary file added assets/images/wave-function-collapse/space/55.png
Binary file added assets/images/wave-function-collapse/space/56.png
Binary file added assets/images/wave-function-collapse/space/57.png
Binary file added assets/images/wave-function-collapse/space/58.png
Binary file added assets/images/wave-function-collapse/space/59.png
Binary file added assets/images/wave-function-collapse/space/6.png
Binary file added assets/images/wave-function-collapse/space/60.png
Binary file added assets/images/wave-function-collapse/space/61.png
Binary file added assets/images/wave-function-collapse/space/62.png
Binary file added assets/images/wave-function-collapse/space/63.png
Binary file added assets/images/wave-function-collapse/space/64.png
Binary file added assets/images/wave-function-collapse/space/67.png
Binary file added assets/images/wave-function-collapse/space/69.png
Binary file added assets/images/wave-function-collapse/space/7.png
Binary file added assets/images/wave-function-collapse/space/8.png
Binary file added assets/images/wave-function-collapse/space/9.png
203 changes: 203 additions & 0 deletions assets/images/wave-function-collapse/texture/generate_texture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
const textures = {
G: { name: 'water', color: [30, 144, 255], pattern: createWaterPattern },
H: { name: 'mountain', color: [139, 69, 19], pattern: createMountainPattern },
V: { name: 'village', color: [255, 215, 0], pattern: createVillagePattern },
F: { name: 'forest', color: [34, 139, 34], pattern: createForestPattern },
D: { name: 'desert', color: [237, 201, 175], pattern: createDesertPattern },
L: { name: 'land', color: [160, 82, 45], pattern: createLandPattern },
A: { name: 'lava', color: [255, 69, 0], pattern: createLavaPattern },
R: { name: 'road', color: [128, 128, 128], pattern: createRoadPattern },
I: { name: 'ice', color: [173, 216, 230], pattern: createIcePattern }
};

function createWaterPattern(ctx, x, y, size) {
const gradient = ctx.createLinearGradient(x, y, x, y + size);
gradient.addColorStop(0, 'rgba(30, 144, 255, 0.9)');
gradient.addColorStop(1, 'rgba(30, 144, 255, 0.5)');
ctx.fillStyle = gradient;
ctx.fillRect(x, y, size, size);

ctx.fillStyle = 'rgba(255, 255, 255, 0.4)'; // Light white for waves
for (let i = 0; i < 15; i++) {
const radius = Math.random() * 15 + 5;
ctx.beginPath();
ctx.arc(x + Math.random() * size, y + Math.random() * size, radius, 0, Math.PI * 2);
ctx.fill();
}
}

function createMountainPattern(ctx, x, y, size) {
const gradient = ctx.createLinearGradient(x, y, x, y + size);
gradient.addColorStop(0, 'rgba(139, 69, 19, 0.8)'); // Mountain color
gradient.addColorStop(1, 'rgba(160, 82, 45, 0.7)'); // Lighter shade
ctx.fillStyle = gradient;
ctx.fillRect(x, y, size, size);
ctx.fillStyle = 'rgba(255, 255, 255, 0.3)'; // Snow caps
ctx.beginPath();
ctx.moveTo(x + size / 2, y);
ctx.lineTo(x + size, y + size);
ctx.lineTo(x, y + size);
ctx.fill();
}

function createVillagePattern(ctx, x, y, size) {
const gradient = ctx.createLinearGradient(x, y, x, y + size);
gradient.addColorStop(0, 'rgba(255, 215, 0, 0.9)'); // Base village color
gradient.addColorStop(1, 'rgba(218, 165, 32, 0.9)'); // Darker shade
ctx.fillStyle = gradient;
ctx.fillRect(x, y, size, size);
}

function createForestPattern(ctx, x, y, size) {
ctx.fillStyle = 'rgba(34, 139, 34, 0.9)'; // Forest base
ctx.fillRect(x, y, size, size);

for (let i = 0; i < 10; i++) {
const treeX = x + Math.random() * size;
const treeY = y + Math.random() * size;
ctx.fillStyle = 'rgba(107, 142, 35, 0.9)'; // Darker green for trees
ctx.beginPath();
ctx.moveTo(treeX, treeY);
ctx.lineTo(treeX + 10, treeY + 30);
ctx.lineTo(treeX + 20, treeY);
ctx.fill();
}
}

function createDesertPattern(ctx, x, y, size) {
const gradient = ctx.createLinearGradient(x, y, x, y + size);
gradient.addColorStop(0, 'rgba(237, 201, 175, 0.9)'); // Desert color
gradient.addColorStop(1, 'rgba(210, 180, 140, 0.7)'); // Darker shade
ctx.fillStyle = gradient;
ctx.fillRect(x, y, size, size);

for (let i = 0; i < 5; i++) {
const arcX = x + Math.random() * size;
const arcY = y + Math.random() * size;
ctx.fillStyle = 'rgba(210, 180, 140, 0.5)'; // Sand details
ctx.beginPath();
ctx.arc(arcX, arcY, 10, 0, Math.PI * 2);
ctx.fill();
}
}

function createLandPattern(ctx, x, y, size) {
ctx.fillStyle = 'rgba(160, 82, 45, 0.9)'; // Land color
ctx.fillRect(x, y, size, size);

for (let i = 0; i < 5; i++) {
const detailX = x + Math.random() * size;
const detailY = y + Math.random() * size;
ctx.fillStyle = 'rgba(205, 133, 63, 0.6)'; // Inner texture
ctx.beginPath();
ctx.arc(detailX, detailY, 5, 0, Math.PI * 2);
ctx.fill();
}
}

function createLavaPattern(ctx, x, y, size) {
const gradient = ctx.createLinearGradient(x, y, x, y + size);
gradient.addColorStop(0, 'rgba(255, 0, 0, 0.9)');
gradient.addColorStop(1, 'rgba(255, 69, 0, 0.7)');
ctx.fillStyle = gradient;
ctx.fillRect(x, y, size, size);
}

function createRoadPattern(ctx, x, y, size) {
ctx.fillStyle = 'rgba(128, 128, 128, 0.9)'; // Road color
ctx.fillRect(x, y, size, size);
ctx.fillStyle = 'rgba(255, 255, 255, 0.5)'; // Road markings
for (let i = 0; i < 4; i++) {
ctx.fillRect(x + size / 4 + (size / 2) * (i % 2), y + size / 2 - 5 + (i % 2) * 10, size / 8, 10);
}
}

function createIcePattern(ctx, x, y, size) {
const gradient = ctx.createLinearGradient(x, y, x, y + size);
gradient.addColorStop(0, 'rgba(173, 216, 230, 0.8)'); // Light blue
gradient.addColorStop(1, 'rgba(135, 206, 250, 0.5)'); // Lighter blue
ctx.fillStyle = gradient;
ctx.fillRect(x, y, size, size);
ctx.fillStyle = 'rgba(255, 255, 255, 0.4)'; // Frosty overlay
for (let i = 0; i < 10; i++) {
ctx.beginPath();
ctx.arc(x + Math.random() * size, y + Math.random() * size, 5, 0, Math.PI * 2);
ctx.fill();
}
}

// Function to generate the final texture
function generateTexture(rows) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const tileSize = 100; // Size of each texture tile

// Set canvas size based on the number of rows and columns
const numberOfRows = rows.length;
const numberOfColumns = rows[0].length;

canvas.width = tileSize * numberOfColumns;
canvas.height = tileSize * numberOfRows;

// Fill the canvas with the corresponding texture colors
for (let row = 0; row < numberOfRows; row++) {
for (let col = 0; col < numberOfColumns; col++) {
const letter = rows[row][col];
const texture = textures[letter]; // Only get texture if it exists
if (texture) {
// Use the pattern function to fill the texture
texture.pattern(ctx, col * tileSize, row * tileSize, tileSize);

// Blend with adjacent tiles
if (col > 0) {
blendTextures(ctx, col * tileSize, row * tileSize, textures[rows[row][col - 1]]);
}
if (row > 0) {
blendTextures(ctx, col * tileSize, row * tileSize, textures[rows[row - 1][col]]);
}
}
}
}

return canvas.toDataURL(); // Return image data URL
}

// Function to blend two textures
function blendTextures(ctx, x, y, adjacentTexture) {
if (!adjacentTexture) return;
const gradient = ctx.createLinearGradient(x, y, x + 100, y + 100);
gradient.addColorStop(0, 'rgba(255, 255, 255, 0.2)'); // White with transparency
gradient.addColorStop(1, `rgba(${adjacentTexture.color.join(',')}, 0.5)`); // Blend with adjacent color
ctx.fillStyle = gradient;
ctx.fillRect(x, y, 100, 100); // Fill with blended color
}

// Generate random input with specified rows and columns
function getRandomInput(rows, columns) {
const keys = Object.keys(textures);
const randomInput = [];
for (let i = 0; i < rows; i++) {
let row = '';
for (let j = 0; j < columns; j++) {
const randomIndex = Math.floor(Math.random() * keys.length);
row += keys[randomIndex]; // Append a random texture key
}
randomInput.push(row); // Add the row to the random input
}
return randomInput;
}

// Generate random input for a 3x3 texture
const inputLetters = getRandomInput(3, 3);

// Generate and display the texture image
const textureImage = generateTexture(inputLetters);

// Create an img element
const img = document.createElement('img');
img.src = textureImage;
img.alt = 'Generated Realistic Texture';
img.style.margin = '10px'; // Add some margin

// Append the img element to the document body
document.body.appendChild(img);
11 changes: 11 additions & 0 deletions assets/images/wave-function-collapse/texture/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Texture Generator</title>
</head>
<body>
<script src="generate_texture.js"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions assets/libraries/bootstrap-5.3.3/js/bootstrap.bundle.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions assets/libraries/bootstrap-5.3.3/js/bootstrap.esm.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions assets/libraries/bootstrap-5.3.3/js/bootstrap.min.js

Large diffs are not rendered by default.

Loading
Loading