https://github.com/coalaura/codeview
Library for rendering code preview images.
https://github.com/coalaura/codeview
Last synced: 3 months ago
JSON representation
Library for rendering code preview images.
- Host: GitHub
- URL: https://github.com/coalaura/codeview
- Owner: coalaura
- Created: 2023-03-07T17:31:57.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-11T15:59:06.000Z (almost 3 years ago)
- Last Synced: 2025-08-17T18:30:51.258Z (4 months ago)
- Language: Go
- Size: 392 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CodeView
Library for rendering code preview images.
## Example Implementation
```golang
package main
import (
"github.com/coalaura/codeview"
)
func main() {
// Set the project name (appended to title, optional)
codeview.SetProjectName("MyProject")
// Set the logo (png bytes, required)
codeview.SetLogo([]byte("..."))
// Set the color theme (optional)
codeview.SetTheme(codeview.DefaultTheme())
// Create a new code view
cv := codeview.NewCodeView()
// Set the title
cv.SetText(text)
// Set the text (required)
cv.SetTitle(codeview.NewText("Some example code", Language("go")))
// Set the scale (optional)
cv.SetScale(2.0)
// Render the image to a file
err := cv.RenderToPng("test.png")
if err != nil {
panic(err)
}
}
```
### Example Image
