From example-skills
Generates Slack-optimized animated GIFs using Python/PIL with frame builders, drawing primitives, easing functions, and validators for emoji/message sizes.
npx claudepluginhub joshuarweaver/cascade-code-general-misc-3 --plugin marcelleon-skills-zhThis skill uses the workspace's default tool permissions.
一个工具包,提供用于创建针对 Slack 优化的动画 GIF 的实用工具和知识。
Applies Acme Corporation brand guidelines including colors, fonts, layouts, and messaging to generated PowerPoint, Excel, and PDF documents.
Builds DCF models with sensitivity analysis, Monte Carlo simulations, and scenario planning for investment valuation and risk assessment.
Calculates profitability (ROE, margins), liquidity (current ratio), leverage, efficiency, and valuation (P/E, EV/EBITDA) ratios from financial statements in CSV, JSON, text, or Excel for investment analysis.
一个工具包,提供用于创建针对 Slack 优化的动画 GIF 的实用工具和知识。
尺寸:
参数:
from core.gif_builder import GIFBuilder
from PIL import Image, ImageDraw
# 1. 创建构建器
builder = GIFBuilder(width=128, height=128, fps=10)
# 2. 生成帧
for i in range(12):
frame = Image.new('RGB', (128, 128), (240, 248, 255))
draw = ImageDraw.Draw(frame)
# 使用 PIL 基元绘制动画
# (圆形、多边形、线条等)
builder.add_frame(frame)
# 3. 保存并优化
builder.save('output.gif', num_colors=48, optimize_for_emoji=True)
如果用户上传图像,请考虑他们是否想要:
使用 PIL 加载和处理图像:
from PIL import Image
uploaded = Image.open('file.png')
# 直接使用,或仅作为颜色/风格的参考
从头开始绘制图形时,使用 PIL ImageDraw 基元:
from PIL import ImageDraw
draw = ImageDraw.Draw(frame)
# 圆形/椭圆形
draw.ellipse([x1, y1, x2, y2], fill=(r, g, b), outline=(r, g, b), width=3)
# 星形、三角形、任何多边形
points = [(x1, y1), (x2, y2), (x3, y3), ...]
draw.polygon(points, fill=(r, g, b), outline=(r, g, b), width=3)
# 线条
draw.line([(x1, y1), (x2, y2)], fill=(r, g, b), width=5)
# 矩形
draw.rectangle([x1, y1, x2, y2], fill=(r, g, b), outline=(r, g, b), width=3)
不要使用: 表情符号字体(跨平台不可靠)或假设此技能中存在预包装的图形。
图形应该看起来精致而富有创意,而不是基础的。以下是方法:
使用更粗的线条 - 始终为轮廓和线条设置 width=2 或更高。细线(width=1)看起来不平滑且业余。
添加视觉深度:
create_gradient_background)使形状更有趣:
注意颜色:
对于复杂的形状(心形、雪花等):
发挥创意并注意细节!一个好的 Slack GIF 应该看起来精致,而不是占位符图形。
core.gif_builder)组装帧并为 Slack 优化:
builder = GIFBuilder(width=128, height=128, fps=10)
builder.add_frame(frame) # 添加 PIL Image
builder.add_frames(frames) # 添加帧列表
builder.save('out.gif', num_colors=48, optimize_for_emoji=True, remove_duplicates=True)
core.validators)检查 GIF 是否满足 Slack 要求:
from core.validators import validate_gif, is_slack_ready
# 详细验证
passes, info = validate_gif('my.gif', is_emoji=True, verbose=True)
# 快速检查
if ady('my.gif'):
print("准备好了!")
core.easing)平滑运动而不是线性:
from core.easing import interpolate
# 从 0.0 到 1.0 的进度
t = i / (num_frames - 1)
# 应用缓动
y = interpolate(start=0, end=400, t=t, easing='ease_out')
# 可用:linear、ease_in、ease_out、ease_in_out、
# bounce_out、elastic_out、back_out
core.frame_composer)常见需求的便捷函数:
from core.frame_composer import (
create_blank_frame, # 纯色背景
create_gradient_background, # 垂直渐变
draw_circle, # 圆形助手
draw_text, # 简单文本渲染
draw_star # 5 角星
)
用振荡偏移对象位置:
math.sin() 或 math.cos() 与帧索引有节奏地缩放对象大小:
math.sin(t * frequency * 2 * math.pi) 进行平滑脉动对象下落并弹跳:
interpolate() 与 easing='bounce_out' 着陆easing='ease_in' 下落(加速)围绕中心旋转对象:
image.rotate(angle, resample=Image.BICUBIC)逐渐出现或消失:
Image.blend(image1, image2, alpha)将对象从屏幕外移动到位置:
interpolate() 与 easing='ease_out' 平滑停止easing='back_out'缩放和定位以实现缩放效果:
创建向外辐射的粒子:
x += vx、y += vyvy += gravity_constant仅当被要求使文件大小更小时,实施以下几种方法:
num_colors=48 而不是 128remove_duplicates=Trueoptimize_for_emoji=True 自动优化# 表情符号的最大优化
builder.save(
'emoji.gif',
num_colors=48,
optimize_for_emoji=True,
remove_duplicates=True
)
此技能提供:
它不提供:
关于用户上传的说明:此技能不包含预构建的图形,但如果用户上传图像,请使用 PIL 加载并处理它 - 根据他们的请求解释他们是希望直接使用它还是仅作为灵感。
发挥创意!组合概念(弹跳 + 旋转、脉动 + 滑动等)并使用 PIL 的全部功能。
pip install pillow imageio numpy