I need to write the second layout on top of the first one, can you simplify and do that?…
- User
I need to write the second layout on top of the first one, can you simplify and do that? function touchKeyboard:draw() -- Draw the background rectangle love.graphics.setColor(0.1, 0.1, 0.1) love.graphics.rectangle("fill", 0+keyoffsetX, -5+keyoffsetY, 2405, 640) love.gradient.draw( function() love.graphics.rectangle("fill", 0+keyoffsetX, -5+keyoffsetY, 2405, 640) end, "linear", --gradientType, 1010, --centerX, 200, -- centerY, -width*2, -- radialWidth, 1080, -- radialHeight, color1, -- color1, color2) -- color2[, angle, scaleX, scaleY])
local layout = selectKeyboardLayout() -- Select the appropriate keyboard layout -- Draw the keys first for i, row in ipairs(layout) do local rowOffset = (i - 1) * 0.5 * (keyWidth + keyPadding) -- Offset for row displacement for j, key in ipairs(row) do --local keyX = rowOffset + (j - 1) * (keyWidth + keyPadding) local keyX = (j - 1) * (keyWidth + keyPadding) if i == 3 then keyX = keyX + rowOffset*0.6 elseif i == 4 then keyX = keyX + rowOffset*0.4 elseif i == 5 then keyX = keyX + rowOffset*0.6 end --[[ if i == 2 then keyX = keyX - rowOffset*1 else elseif i == 4 then keyX = keyX - rowOffset*0.7 end --]] local keyY = (i - 1) * (keyHeight + keyPadding) local keyOffsetX = 0 local keyWidthMultiplier = 1 -- Adjust offsets and multipliers based on key type if key == "?123" then keyOffsetX = -keyWidth * 1.5 keyWidthMultiplier = 1.85 elseif key == "," then keyOffsetX = -keyWidth * 0.58 keyWidthMultiplier = 1 elseif key == "linux" or key == "alt" then keyOffsetX = -keyWidth * 1 keyWidthMultiplier = 1.0 elseif key == "alt gr" or key == "fn" or key == "fn2" then keyOffsetX = keyWidth * 5 keyWidthMultiplier = 1.0 elseif key == "strg2" then keyOffsetX = keyWidth * 5 keyWidthMultiplier = 1.55 elseif key == "Space" then keyOffsetX = keyWidth * -0.57 keyWidthMultiplier = 4.47 elseif key == "." then keyOffsetX = keyWidth * 3.1 keyWidthMultiplier = 1 elseif key == "Up" or key == "Up2" then keyOffsetX = -keyWidth * 0 keyWidthMultiplier = 1.0 elseif key == "Up3" then keyWidthMultiplier = 1.9 elseif key == "Tab" then keyOffsetX = -keyWidth * 0.5 keyWidthMultiplier = 1.5 elseif key == "ret" then keyOffsetX = keyWidth * 3.1 keyWidthMultiplier = 1.9 elseif key == "ret2" then keyWidthMultiplier = 1.4 elseif key == "del" then keyOffsetX = 1 keyWidthMultiplier = 1.4 end -- Calculate the current key width local currentKeyWidth = keyWidth * keyWidthMultiplier + keyPadding * (keyWidthMultiplier - 1) -- Set color and transparency based on key selection local isSelected = self.selectedKey == key if isSelected then self.keyTransparency[key] = self.keyTransparency[key] or 1 love.graphics.setColor(0.2, 0.2, 0.8, self.keyTransparency[key]) elseif self.keyTransparency[key] and self.keyTransparency[key] >= 0.1 then love.graphics.setColor(0.2, 0.2, 0.8, self.keyTransparency[key]) else if key == "ret" then love.graphics.setColor(0, 0, 1, 1) elseif key == "?123" or key == "Up" or key == "Up2" or key == "del" then love.graphics.setColor(0.3, 0.3, 0.3, 1) else love.graphics.setColor(0.5, 0.5, 0.5, 1) end end -- Draw the key --love.graphics.roundrect("fill", keyX + keyOffsetX, keyY + keyoffsetY, currentKeyWidth, keyHeight, 20, 20) -- Draw the key label love.graphics.setColor(1, 1, 1) love.graphics.print(key, keyX + keyOffsetX + currentKeyWidth / 2 - 15, keyY + keyoffsetY + keyHeight / 2 - 10,0,2) end end -- Draw the zoomed-in pressed key if any key is selected if keypressed==true then ZoomedKeyDraw(self.selectedKey) end - Assistant
- User
- Assistant
- User
now add a conditional where the keys are printed so that I can change colors on the second layout
- Assistant
- User
- Assistant