Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring project #64

Merged
merged 16 commits into from
Oct 12, 2023
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
- Adding `Focus()` method to `Window` to focus the window via API.
- Restructure Pixel Project
- Converted `imdraw` and `text` packages to `plugins`
- moved all `*_test.go` files to `test` package

## [v1.0.0](https://github.com/gopxl/pixel/v2/compare/v1.0.0...dev)
- Multiple Window Management Framework
Expand Down
Empty file added backends/opengl/.init
dusk125 marked this conversation as resolved.
Show resolved Hide resolved
duysqubix marked this conversation as resolved.
Show resolved Hide resolved
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added backends/vulkan/.init
Empty file.
8 changes: 5 additions & 3 deletions plugins/README.md → ext/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Plugins
# Extensions

## Introduction

Plugins are a way to extend the features and functionality of Pixel. They are the communities contribution
Extensions are a way to *extend* the features and functionality of Pixel. They are the communities contribution
to pushing Pixel to the next level.


## Plugin List
## Extension List

* [gameloop](gameloop/README.md) - A plugin that allows you to run a game loop in Pixel.
* [imdraw](imdraw/README.md) - A plugin that allows you to draw primitives in Pixel.
* [text](text/README.md) - A plugin that allows you to draw text in Pixel.


## Creating a Plugin
duysqubix marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion plugins/gameloop/gameloop.go → ext/gameloop/gameloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"time"

"github.com/gopxl/pixel/v2/pixelgl"
"github.com/gopxl/pixel/v2/backends/opengl"
)

type EasyWindow interface {
Expand Down
39 changes: 39 additions & 0 deletions ext/imdraw/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# IMDraw

<hr>
IMDraw is an immediate-mode-like shape drawer and BasicTarget. IMDraw supports TrianglesPosition,
TrianglesColor, TrianglesPicture and PictureColor.

IMDraw, other than a regular BasicTarget, is used to draw shapes. To draw shapes, you first need
to Push some points to IMDraw:
```go
imd := pixel.NewIMDraw(pic) use nil pic if you only want to draw primitive shapes
imd.Push(pixel.V(100, 100))
imd.Push(pixel.V(500, 100))
```
Once you have Pushed some points, you can use them to draw a shape, such as a line:

`imd.Line(20) //draws a 20 units thick line``

Set exported fields to change properties of Pushed points:

```go
imd.Color = pixel.RGB(1, 0, 0)
imd.Push(pixel.V(200, 200))
imd.Circle(400, 0)
```
Here is the list of all available point properties (need to be set before Pushing a point):
- Color - applies to all
- Picture - coordinates, only applies to filled polygons
- Intensity - picture intensity, only applies to filled polygons
- Precision - curve drawing precision, only applies to circles and ellipses
- EndShape - shape of the end of a line, only applies to lines and outlines

And here's the list of all shapes that can be drawn (all, except for line, can be filled or
outlined):
- Line
- Polygon
- Circle
- Circle arc
- Ellipse
- Ellipse arc
File renamed without changes.
2 changes: 1 addition & 1 deletion imdraw/imdraw_test.go → ext/imdraw/imdraw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"github.com/gopxl/pixel/v2"
"github.com/gopxl/pixel/v2/imdraw"
"github.com/gopxl/pixel/v2/ext/imdraw"
)

func BenchmarkPush(b *testing.B) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion text/atlas_test.go → ext/text/atlas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package text_test
import (
"testing"

"github.com/gopxl/pixel/v2/text"
"github.com/gopxl/pixel/v2/ext/text"
"golang.org/x/image/font/inconsolata"
)

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions text/text_test.go → ext/text/text_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"golang.org/x/image/font/basicfont"
"golang.org/x/image/font/gofont/goregular"

"github.com/gopxl/pixel/v2"
"github.com/gopxl/pixel/v2/text"
"github.com/golang/freetype/truetype"
"github.com/gopxl/pixel/v2"
"github.com/gopxl/pixel/v2/ext/text"
)

func TestClear(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ require (
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
bhperry marked this conversation as resolved.
Show resolved Hide resolved
gopkg.in/yaml.v3 v3.0.1 // indirect
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk=
Expand All @@ -22,6 +23,12 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/image v0.0.0-20190321063152-3fc05d484e9f/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
Expand All @@ -30,5 +37,6 @@ golang.org/x/image v0.13.0/go.mod h1:6mmbMOeV28HuMTgA6OSRkdXKYw/t5W9Uwn2Yv1r3Yxk
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pixel_test.go → tests/pixel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
_ "image/png"

"github.com/gopxl/pixel/v2"
"github.com/gopxl/pixel/v2/pixelgl"
pixelgl "github.com/gopxl/pixel/v2/backends/opengl"
)

// onePixelImage is the byte representation of a 1x1 solid white png file
Expand Down
File renamed without changes.
File renamed without changes.