哪些图形库可用于 Bash shell 脚本?

rra*_*tam 0 gui bash scripts graphics

像 C/C++ 的 opengl 一样,是否有一些库可用于 Bash shell 脚本?

我试图使用 Bash 创建一个简单的 2D 游戏(河内之塔)。我需要哪些库才能从图形对象开始,例如创建圆柱体、环等?

Rin*_*ind 6

Zenity是一个创建对话框的工具,仅此而已。Bash 中没有 3D。为此,您需要一种编码语言,而不是 shell 脚本语言。

它有以下选项:

  --calendar                             Display calendar dialog
  --entry                                Display text entry dialog
  --error                                Display error dialog
  --info                                 Display info dialog
  --file-selection                       Display file selection dialog
  --list                                 Display list dialog
  --notification                         Display notification
  --progress                             Display progress indication dialog
  --question                             Display question dialog
  --warning                              Display warning dialog
  --scale                                Display scale dialog
  --text-info                            Display text information dialog
Run Code Online (Sandbox Code Playgroud)

创建供用户输入的图形方法。

例子:

#!/bin/sh

if zenity --entry \
--title="Add new profile" \
--text="Enter name of new profile:" \
--entry-text "NewProfile"
  then echo $?
  else echo "No name entered"
fi
Run Code Online (Sandbox Code Playgroud)

会显示...

在此处输入图片说明

但这在很大程度上仅限于这些选项。

如果您想创建 3D 应用程序(如游戏),请使用 Python(pygame 是一个不错的选择)、Perl 或 C/C++。


howtogeek还有一些例子。