You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, windowTitle = "MS Paint", desktopColor = "#008080") {
// Basic constants for layout
const C_MARGIN_X = 50;
const C_MARGIN_Y = 50;
const MIN_WIN_W = 200;
const iw = originalImg.width;
const ih = originalImg.height;
// Calculate window bounds
const winW = Math.max(iw + 8, MIN_WIN_W);
const winH = ih + 28;
// Create the canvas
const c = document.createElement('canvas');
c.width = winW + C_MARGIN_X * 2;
c.height = winH + C_MARGIN_Y * 2;
const ctx = c.getContext('2d');
// 1. Draw "Desktop" background
ctx.fillStyle = desktopColor;
ctx.fillRect(0, 0, c.width, c.height);
// 2. Draw standard Windows 95 style base window frame
const winX = C_MARGIN_X;
const winY = C_MARGIN_Y;
// Base background color
ctx.fillStyle = '#c0c0c0';
ctx.fillRect(winX, winY, winW, winH);
// Outer borders
ctx.fillStyle = '#ffffff'; // Top outer highlight
ctx.fillRect(winX, winY, winW, 1);
ctx.fillRect(winX, winY, 1, winH); // Left outer highlight
ctx.fillStyle = '#000000'; // Bottom outer shadow
ctx.fillRect(winX, winY + winH - 1, winW, 1);
ctx.fillRect(winX + winW - 1, winY, 1, winH); // Right outer shadow
// Inner borders
ctx.fillStyle = '#dfdfdf'; // Top inner highlight
ctx.fillRect(winX + 1, winY + 1, winW - 2, 1);
ctx.fillRect(winX + 1, winY + 1, 1, winH - 2); // Left inner highlight
ctx.fillStyle = '#808080'; // Bottom inner shadow
ctx.fillRect(winX + 1, winY + winH - 2, winW - 2, 1);
ctx.fillRect(winX + winW - 2, winY + 1, 1, winH - 2); // Right inner shadow
// 3. Draw Title Bar
const tx = winX + 3;
const ty = winY + 3;
const tw = winW - 6;
const th = 18;
// Title gradient/solid
ctx.fillStyle = '#000080';
ctx.fillRect(tx, ty, tw, th);
// 4. Draw Small generic picture icon in title bar
const icX = tx + 2;
const icY = ty + 2;
ctx.fillStyle = '#ffffff';
ctx.fillRect(icX, icY, 14, 14);
ctx.lineWidth = 1;
ctx.strokeStyle = '#000000';
ctx.strokeRect(icX + 0.5, icY + 0.5, 13, 13);
// Draw tiny mountain in icon
ctx.beginPath();
ctx.moveTo(icX + 2, icY + 12);
ctx.lineTo(icX + 6, icY + 5);
ctx.lineTo(icX + 10, icY + 12);
ctx.fillStyle = '#808080';
ctx.fill();
// Draw tiny sun in icon
ctx.fillStyle = '#ffff00';
ctx.fillRect(icX + 9, icY + 3, 3, 3);
// 5. Draw Title Text
ctx.fillStyle = '#ffffff';
ctx.font = 'bold 11px "Tahoma", "Arial", sans-serif';
ctx.textBaseline = 'middle';
// Prevent text from overlapping buttons
const maxTextWidth = tw - (16 * 3 + 12) - 20;
ctx.fillText(windowTitle, tx + 20, ty + th / 2 + 1, maxTextWidth);
// 6. Draw Window Buttons (Close, Maximize, Minimize)
function drawWin95Button(bx, by, bw, bh) {
ctx.fillStyle = '#c0c0c0';
ctx.fillRect(bx, by, bw, bh);
ctx.fillStyle = '#ffffff';
ctx.fillRect(bx, by, bw, 1);
ctx.fillRect(bx, by, 1, bh);
ctx.fillStyle = '#000000';
ctx.fillRect(bx, by + bh - 1, bw, 1);
ctx.fillRect(bx + bw - 1, by, 1, bh);
ctx.fillStyle = '#808080';
ctx.fillRect(bx + 1, by + bh - 2, bw - 2, 1);
ctx.fillRect(bx + bw - 2, by + 1, 1, bh - 2);
ctx.fillStyle = '#dfdfdf';
ctx.fillRect(bx + 1, by + 1, bw - 3, 1);
ctx.fillRect(bx + 1, by + 1, 1, bh - 3);
}
const btnW = 16, btnH = 14;
// Close Button
const cbx = tx + tw - btnW - 2;
const cby = ty + 2;
drawWin95Button(cbx, cby, btnW, btnH);
// Draw crisp 'X' mark
ctx.fillStyle = '#000000';
for (let i = 0; i < 6; i++) {
ctx.fillRect(cbx + 5 + i, cby + 4 + i, 1, 1); // Diagonal \
ctx.fillRect(cbx + 6 + i, cby + 4 + i, 1, 1); // Thickening \
ctx.fillRect(cbx + 10 - i, cby + 4 + i, 1, 1); // Diagonal /
ctx.fillRect(cbx + 11 - i, cby + 4 + i, 1, 1); // Thickening /
}
// Maximize Button
const mbx = cbx - btnW;
drawWin95Button(mbx, cby, btnW, btnH);
ctx.fillStyle = '#000000';
ctx.fillRect(mbx + 3, cby + 2, 10, 2); // Thicker top border
ctx.fillRect(mbx + 3, cby + 4, 1, 7); // Left border
ctx.fillRect(mbx + 12, cby + 4, 1, 7); // Right border
ctx.fillRect(mbx + 3, cby + 10, 10, 1); // Bottom border
// Minimize Button
const mibx = mbx - btnW;
drawWin95Button(mibx, cby, btnW, btnH);
ctx.fillStyle = '#000000';
ctx.fillRect(mibx + 4, cby + 10, 8, 2);
// 7. Calculate centered layout for original image inside window
const ix = winX + Math.floor((winW - iw) / 2);
const iy = winY + 24; // Just below the titlebar with margin
// 8. Draw classic 1px sunken inset border around the image
ctx.fillStyle = '#808080';
ctx.fillRect(ix - 1, iy - 1, iw + 2, 1); // Sunken top
ctx.fillRect(ix - 1, iy - 1, 1, ih + 2); // Sunken left
ctx.fillStyle = '#ffffff';
ctx.fillRect(ix - 1, iy + ih, iw + 2, 1); // Raised bottom reflection
ctx.fillRect(ix + iw, iy - 1, 1, ih + 2); // Raised right reflection
// 9. Draw the actual image
ctx.drawImage(originalImg, ix, iy, iw, ih);
return c;
}
Apply Changes