diff --git a/actions/canvas_create_primitive_MOD.js b/actions/canvas_create_primitive_MOD.js new file mode 100644 index 00000000..01db6a59 --- /dev/null +++ b/actions/canvas_create_primitive_MOD.js @@ -0,0 +1,101 @@ +module.exports = { + name: 'Canvas Create Shape', + section: 'Image Editing', + meta: { + version: '1.0.0', + author: 'Your Name', + authorUrl: 'https://yourwebsite.com', + downloadURL: 'https://github.com/yourrepository/your-script.js', + }, + + subtitle(data) { + const info = parseInt(data.info, 10); + if (info === 0) { + return data.color ? `Create Circle with Color ${data.color}` : 'No color circle has been created'; + } + if (info === 1) { + return data.color ? `Create Rectangle with Color ${data.color}` : 'No color rectangle has been created'; + } + // Add more cases for different shapes as needed + }, + + variableStorage(data, varType) { + if (parseInt(data.storage, 10) !== varType) return; + return [data.varName, 'Image']; + }, + + fields: ['shapeType', 'width', 'height', 'color', 'storage', 'varName'], + + html() { + return ` +
+
+ Shape Type + +
+
+

+ +
+
+ Width (px) +
+
+
+ Height (px) +
+
+
+

+ +
+
+ Color +
+
+
+

+ + +`; + }, + + async action(cache) { + const data = cache.actions[cache.index]; + const Canvas = require('canvas'); + const shapeType = parseInt(data.shapeType, 10); + const width = parseInt(this.evalMessage(data.width, cache), 10); + const height = parseInt(this.evalMessage(data.height, cache), 10); + const canvas = Canvas.createCanvas(width, height); + const ctx = canvas.getContext('2d'); + const color = this.evalMessage(data.color, cache); + + switch (shapeType) { + case 0: // Circle + ctx.beginPath(); + ctx.arc(width / 2, height / 2, Math.min(width, height) / 2, 0, 2 * Math.PI); + ctx.fillStyle = color; + ctx.fill(); + break; + case 1: // Rectangle + ctx.fillStyle = color; + ctx.fillRect(0, 0, width, height); + break; + // Add more cases for different shapes + default: + break; + } + + const result = canvas.toDataURL('image/png').replace('image/png', 'image/octet-stream'); + const varName = this.evalMessage(data.varName, cache); + const storage = parseInt(data.storage, 10); + this.storeValue(result, storage, varName, cache); + this.callNextAction(cache); + }, + + mod() {}, +}; diff --git a/actions/seperator_MOD.js b/actions/seperator_MOD.js new file mode 100644 index 00000000..8ab631a7 --- /dev/null +++ b/actions/seperator_MOD.js @@ -0,0 +1,112 @@ +module.exports = { + name: 'Separator', + section: 'Other', + fields: ['separator', 'color', 'bold', 'underline', 'fontSize'], + + meta: { + version: '2.1.7', + author: 'DBM Mods', + authorUrl: 'https://github.com/dbm-network/mods', + downloadURL: 'https://github.com/dbm-network/mods/blob/master/actions/file_control_separator.js', + }, + + subtitle(data) { + let style = ''; + if (data.bold === 'true') style += 'font-weight: bold;'; + if (data.underline === 'true') style += 'text-decoration: underline;'; + if (data.fontSize) style += `font-size: ${parseInt(data.fontSize, 10)}px;`; + const separator = data.separator || 'No separator provided'; + const color = data.color || '#000000'; + return `${separator}`; + }, + + html() { + return ` +
+
+ Separator +
+ Color:
+

+ Bold:
+
+ Underline:
+
+ Font Size (px):
+

+
+
`; + }, + + init() { + const { document } = this; + const separatorField = document.getElementById('separator'); + const colorField = document.getElementById('color'); + const boldField = document.getElementById('bold'); + const underlineField = document.getElementById('underline'); + const fontSizeField = document.getElementById('fontSize'); + + function updateSubtitle() { + const separatorValue = separatorField.value.trim(); + const colorValue = colorField.value; + const boldValue = boldField.value === 'true'; + const underlineValue = underlineField.value === 'true'; + const fontSizeValue = fontSizeField.value; + const subtitle = document.querySelector('.subtitle'); + let style = ''; + if (boldValue) style += 'font-weight: bold;'; + if (underlineValue) style += 'text-decoration: underline;'; + if (fontSizeValue) style += `font-size: ${parseInt(fontSizeValue, 10)}px;`; + subtitle.innerHTML = `${ + separatorValue || 'No separator provided' + }`; + } + + separatorField.addEventListener('input', updateSubtitle); + colorField.addEventListener('input', updateSubtitle); + boldField.addEventListener('change', updateSubtitle); + underlineField.addEventListener('change', updateSubtitle); + fontSizeField.addEventListener('input', updateSubtitle); + + // Trigger subtitle update on initialization + updateSubtitle(); + }, + + async action(cache) { + const data = cache.actions[cache.index]; + const separator = this.evalMessage(data.separator, cache); + const color = this.evalMessage(data.color, cache); + const bold = data.bold === 'true'; + const underline = data.underline === 'true'; + + // Store separator value if provided + if (separator !== undefined) { + cache.separator = separator; + } + + // Store color value if provided + if (color !== undefined) { + cache.color = color; + } + + // Store bold value if provided + if (bold !== undefined) { + cache.bold = bold; + } + + // Store underline value if provided + if (underline !== undefined) { + cache.underline = underline; + } + + this.callNextAction(cache); + }, + + mod() {}, +};