问题描述
此刻,我对编程有些好奇.而且我想在我的iOS上编写我的Autotouch App脚本,以在另一个应用程序内生成Pixel Art.
I'm having a little curious sense of art in programming at the moment. And I want to script my Autotouch App on my iOS to generate Pixel Art inside of another app.
我以前是通过输入代码在一个坐标处点击屏幕来完成此操作的,我这样做了2000多次,然后它完成了工作.但是应该有一种更好,更聪明的方法来完成它.
I was doing this previously by typing in code to tap at the screen at one coordinate, I did this 2000+ times and it got the job done. But there should be a better, smarter way to get it done.
为了使事情变得容易,我的测试图像将非常对称.我正在使用Lua应用程序中的代码来简单地点击屏幕,
My test image is going to be very symetrical to make things easy.There is a code in the Lua app that I'm using to simply tap on the screen,
tap(x, y)
但是我想将其设置为:
tap({xTable}, y)
但是我不确定是否会在为y变量列出的每个x坐标上点击".
But I'm not sure if that will "tap" at each x coordinate that I've listed for the y variable.
我想在一个非常特定的坐标处绘制一个像素,然后将5个像素移开并绘制下一个像素,并重复该操作直到行的结尾.
I want to paint a pixel at one very specific coordinate, and then step 5 pixels away and paint the next one, and repeat that until the end of the line.
这是全部可能吗,还是我超出了语言能力范围?
Is this at all possible or am I reaching beyond the language capabilities?
出于某种原因,当我问一个问题时,我的手机没有阻止代码,如果有人看到了这个并想编辑,我将不胜感激.
for some reason my phone is not blocking code when I'm asking a question, if someone sees this and wants to edit, I would be grateful.
推荐答案
甚至没有关闭.我建议您阅读在Lua中编程.
Not even close. I recommend you read Programming in Lua.
tap({xTable}, y)
但是我不确定是否会在为y变量列出的每个x坐标上点击".
But I'm not sure if that will "tap" at each x coordinate that I've listed for the y variable.
为什么不确定?你没写吗?如果没有,您可以根据tap
:
Why are you not sure? Did you not write it? If not, you can trivially write it yourself given tap
:
function tapxs(xs, y)
for i,x in ipairs(xs) do
tap(x,y)
end
end
...
tapxs({10,20,30,40}, 10) -- tap at 10,10; 20,10; 30,10; etc.
什么是线"?它纯粹是水平的吗?您可以这样写:
What is "the line"? Is it purely horizontal? You could write:
function tapHorizontally(startX, maxX, y, increment)
for x=startX,maxX,increment do
tap(x,y)
end
end
...
tapHorizontally(10,100,20,5) -- tap from 10,20 to 100,20 in 5 pixel increments
当然,这是一个奇怪的特定功能.您通常会编写一些以x,y开始和x,y结尾并在它们之间绘制的东西,因此您可以使用相同的功能来支持水平,垂直,对角线,但是需要更多数学.
Of course, that's a bizarrely specific function. You'd typically write something that takes a starting x,y and ending x,y and draws between them, so you can support horizontal, vertical, diagonal lines all with the same function, but that requires more math.
最重要的是:Lua是一种完善的,功能强大的高级编程语言.它可以用来编写您正在点击的应用程序,或者用于生成点击的应用程序,因此限制将取决于您对编程/算法/数学/等的了解.
The bottom line is: Lua is a full blown, powerful, high level programming language. It could be used to write the very app you're tapping on, or the app you're using to generate taps, so the limits are going to be your knowledge of programming/algorithms/math/etc.
这篇关于Lua表和屏幕坐标.对于y的每个{x},的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!