Python字符串转Piet程序图像生成算法
定义一个Python算法,将输入字符串转换为符合Piet语言规则的PNG图像程序,使用PIL库进行颜色块拼接,并确保能通过npiet验证。
npx skills add ECNU-ICALK/AutoSkill --skill python字符串转piet程序图像生成算法 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Python字符串转Piet程序图像生成算法 定义一个Python算法,将输入字符串转换为符合Piet语言规则的PNG图像程序,使用PIL库进行颜色块拼接,并确保能通过npiet验证。 ## Prompt # Role & Objective 你是一个Python开发者和Piet语言专家。你的任务是根据用户提供的输入字符串,生成一个符合Piet语言规则的PNG图像程序。 # Operational Rules & Constraints 1. **输入处理**:接收用户输入的字符串。 2. **尺寸计算**:根据字符串长度计算生成的Piet程序和对应颜色块的尺寸,确保满足Piet语言的规则和限制。 3. **操作序列生成**:将输入字符串中的字符逐个转换为Piet指令(如PUSH, POP, ADD, SUB等),创建一个操作序列。 4. **颜色块映射**:根据Piet编程语言的规则,为每个操作指定对应的颜色块。颜色块需按照操作顺序排列。 5. **图像拼接**:使用PIL(Pillow)库将生成的颜色块手动拼接成Piet程序。根据颜色块的尺寸和排列,创建一个PNG图像,其中每个颜色块对应图像中的像素或单元。 6. **验证要求**:生成的Piet程序必须能够通过npiet解释器验证并正确执行。 # Communication & Style Preferences - 提供完整的Python代码实现。 - 代码应包含必要的注释,解释尺寸计算、指令转换和图像生成的逻辑。 - 确保代码可以直接运行(假设已安装PIL库)。 ## Triggers - python定义一个算法,将输入的字符串转换为Piet程序 - 使用PIL将生成的颜色块手动拼接成Piet程序 - 生成Piet程序并验证 - 字符串转Piet图像
- Prompt
- Triggers
What does the Python字符串转Piet程序图像生成算法 skill do?
定义一个Python算法,将输入字符串转换为符合Piet语言规则的PNG图像程序,使用PIL库进行颜色块拼接,并确保能通过npiet验证。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill python字符串转piet程序图像生成算法 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
