Investigate how to manipulate the cards into a 3x3 grid programmatically #110
Vylpes
commented 2023-12-10 15:25:30 +00:00
Owner
No description provided.
Vylpes
referenced this issue 2023-12-10 15:27:14 +00:00
AS a user, I want the inventory command to show my cards in a grid of images #79
Vylpes
added the 2024-05-20 09:52:03 +01:00
type
spike
label
Vylpes
added this to the 0.7.0 milestone 2024-06-02 16:07:54 +01:00
Vylpes
added this to the 0.7 Sprint 2 project 2024-06-16 15:43:27 +01:00
Vylpes
self-assigned this 2024-06-18 18:46:47 +01:00
Vylpes
started working 2024-06-21 17:15:08 +01:00
Vylpes
stopped working 2024-06-21 17:45:31 +01:00
30 minutes 23 seconds
Vylpes
commented 2024-06-21 17:46:21 +01:00
Author
Owner
```js
const { createCanvas, loadImage } = require('canvas');
const { writeFileSync } = require('fs');
async function test(gridSize) {
const totalImages = gridSize ** 2;
const imageWidth = 526;
const imageHeight = 712;
const canvasWidth = imageWidth * gridSize;
const canvasHeight = imageHeight * Math.floor(totalImages / gridSize);
const canvas = createCanvas(canvasWidth, canvasHeight);
const ctx = canvas.getContext('2d');
const images = [];
for (let i = 0; i < totalImages; i++) {
images.push(await loadImage(`cards/${i}.png`));
}
for (let i = 0; i < images.length; i++) {
const image = images[i];
const x = i % gridSize;
const y = Math.floor(i / gridSize);
const imageX = imageWidth * x;
const imageY = imageHeight * y;
ctx.drawImage(image, imageX, imageY);
writeFileSync("out.png", canvas.toBuffer());
}
}
test(3);
```
Vylpes
closed this issue 2024-06-22 10:18:11 +01:00
Labels
No labels
blocked
duplicate
needs criteria
needs estimate
needs testing
question
requires documentation
type
admin
type
alert
type
bug
type
change
type
defect
type
dependencies
type
epic
type
spike
type
story
type
subtask
won't fix
No project
No assignees
1 participant
Notifications
Total time spent: 30 minutes 23 seconds
Due date
Vylpes
30 minutes 23 seconds
No due date set.
Dependencies
No dependencies set.
Reference: External/card-drop#110
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?