Codeposter
🎉 代码明信片生成器,Generate a poster from your code!
Install / Use
/learn @cj1128/CodeposterREADME
Code Poster
使用 SDL 生成代码明信片,相关博客 使用 Go 编写代码明信片生成器。
<p align="center"> <img src="./examples/rocket.codeposter.png" alt="rocket code poster" /> </p>安装
因为 go-sdl2 使用了 CGO,编译比较复杂,建议在 Releases 中下载编译好的二进制程序。
编译
主机为 Mac,静态编译到 Mac:
$ go build -v -tags static -ldflags "-s -w"
交叉编译到 Windows:
$ CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -v -tags static -ldflags "-s -w"
Linux 无法在 Mac 上进行交叉编译,在 Linux 进行编译可以参考 go-sdl2 的文档说明。
使用
$ codeposter -h
usage: codeposter [<flags>] <source>
Flags:
-h, --help Show context-sensitive help (also try --help-long
and --help-man).
--font=FONT specify font file (default: Hack-Regular.ttf bundled
in binary)
--font-size=12 font size
--width=120 poster width in characters
--height=50 poster height in characters
--code-color=#e9e9e9 source code color, '#rgb' or '#rrggbb' or
'#rrggbbaa'
--bg-color=#fff background color, '#rgb' or '#rrggbb' or '#rrggbbaa'
--img=IMG image used to render poster (default: gopher.png
bundled in binary
--padding=1,2 padding space in characters, e.g. 1,2
-v, --version Show application version.
Args:
<source> source code path
font:字体,默认使用 Hack-Regular.ttf,打包在二进制中font-size:字体大小width:明信片的宽度,单位是字符height:明信片的高度,单位是字符code-color: 代码的颜色,默认为#e9e9e9bg-color: 背景颜色,默认为#fffimg: 渲染明信片的图片,支持 png, jpg, gif,默认为 gopher.png,打包在二进制中padding: 上下和左右间距,单位是字符。可以使用--pading 1设置上下和左右也可以使用--pading 1,2分别设置
示例
Gopher
$ codeposter examples/jquery.min.js --img examples/gopher.png
<p align="center">
<img src="./examples/gopher.codeposter.png" />
</p>
Heart
$ codeposter examples/jquery.min.js --img examples/heart.png
<p align="center">
<img src="./examples/heart.codeposter.png" />
</p>
Diamond
$ codeposter examples/jquery.min.js --img examples/diamond.png
<p align="center">
<img src="./examples/diamond.codeposter.png" />
</p>
Change Log
v0.2.0
- 不再使用浏览器渲染方案,改用 SDL 渲染,直接生成图片
v0.1.1
- 处理
jpeg以及gif类型的图片
v0.1.0
- 完成基本功能
Related Skills
node-connect
352.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
