Depuis 6 heures, je planche sur un lecteur d'image fonctionnant sous Lua et permettant donc de l'insérer des des classeurs. Je suis arrivé à faire bouger l'image avec les flèches sans trop de problèmes et maintenant ça roule . Puis je suis arrivé à faire un zoom sur le même principe. Maintenant, j'aimerais associer les deux afin de pouvoir déplacer l'image avec les flèches puis de faire un zoom + avec la touche * et un zoom - avec la touche /.
Voici mon code pour déplacer l'image:
- Code: Tout sélectionner
bridge1 = image.new("code de l'image")
function on.paint(gc)
gc:drawImage(bridge1,0,0)
end
local screen = platform.window
local sc = 0.5
local sd = 0.5
function on.paint(gc)
local w = screen:width()
local h = screen:height()
local imw = bridge1:width()
local imh = bridge1:height()
local im = bridge1:copy(sd * imw, sc * imh)
local imw = im:width(im)
local imh = im:height(im)
gc:drawImage(Bridge1,w - imw ,h - imh)
end
platform.window:invalidate()
local screen = platform.window
function on.construction()
timer.start(1/5)
end
function on.timer()
screen:invalidate()
end
function on.arrowUp()
sc = sc - 0.1
screen:invalidate()
end
function on.arrowDown()
sc = sc + 0.1
screen:invalidate()
end
local screen = platform.window
function on.construction()
timer.start(1/5)
end
function on.timer()
screen:invalidate()
end
function on.arrowRight()
sd = sd + 0.1
screen:invalidate()
print(sd)
end
function on.arrowLeft()
sd = sd - 0.1
screen:invalidate()
print(sd)
end
... Et voici le code pour zoomer ou dézoomer:
- Code: Tout sélectionner
bridge1 = image.new("code de l'image")
function on.paint(gc)
gc:drawImage(bridge1,0,0)
end
local screen = platform.window
local sd = 0.5
function on.paint(gc)
local w = screen:width()
local h = screen:height()
local imw = bridge1:width()
local imh = bridge1:height()
local im = bridge1:copy(sd * imw, sd * imh)
local imw = im:width(im)
local imh = im:height(im)
gc:drawImage(Bridge1,w - imw ,h- imh)
end
platform.window:invalidate()
local screen = platform.window
function on.construction()
timer.start(1/5)
end
function on.timer()
screen:invalidate()
end
function on.arrowUp()
sd = sd - 0.1
screen:invalidate()
end
function on.arrowDown()
sc = sc + 0.1
screen:invalidate()
end
local screen = platform.window
function on.construction()
timer.start(1/5)
end
function on.timer()
screen:invalidate()
end
function on.arrowRight()
sd = sd + 0.1
screen:invalidate()
print(sd)
end
function on.arrowLeft()
sd = sd - 0.1
screen:invalidate()
print(sd)
end
...Et c'est là que je sèche: Comment faire pour associer les deux ???
Étant donné que le bac arrive à grand pas, et que l'OS 3,2 est très intéressant pour la géométrie dans l'espace, votre aide est m'arrangerait beaucoup ainsi que beaucoup de terminales S je pense...