https://github.com/setanarut/ebitencm
ebitencm is setanarut/cm physics space drawing package
https://github.com/setanarut/ebitencm
chipmunk chipmunk-physics-engine chipmunk2d ebiten ebiten-framework ebiten-parts ebitengine
Last synced: 2 months ago
JSON representation
ebitencm is setanarut/cm physics space drawing package
- Host: GitHub
- URL: https://github.com/setanarut/ebitencm
- Owner: setanarut
- License: mit
- Created: 2024-09-15T20:48:14.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-08-13T19:04:50.000Z (8 months ago)
- Last Synced: 2025-08-13T21:19:51.520Z (8 months ago)
- Topics: chipmunk, chipmunk-physics-engine, chipmunk2d, ebiten, ebiten-framework, ebiten-parts, ebitengine
- Language: Go
- Homepage:
- Size: 69.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pkg.go.dev/github.com/setanarut/ebitencm)

# ebitencm
**ebitencm** is *Drawer* for [setanarut/cm](https://github.com/setanarut/cm) Chipmunk physics space.
# Features
- Color theme customization for *Fill* and *Stroke* colors.
- Detailed drawing options.
- `drawer.GeoM{}` structure is provided for screen transformation. (Cameras)
## Usage
First create a drawer
```Go
var drawer *ebitencm.Drawer = ebitencm.NewDrawer()
```
Then
```go
func (g *Game) Draw(screen *ebiten.Image) {
drawer.DrawSpace(space, screen)
}
```
## Dragging
If you want to enable dragging, call the `HandleMouseEvent()` function within the `Update` method, passing the `*cm.Space` object. This will allow objects to be dragged using a mouse or touch device.
```go
func (g *Game) Update() error {
drawer.HandleMouseEvent(space)
```
## Camera transform
Use `Drawer.GeoM{}` for all vertices transform. The cursor position is calculated according to this matrix.
```Go
// move the all space objects 100 pixels to the left (move camera to right)
drawer.GeoM.Translate(-100, 0)
```
Here is an example with the [setanarut/kamera](https://github.com/setanarut/kamera) package.
```Go
func (g *Game) Update() error {
g.space.Step(1 / 60.0)
g.cam.LookAt(x, y)
// Apply camera transform to drawer
g.drawer.GeoM.Reset()
g.cam.ApplyCameraTransform(g.drawer.GeoM)
// Enable cursor dragging
g.drawer.HandleMouseEvent(g.space)
```
## Examples
Browse to the [examples](./examples/) folder for all examples.