User prompt
Añade música de fondeo
User prompt
Elimina las opciones de sabe newby gallery
User prompt
Haz que al pinchar en sabe el cuadro se guarde en la gallery ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Haz el botón de clisé en la galería sea mucho más grande
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage.paintings.push(paintingData);' Line Number: 295 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage.paintings.push(paintingData);' Line Number: 295 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Baja los botones de grosor y haz el cuadro más grande
User prompt
Elimina la opción de los colores y haz que el grosor y las opciones ocupen en el espacio restante
User prompt
Cambia los colores que hay por rosa negro morado rojo verde azul amarillo negro blanco marrón
User prompt
Pon el botón de gallery como el de los demas
User prompt
Separa los botones de opciones
User prompt
Separa el botón de opciones en botones individuales
Code edit (1 edits merged)
Please save this source code
User prompt
Pon los botones de opciones en el centro de abaja
User prompt
Pon los botones de color más arruba
User prompt
Haz que los colores estén más en el centro que no se repitan los colores y que añadas más colores
User prompt
Pon los botones the grisor debajo del marco
User prompt
Pon los botones de grosor en el centro
User prompt
Haz los botones de paleta más separados entre si
User prompt
Haz los controles separados y más grandes al igual que la paleta
User prompt
Haz los botones mucho más grandes
User prompt
Haz que los botones estén abajo
User prompt
Haz que al detectar tacto se pinte pero en vez de puntos líneas y aumenta el tamaño de los controles
Code edit (1 edits merged)
Please save this source code
User prompt
Paint Studio - Creative Canvas
/****
* Plugins
****/
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var BrushButton = Container.expand(function (size, asset) {
var self = Container.call(this);
var button = self.attachAsset(asset, {
anchorX: 0.5,
anchorY: 0.5
});
self.size = size;
self.down = function () {
currentBrushSize = self.size;
updateBrushPreview();
};
return self;
});
var ColorButton = Container.expand(function (color) {
var self = Container.call(this);
var button = self.attachAsset('colorButton', {
anchorX: 0.5,
anchorY: 0.5
});
button.tint = color;
self.color = color;
self.down = function () {
currentColor = self.color;
updateBrushPreview();
};
return self;
});
var GalleryButton = Container.expand(function () {
var self = Container.call(this);
var button = self.attachAsset('galleryButton', {
anchorX: 0.5,
anchorY: 0.5
});
var text = new Text2('Gallery', {
size: 28,
fill: 0xFFFFFF
});
text.anchor.set(0.5, 0.5);
self.addChild(text);
self.down = function () {
showGallery();
};
return self;
});
var PaintDot = Container.expand(function (color, size) {
var self = Container.call(this);
var dot = self.attachAsset('paintDot', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: size / 20,
scaleY: size / 20
});
dot.tint = color;
return self;
});
var PaintingThumbnail = Container.expand(function (paintingData, index) {
var self = Container.call(this);
var thumbnail = self.attachAsset('canvas', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
self.paintingData = paintingData;
self.index = index;
// Recreate dots on thumbnail
if (paintingData && paintingData.dots) {
for (var i = 0; i < paintingData.dots.length; i++) {
var dotData = paintingData.dots[i];
var dot = new PaintDot(dotData.color, dotData.size);
dot.x = dotData.x * 0.3;
dot.y = dotData.y * 0.3;
self.addChild(dot);
}
}
self.down = function () {
loadPainting(self.paintingData);
hideGallery();
};
return self;
});
var ToolButton = Container.expand(function (label, action) {
var self = Container.call(this);
var button = self.attachAsset('toolButton', {
anchorX: 0.5,
anchorY: 0.5
});
var text = new Text2(label, {
size: 24,
fill: 0xFFFFFF
});
text.anchor.set(0.5, 0.5);
self.addChild(text);
self.action = action;
self.down = function () {
self.action();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xf0f0f0
});
/****
* Game Code
****/
// Initialize storage
if (!storage.paintings) {
storage.paintings = [];
}
// Game state
var isPainting = false;
var currentColor = 0x000000;
var currentBrushSize = 20;
var paintingMode = true;
var isErasing = false;
var currentPaintingDots = [];
var showingGallery = false;
// Canvas setup
var canvas = game.addChild(LK.getAsset('canvas', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1000
}));
// Color palette
var colors = [0x000000, 0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff, 0x00ffff, 0xffa500, 0x800080, 0x008000, 0x808080, 0xffffff];
var colorPalette = [];
for (var i = 0; i < colors.length; i++) {
var colorBtn = new ColorButton(colors[i]);
colorBtn.x = 150 + i % 6 * 80;
colorBtn.y = 100 + Math.floor(i / 6) * 80;
game.addChild(colorBtn);
colorPalette.push(colorBtn);
}
// Brush size buttons
var brushSizes = [{
size: 15,
asset: 'brushSmall'
}, {
size: 30,
asset: 'brushMedium'
}, {
size: 45,
asset: 'brushLarge'
}];
var brushButtons = [];
for (var i = 0; i < brushSizes.length; i++) {
var brushBtn = new BrushButton(brushSizes[i].size, brushSizes[i].asset);
brushBtn.x = 1500 + i * 120;
brushBtn.y = 150;
game.addChild(brushBtn);
brushButtons.push(brushBtn);
}
// Tool buttons
var clearBtn = new ToolButton('Clear', function () {
clearCanvas();
});
clearBtn.x = 1500;
clearBtn.y = 300;
game.addChild(clearBtn);
var eraseBtn = new ToolButton('Erase', function () {
toggleEraser();
});
eraseBtn.x = 1650;
eraseBtn.y = 300;
game.addChild(eraseBtn);
var saveBtn = new ToolButton('Save', function () {
savePainting();
});
saveBtn.x = 1500;
saveBtn.y = 400;
game.addChild(saveBtn);
var newBtn = new ToolButton('New', function () {
newPainting();
});
newBtn.x = 1650;
newBtn.y = 400;
game.addChild(newBtn);
// Gallery button
var galleryBtn = new GalleryButton();
galleryBtn.x = 1575;
galleryBtn.y = 520;
game.addChild(galleryBtn);
// Brush preview
var brushPreview = game.addChild(LK.getAsset('brushSmall', {
anchorX: 0.5,
anchorY: 0.5,
x: 1575,
y: 650
}));
// Gallery container
var galleryContainer = new Container();
game.addChild(galleryContainer);
galleryContainer.visible = false;
// Gallery background
var galleryBg = galleryContainer.addChild(LK.getAsset('canvas', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
scaleX: 1.2,
scaleY: 2.0
}));
galleryBg.tint = 0x222222;
// Gallery title
var galleryTitle = new Text2('Gallery', {
size: 48,
fill: 0xFFFFFF
});
galleryTitle.anchor.set(0.5, 0.5);
galleryTitle.x = 1024;
galleryTitle.y = 200;
galleryContainer.addChild(galleryTitle);
// Gallery close button
var closeGalleryBtn = new ToolButton('Close', function () {
hideGallery();
});
closeGalleryBtn.x = 1024;
closeGalleryBtn.y = 2500;
galleryContainer.addChild(closeGalleryBtn);
// Gallery thumbnails container
var thumbnailsContainer = new Container();
galleryContainer.addChild(thumbnailsContainer);
function updateBrushPreview() {
brushPreview.tint = isErasing ? 0xff0000 : currentColor;
brushPreview.scaleX = currentBrushSize / 20;
brushPreview.scaleY = currentBrushSize / 20;
}
function clearCanvas() {
// Remove all paint dots from canvas
for (var i = canvas.children.length - 1; i >= 0; i--) {
var child = canvas.children[i];
if (child instanceof PaintDot) {
canvas.removeChild(child);
}
}
currentPaintingDots = [];
}
function toggleEraser() {
isErasing = !isErasing;
updateBrushPreview();
}
function savePainting() {
if (currentPaintingDots.length === 0) return;
var paintingData = {
dots: currentPaintingDots.slice(),
timestamp: Date.now()
};
storage.paintings.push(paintingData);
updateGalleryThumbnails();
}
function newPainting() {
clearCanvas();
currentPaintingDots = [];
}
function showGallery() {
galleryContainer.visible = true;
showingGallery = true;
updateGalleryThumbnails();
}
function hideGallery() {
galleryContainer.visible = false;
showingGallery = false;
}
function updateGalleryThumbnails() {
// Clear existing thumbnails
for (var i = thumbnailsContainer.children.length - 1; i >= 0; i--) {
thumbnailsContainer.removeChild(thumbnailsContainer.children[i]);
}
// Create new thumbnails
var paintings = storage.paintings || [];
for (var i = 0; i < paintings.length; i++) {
var thumbnail = new PaintingThumbnail(paintings[i], i);
thumbnail.x = 300 + i % 3 * 400;
thumbnail.y = 400 + Math.floor(i / 3) * 350;
thumbnailsContainer.addChild(thumbnail);
}
}
function loadPainting(paintingData) {
clearCanvas();
currentPaintingDots = [];
if (paintingData && paintingData.dots) {
for (var i = 0; i < paintingData.dots.length; i++) {
var dotData = paintingData.dots[i];
var dot = new PaintDot(dotData.color, dotData.size);
dot.x = dotData.x;
dot.y = dotData.y;
canvas.addChild(dot);
currentPaintingDots.push({
x: dotData.x,
y: dotData.y,
color: dotData.color,
size: dotData.size
});
}
}
}
function paintAt(x, y) {
if (showingGallery) return;
var localPos = canvas.toLocal({
x: x,
y: y
});
// Check if within canvas bounds
if (localPos.x < -900 || localPos.x > 900 || localPos.y < -700 || localPos.y > 700) {
return;
}
if (isErasing) {
// Remove dots near the eraser position
for (var i = canvas.children.length - 1; i >= 0; i--) {
var child = canvas.children[i];
if (child instanceof PaintDot) {
var dx = child.x - localPos.x;
var dy = child.y - localPos.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < currentBrushSize) {
canvas.removeChild(child);
// Remove from currentPaintingDots array
for (var j = currentPaintingDots.length - 1; j >= 0; j--) {
var dot = currentPaintingDots[j];
if (Math.abs(dot.x - localPos.x) < 5 && Math.abs(dot.y - localPos.y) < 5) {
currentPaintingDots.splice(j, 1);
break;
}
}
}
}
}
} else {
// Add paint dot
var dot = new PaintDot(currentColor, currentBrushSize);
dot.x = localPos.x;
dot.y = localPos.y;
canvas.addChild(dot);
currentPaintingDots.push({
x: localPos.x,
y: localPos.y,
color: currentColor,
size: currentBrushSize
});
}
}
// Initialize brush preview
updateBrushPreview();
game.down = function (x, y, obj) {
if (showingGallery) return;
isPainting = true;
paintAt(x, y);
};
game.up = function (x, y, obj) {
isPainting = false;
};
game.move = function (x, y, obj) {
if (isPainting) {
paintAt(x, y);
}
};
game.update = function () {
// Game loop - nothing specific needed for painting
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,373 @@
-/****
+/****
+* Plugins
+****/
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var BrushButton = Container.expand(function (size, asset) {
+ var self = Container.call(this);
+ var button = self.attachAsset(asset, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.size = size;
+ self.down = function () {
+ currentBrushSize = self.size;
+ updateBrushPreview();
+ };
+ return self;
+});
+var ColorButton = Container.expand(function (color) {
+ var self = Container.call(this);
+ var button = self.attachAsset('colorButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ button.tint = color;
+ self.color = color;
+ self.down = function () {
+ currentColor = self.color;
+ updateBrushPreview();
+ };
+ return self;
+});
+var GalleryButton = Container.expand(function () {
+ var self = Container.call(this);
+ var button = self.attachAsset('galleryButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var text = new Text2('Gallery', {
+ size: 28,
+ fill: 0xFFFFFF
+ });
+ text.anchor.set(0.5, 0.5);
+ self.addChild(text);
+ self.down = function () {
+ showGallery();
+ };
+ return self;
+});
+var PaintDot = Container.expand(function (color, size) {
+ var self = Container.call(this);
+ var dot = self.attachAsset('paintDot', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: size / 20,
+ scaleY: size / 20
+ });
+ dot.tint = color;
+ return self;
+});
+var PaintingThumbnail = Container.expand(function (paintingData, index) {
+ var self = Container.call(this);
+ var thumbnail = self.attachAsset('canvas', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.3,
+ scaleY: 0.3
+ });
+ self.paintingData = paintingData;
+ self.index = index;
+ // Recreate dots on thumbnail
+ if (paintingData && paintingData.dots) {
+ for (var i = 0; i < paintingData.dots.length; i++) {
+ var dotData = paintingData.dots[i];
+ var dot = new PaintDot(dotData.color, dotData.size);
+ dot.x = dotData.x * 0.3;
+ dot.y = dotData.y * 0.3;
+ self.addChild(dot);
+ }
+ }
+ self.down = function () {
+ loadPainting(self.paintingData);
+ hideGallery();
+ };
+ return self;
+});
+var ToolButton = Container.expand(function (label, action) {
+ var self = Container.call(this);
+ var button = self.attachAsset('toolButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var text = new Text2(label, {
+ size: 24,
+ fill: 0xFFFFFF
+ });
+ text.anchor.set(0.5, 0.5);
+ self.addChild(text);
+ self.action = action;
+ self.down = function () {
+ self.action();
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0xf0f0f0
+});
+
+/****
+* Game Code
+****/
+// Initialize storage
+if (!storage.paintings) {
+ storage.paintings = [];
+}
+// Game state
+var isPainting = false;
+var currentColor = 0x000000;
+var currentBrushSize = 20;
+var paintingMode = true;
+var isErasing = false;
+var currentPaintingDots = [];
+var showingGallery = false;
+// Canvas setup
+var canvas = game.addChild(LK.getAsset('canvas', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1000
+}));
+// Color palette
+var colors = [0x000000, 0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff, 0x00ffff, 0xffa500, 0x800080, 0x008000, 0x808080, 0xffffff];
+var colorPalette = [];
+for (var i = 0; i < colors.length; i++) {
+ var colorBtn = new ColorButton(colors[i]);
+ colorBtn.x = 150 + i % 6 * 80;
+ colorBtn.y = 100 + Math.floor(i / 6) * 80;
+ game.addChild(colorBtn);
+ colorPalette.push(colorBtn);
+}
+// Brush size buttons
+var brushSizes = [{
+ size: 15,
+ asset: 'brushSmall'
+}, {
+ size: 30,
+ asset: 'brushMedium'
+}, {
+ size: 45,
+ asset: 'brushLarge'
+}];
+var brushButtons = [];
+for (var i = 0; i < brushSizes.length; i++) {
+ var brushBtn = new BrushButton(brushSizes[i].size, brushSizes[i].asset);
+ brushBtn.x = 1500 + i * 120;
+ brushBtn.y = 150;
+ game.addChild(brushBtn);
+ brushButtons.push(brushBtn);
+}
+// Tool buttons
+var clearBtn = new ToolButton('Clear', function () {
+ clearCanvas();
+});
+clearBtn.x = 1500;
+clearBtn.y = 300;
+game.addChild(clearBtn);
+var eraseBtn = new ToolButton('Erase', function () {
+ toggleEraser();
+});
+eraseBtn.x = 1650;
+eraseBtn.y = 300;
+game.addChild(eraseBtn);
+var saveBtn = new ToolButton('Save', function () {
+ savePainting();
+});
+saveBtn.x = 1500;
+saveBtn.y = 400;
+game.addChild(saveBtn);
+var newBtn = new ToolButton('New', function () {
+ newPainting();
+});
+newBtn.x = 1650;
+newBtn.y = 400;
+game.addChild(newBtn);
+// Gallery button
+var galleryBtn = new GalleryButton();
+galleryBtn.x = 1575;
+galleryBtn.y = 520;
+game.addChild(galleryBtn);
+// Brush preview
+var brushPreview = game.addChild(LK.getAsset('brushSmall', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1575,
+ y: 650
+}));
+// Gallery container
+var galleryContainer = new Container();
+game.addChild(galleryContainer);
+galleryContainer.visible = false;
+// Gallery background
+var galleryBg = galleryContainer.addChild(LK.getAsset('canvas', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1366,
+ scaleX: 1.2,
+ scaleY: 2.0
+}));
+galleryBg.tint = 0x222222;
+// Gallery title
+var galleryTitle = new Text2('Gallery', {
+ size: 48,
+ fill: 0xFFFFFF
+});
+galleryTitle.anchor.set(0.5, 0.5);
+galleryTitle.x = 1024;
+galleryTitle.y = 200;
+galleryContainer.addChild(galleryTitle);
+// Gallery close button
+var closeGalleryBtn = new ToolButton('Close', function () {
+ hideGallery();
+});
+closeGalleryBtn.x = 1024;
+closeGalleryBtn.y = 2500;
+galleryContainer.addChild(closeGalleryBtn);
+// Gallery thumbnails container
+var thumbnailsContainer = new Container();
+galleryContainer.addChild(thumbnailsContainer);
+function updateBrushPreview() {
+ brushPreview.tint = isErasing ? 0xff0000 : currentColor;
+ brushPreview.scaleX = currentBrushSize / 20;
+ brushPreview.scaleY = currentBrushSize / 20;
+}
+function clearCanvas() {
+ // Remove all paint dots from canvas
+ for (var i = canvas.children.length - 1; i >= 0; i--) {
+ var child = canvas.children[i];
+ if (child instanceof PaintDot) {
+ canvas.removeChild(child);
+ }
+ }
+ currentPaintingDots = [];
+}
+function toggleEraser() {
+ isErasing = !isErasing;
+ updateBrushPreview();
+}
+function savePainting() {
+ if (currentPaintingDots.length === 0) return;
+ var paintingData = {
+ dots: currentPaintingDots.slice(),
+ timestamp: Date.now()
+ };
+ storage.paintings.push(paintingData);
+ updateGalleryThumbnails();
+}
+function newPainting() {
+ clearCanvas();
+ currentPaintingDots = [];
+}
+function showGallery() {
+ galleryContainer.visible = true;
+ showingGallery = true;
+ updateGalleryThumbnails();
+}
+function hideGallery() {
+ galleryContainer.visible = false;
+ showingGallery = false;
+}
+function updateGalleryThumbnails() {
+ // Clear existing thumbnails
+ for (var i = thumbnailsContainer.children.length - 1; i >= 0; i--) {
+ thumbnailsContainer.removeChild(thumbnailsContainer.children[i]);
+ }
+ // Create new thumbnails
+ var paintings = storage.paintings || [];
+ for (var i = 0; i < paintings.length; i++) {
+ var thumbnail = new PaintingThumbnail(paintings[i], i);
+ thumbnail.x = 300 + i % 3 * 400;
+ thumbnail.y = 400 + Math.floor(i / 3) * 350;
+ thumbnailsContainer.addChild(thumbnail);
+ }
+}
+function loadPainting(paintingData) {
+ clearCanvas();
+ currentPaintingDots = [];
+ if (paintingData && paintingData.dots) {
+ for (var i = 0; i < paintingData.dots.length; i++) {
+ var dotData = paintingData.dots[i];
+ var dot = new PaintDot(dotData.color, dotData.size);
+ dot.x = dotData.x;
+ dot.y = dotData.y;
+ canvas.addChild(dot);
+ currentPaintingDots.push({
+ x: dotData.x,
+ y: dotData.y,
+ color: dotData.color,
+ size: dotData.size
+ });
+ }
+ }
+}
+function paintAt(x, y) {
+ if (showingGallery) return;
+ var localPos = canvas.toLocal({
+ x: x,
+ y: y
+ });
+ // Check if within canvas bounds
+ if (localPos.x < -900 || localPos.x > 900 || localPos.y < -700 || localPos.y > 700) {
+ return;
+ }
+ if (isErasing) {
+ // Remove dots near the eraser position
+ for (var i = canvas.children.length - 1; i >= 0; i--) {
+ var child = canvas.children[i];
+ if (child instanceof PaintDot) {
+ var dx = child.x - localPos.x;
+ var dy = child.y - localPos.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < currentBrushSize) {
+ canvas.removeChild(child);
+ // Remove from currentPaintingDots array
+ for (var j = currentPaintingDots.length - 1; j >= 0; j--) {
+ var dot = currentPaintingDots[j];
+ if (Math.abs(dot.x - localPos.x) < 5 && Math.abs(dot.y - localPos.y) < 5) {
+ currentPaintingDots.splice(j, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+ } else {
+ // Add paint dot
+ var dot = new PaintDot(currentColor, currentBrushSize);
+ dot.x = localPos.x;
+ dot.y = localPos.y;
+ canvas.addChild(dot);
+ currentPaintingDots.push({
+ x: localPos.x,
+ y: localPos.y,
+ color: currentColor,
+ size: currentBrushSize
+ });
+ }
+}
+// Initialize brush preview
+updateBrushPreview();
+game.down = function (x, y, obj) {
+ if (showingGallery) return;
+ isPainting = true;
+ paintAt(x, y);
+};
+game.up = function (x, y, obj) {
+ isPainting = false;
+};
+game.move = function (x, y, obj) {
+ if (isPainting) {
+ paintAt(x, y);
+ }
+};
+game.update = function () {
+ // Game loop - nothing specific needed for painting
+};
\ No newline at end of file