您好,我最近为我的 UNI 计算类(class)创建了一个 C 程序,该程序在 localhost:2020 生成一个 Web 服务器并发送 Mandelbrot 集的 bmp 文件。如果您不知道那是什么,请不要担心,网址部分很重要。 URL 格式如下
http://X_(x坐标)_(y坐标)_(缩放级别).bmp
所以
http://localhost:2020/X_-0.15_1.03_56.bmp
返回
x:-0.15
y:1.03
缩放:56
我的目标是拥有一个自动化流程,可以获取 x,y 位置(在代码中很好)并重复从服务器加载图像,每次缩放级别增加 0.01 并保存它到一个文件夹或最好将它们全部加载到一个文件中以视频形式呈现。 我很清楚,这在 C 中更容易做到,只需将其保存到文件中,但我的目标是熟悉 applescript/automator 或具有此类任务的类似程序。 它旨在为我自己提供一次有趣的学习体验,我将非常感谢我能得到的任何帮助,谢谢。
最佳答案
这样的东西可能适用于您的部分任务。我们使用 unix 命令行实用程序“curl”下载所有图像(在每个缩放级别)。每个图像均以 url 中的名称保存到您选择的文件夹中。我们将此代码放入重复循环中,以便我们可以增加缩放级别。
该脚本显示了很多内容,特别是如何将变量直接插入到苹果脚本中(例如硬编码)以及如何从用户那里获取输入。它还展示了如何从 applescript 中运行命令行实用程序(例如curl)。
所以这个脚本应该可以帮助您入门。看看是否有帮助。
-- hard-coded variables
set minZoomLevel to 0
set maxZoomLevel to 10
set zoomIncrement to 0.1
-- get user input variables
set outputFolder to choose folder with prompt "Pick the output folder for the images"
set xDialog to display dialog "Enter the X coordinate" default answer ""
set yDialog to display dialog "Enter the Y coordinate" default answer ""
set posixStyleOutputFolder to POSIX path of outputFolder
set x to text returned of xDialog
set y to text returned of yDialog
set i to minZoomLevel
repeat while i is less than or equal to maxZoomLevel
set fileName to "X_" & x & "_" & y & "_" & (i as text) & ".bmp"
set theURL to "http://localhost:2020/" & fileName
do shell script "curl " & theURL & " -o " & quoted form of (posixStyleOutputFolder & fileName)
set i to i + zoomIncrement
end repeat
关于c - Applescript 或 Automator 从网站逐步保存 Mandelbrot 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10162229/