用途:Ray 用于把代码片段渲染成带窗口外观的代码截图,适合用户提出代码截图、代码图片、代码片段转图片等需求。
主要能力:调用 POST https://ray.tinte.dev/api/v1/screenshot,请求体为 JSON。参数包括 code(必填,1-10,000 字符)、language(默认 typescript,支持 javascript、python、rust、go、java、cpp、c、html、css、json、bash、sql、markdown、toml)、theme(默认 one-hunter,可用 tinte.dev 的主题 slug 或内联 TinteBlock 对象)、mode(dark 或 light,默认 dark)、padding(默认 32,0-256)、fontSize(默认 14,8-32)、lineNumbers(默认 true)、title(窗口标题,最多 100 字符)、background(midnight、sunset、ocean、forest、ember、steel、aurora、none 之一,不接受十六进制颜色)、format(仅支持 png)、scale(默认 2,1-4 表示 retina 倍率)。
使用方式:确定要截图的代码,按文件扩展名或内容判断语言,用 curl 调用 API 并保存 PNG,例如:curl -s -X POST https://ray.tinte.dev/api/v1/screenshot -H 'Content-Type: application/json' -d '{"code": "const greeting = "Hello, world!";", "language": "typescript", "theme": "one-hunter", "title": "hello.ts"}' -o screenshot.png && open screenshot.png
限制:仅输出 PNG;background 不接受十六进制颜色;background 设为 none 时返回透明 RGBA PNG,但仍会有窗口阴影的透明边距,合成前可用 magick input.png -trim +repage output.png 去掉;长代码片段渲染可能需 30-60 秒以上,脚本或智能体中调用时应设置单次请求超时。主题使用 tinte.dev 的 slug,或内联包含 13 个语义颜色的 TinteBlock 对象。其余信息暂未提供。