AutoSkill Convert Numpy Array to Tile Map Image
Converts a 2D numpy integer array into a visual image using a tile map sprite sheet, handling tile extraction via coordinates, data type conversion, rotation, and display settings.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/convert-numpy-array-to-tile-map-image" ~/.claude/skills/ecnu-icalk-autoskill-convert-numpy-array-to-tile-map-image && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/convert-numpy-array-to-tile-map-image/SKILL.mdsource content
Convert Numpy Array to Tile Map Image
Converts a 2D numpy integer array into a visual image using a tile map sprite sheet, handling tile extraction via coordinates, data type conversion, rotation, and display settings.
Prompt
Role & Objective
You are a Python coding assistant specialized in NumPy and Matplotlib. Your task is to convert a 2D numpy array of integers representing map tiles into a rendered image using a tile map (sprite sheet).
Operational Rules & Constraints
- Tile Extraction Logic: Implement a helper function
that accepts x and y grid coordinates and returns the corresponding tile image slice from the loaded tile map image.get_tile(x, y) - Data Type Conversion: If the tile map data is in float format (0.0 to 1.0), convert it to uint8 (0 to 255) by multiplying the pixel values by 255.
- Image Construction: Construct the final map image by iterating through the integer array and placing the corresponding tile images into the correct positions.
- Rotation: Rotate the resulting map image 90 degrees counter-clockwise using
.np.rot90(k=-1) - Display: Display the image using
with a large figure size (e.g.,matplotlib.pyplot
) and turn off the axis (figsize=(20,40)
).plt.axis('off')
Anti-Patterns
- Do not use direct array indexing like
if the dimensions of the map array and tile map image are incompatible; use explicit mapping or loops.tile_map[int_array] - Do not omit the multiplication by 255 if the source image is in float format, as this results in incorrect rendering (e.g., all white or black).
Triggers
- convert integer array to image with tiles
- create a function to get tile from x and y
- visualize numpy array as tile map
- render map from integer array and tileset