Fraser commited on
Commit
34f0868
·
1 Parent(s): 51003e8
Files changed (1) hide show
  1. src/lib/services/picletExport.ts +10 -11
src/lib/services/picletExport.ts CHANGED
@@ -10,27 +10,26 @@ export async function generateShareableImage(piclet: PicletInstance): Promise<Bl
10
  const ctx = canvas.getContext('2d');
11
  if (!ctx) throw new Error('Could not create canvas context');
12
 
13
- // Set canvas size - narrower width to match content
14
  const canvasWidth = 700;
15
- const canvasHeight = 900; // More reasonable height
16
  canvas.width = canvasWidth;
17
  canvas.height = canvasHeight;
18
 
19
- // Fill background with solid sky blue
20
- ctx.fillStyle = '#87CEEB';
21
- ctx.fillRect(0, 0, canvasWidth, canvasHeight);
22
 
23
  // Load piclet image first
24
  const picletImg = await loadImage(piclet.imageData || piclet.imageUrl);
25
  const picletSize = 512;
26
  const picletX = (canvasWidth - picletSize) / 2;
27
- const picletY = canvasHeight - picletSize - 100; // Position piclet with bottom margin
28
 
29
  // Load and draw grass platform positioned under the piclet
30
  const grassImg = await loadImage('/assets/grass.PNG');
31
  const platformSize = picletSize + 100; // Slightly larger than piclet
32
  const platformX = (canvasWidth - platformSize) / 2;
33
- const platformY = picletY + picletSize - 100; // Platform sits right under piclet
34
  ctx.drawImage(grassImg, platformX, platformY, platformSize, platformSize);
35
 
36
  // Draw piclet on top of platform
@@ -41,9 +40,9 @@ export async function generateShareableImage(piclet: PicletInstance): Promise<Bl
41
  ctx.strokeStyle = '#1e3a8a'; // Dark blue outline
42
  ctx.lineWidth = 8;
43
  // Try to use a more gaming-style font, fallback to Impact
44
- ctx.font = 'bold 72px "Press Start 2P", "Courier New", Impact, monospace';
45
  ctx.textAlign = 'center';
46
- ctx.shadowColor = 'rgba(0, 0, 0, 0.5)';
47
  ctx.shadowBlur = 10;
48
  ctx.shadowOffsetX = 4;
49
  ctx.shadowOffsetY = 4;
@@ -51,8 +50,8 @@ export async function generateShareableImage(piclet: PicletInstance): Promise<Bl
51
  const nameText = piclet.nickname || piclet.typeId;
52
 
53
  // Draw name with outline and shadow
54
- ctx.strokeText(nameText, canvasWidth / 2, 150);
55
- ctx.fillText(nameText, canvasWidth / 2, 150);
56
 
57
  // Reset shadow
58
  ctx.shadowColor = 'transparent';
 
10
  const ctx = canvas.getContext('2d');
11
  if (!ctx) throw new Error('Could not create canvas context');
12
 
13
+ // Set canvas size - narrower width to match content, tighter height
14
  const canvasWidth = 700;
15
+ const canvasHeight = 700; // Square format, tighter
16
  canvas.width = canvasWidth;
17
  canvas.height = canvasHeight;
18
 
19
+ // Clear canvas for transparency (no background fill)
20
+ ctx.clearRect(0, 0, canvasWidth, canvasHeight);
 
21
 
22
  // Load piclet image first
23
  const picletImg = await loadImage(piclet.imageData || piclet.imageUrl);
24
  const picletSize = 512;
25
  const picletX = (canvasWidth - picletSize) / 2;
26
+ const picletY = 120; // Position piclet closer to top, leaving room for name
27
 
28
  // Load and draw grass platform positioned under the piclet
29
  const grassImg = await loadImage('/assets/grass.PNG');
30
  const platformSize = picletSize + 100; // Slightly larger than piclet
31
  const platformX = (canvasWidth - platformSize) / 2;
32
+ const platformY = picletY + picletSize - 200; // Platform overlaps bottom of piclet
33
  ctx.drawImage(grassImg, platformX, platformY, platformSize, platformSize);
34
 
35
  // Draw piclet on top of platform
 
40
  ctx.strokeStyle = '#1e3a8a'; // Dark blue outline
41
  ctx.lineWidth = 8;
42
  // Try to use a more gaming-style font, fallback to Impact
43
+ ctx.font = 'bold 64px "Press Start 2P", "Courier New", Impact, monospace';
44
  ctx.textAlign = 'center';
45
+ ctx.shadowColor = 'rgba(0, 0, 0, 0.8)';
46
  ctx.shadowBlur = 10;
47
  ctx.shadowOffsetX = 4;
48
  ctx.shadowOffsetY = 4;
 
50
  const nameText = piclet.nickname || piclet.typeId;
51
 
52
  // Draw name with outline and shadow
53
+ ctx.strokeText(nameText, canvasWidth / 2, 80);
54
+ ctx.fillText(nameText, canvasWidth / 2, 80);
55
 
56
  // Reset shadow
57
  ctx.shadowColor = 'transparent';