I like this sketchy thing ! i tried to make an “arm” button :
-- Vérification de la compatibilité du preset
assert(
controller.isRequired(MODEL_MK2, "3.6.0"),
"Version 3.6.0 ou supérieure est requise"
)
-- Raccourci pour l'objet graphique
local g = graphics
-- Le contrôle XY personnalisé (pad)
local customControl = controls.get(1)
-- Initialisation du preset
function preset.onLoad()
resizeControl(customControl, 130, 60)
customControl:setPaintCallback(myPaintCallback)
customControl:setValueChangeCallback(onValueChange)
end
-- Fonction pour redimensionner le contrĂ´le
function resizeControl(control, width, height)
local bounds = control:getBounds()
bounds[WIDTH] = width
bounds[HEIGHT] = height
control:setBounds(bounds)
end
-- Fonction de rappel pour la peinture
function myPaintCallback(control)
local bounds = control:getBounds()
local width = bounds[WIDTH]
local height = bounds[HEIGHT]
-- Utiliser la dimension minimale comme référence
local minDimension = math.min(width, height)
-- Calcul des marges et dimensions proportionnelles, arrondies Ă l'entier le plus proche
local margin = math.floor(0.1 * minDimension)
local innerMargin = math.floor(0.05 * minDimension)
local outerWidth = math.floor(width - 2 * margin)
local outerHeight = math.floor(height - 2 * margin)
local innerWidth = math.floor(outerWidth - 2 * innerMargin)
local innerHeight = math.floor(outerHeight - 2 * innerMargin)
local rectWidth = math.floor(innerWidth * 0.8)
local rectHeight = math.floor(innerHeight * 0.8)
local circleRadius = math.floor(math.min(rectWidth, rectHeight) * 0.4)
-- Centrer les éléments
local outerX = math.floor((width - outerWidth) / 2)
local outerY = math.floor((height - outerHeight) / 2)
local innerX = math.floor(outerX + innerMargin)
local innerY = math.floor(outerY + innerMargin)
local rectX = math.floor(innerX + (innerWidth - rectWidth) / 2)
local rectY = math.floor(innerY + (innerHeight - rectHeight) / 2)
local circleX = math.floor(rectX + rectWidth / 2)
local circleY = math.floor(rectY + rectHeight / 2)
-- Effacer la zone de dessin
g.setColor(0x1E1E1E) -- Fond sombre
g.fillRect(0, 0, width, height)
-- Dessiner le cadre extérieur (gris clair)
g.setColor(0xCCCCCC)
g.fillRect(outerX, outerY, outerWidth, outerHeight)
-- Dessiner la bordure intérieure (gris clair)
g.setColor(0xCCCCCC)
g.fillRect(innerX, innerY, innerWidth, innerHeight)
-- Dessiner le rectangle, couleur en fonction de l'état du pad
if customControl:getValue() == 127 then
g.setColor(0xFF0000) -- Rouge pour ON
else
g.setColor(0x0000FF) -- Bleu pour OFF
end
g.fillRect(rectX, rectY, rectWidth, rectHeight)
-- Dessiner le cercle noir centré dans le rectangle
g.setColor(0x000000)
g.fillCircle(circleX, circleY, circleRadius)
end
-- Fonction appelée lorsque la valeur du pad change
function onValueChange(valueObject, value)
customControl:repaint()
end
With chat GPT , i manage to make it resize of the drawing depending of le size of the customContro . resizeControl(customControl, x, y)
Now i wanted that i could push the drawing and then the color of the “arm” button change to red . I asked chat gpt and he gave me this code but it does not work :
if customControl:getValue() == 127 then
g.setColor(0xFF0000) -- Rouge pour ON
else
g.setColor(0x0000FF) -- Bleu pour OFF
end
g.fillRect(rectX, rectY, rectWidth, rectHeight
it uses “getValue()” … not shure it work .
Is it possible yet to do such a thing ?
Also it’s really cool to be able to draw things ! 
Thanks for all those improvment !
