Skip to content
Back to skills

Python字符串转Piet程序图像生成算法

ASecurity

定义一个Python算法,将输入字符串转换为符合Piet语言规则的PNG图像程序,使用PIL库进行颜色块拼接,并确保能通过npiet验证。

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
educationpython

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill 'python字符串转piet程序图像生成算法' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Python字符串转Piet程序图像生成算法?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Python字符串转Piet程序图像生成算法
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-python-piet/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-python-piet)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "9dfd836c-280f-4fbd-b74d-b224a770cd1e"
name: "Python字符串转Piet程序图像生成算法"
description: "定义一个Python算法,将输入字符串转换为符合Piet语言规则的PNG图像程序,使用PIL库进行颜色块拼接,并确保能通过npiet验证。"
version: "0.1.0"
tags:
  - "python"
  - "piet"
  - "图像生成"
  - "算法"
  - "PIL"
triggers:
  - "python定义一个算法,将输入的字符串转换为Piet程序"
  - "使用PIL将生成的颜色块手动拼接成Piet程序"
  - "生成Piet程序并验证"
  - "字符串转Piet图像"
---

# 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图像

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.