From 6b4a6905dec37f916e4e1fec434d0686aceceb98 Mon Sep 17 00:00:00 2001 From: "Alex R. Delp" Date: Sat, 9 May 2020 10:12:32 -0700 Subject: [PATCH 01/11] Update CHANGELOG.md --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea185373..50fddce6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - ## [Unreleased] +- Gamepad API? + +## [v0.10.0-alpha] 2020-05-08 - Upgrade to GLFW 3.3! :tada: - Closes https://github.com/faiface/pixel/issues/137 - Add support for glfw's DisableCursor @@ -34,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Changelog for this and older versions can be found on the corresponding [GitHub releases](https://github.com/faiface/pixel/releases). -[Unreleased]: https://github.com/faiface/pixel/compare/v0.9.0...HEAD +[Unreleased]: https://github.com/faiface/pixel/compare/v0.10.0-alpha...HEAD +[v0.10.0]: https://github.com/faiface/pixel/compare/v0.9.0...v0.10.0-alpha [v0.9.0]: https://github.com/faiface/pixel/compare/v0.8.0...v0.9.0 [v0.8.0]: https://github.com/faiface/pixel/releases/tag/v0.8.0 From b40ab4939f625ede126f3f33c3c7d046a8f2cf81 Mon Sep 17 00:00:00 2001 From: "Alex R. Delp" Date: Sat, 9 May 2020 10:13:05 -0700 Subject: [PATCH 02/11] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50fddce6..4ed4aded 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,6 @@ Changelog for this and older versions can be found on the corresponding [GitHub releases](https://github.com/faiface/pixel/releases). [Unreleased]: https://github.com/faiface/pixel/compare/v0.10.0-alpha...HEAD -[v0.10.0]: https://github.com/faiface/pixel/compare/v0.9.0...v0.10.0-alpha +[v0.10.0-alpha]: https://github.com/faiface/pixel/compare/v0.9.0...v0.10.0-alpha [v0.9.0]: https://github.com/faiface/pixel/compare/v0.8.0...v0.9.0 [v0.8.0]: https://github.com/faiface/pixel/releases/tag/v0.8.0 From d7884ac96a4417bc256e094c67397ec3760b0b0a Mon Sep 17 00:00:00 2001 From: "Alex R. Delp" Date: Sat, 9 May 2020 10:15:57 -0700 Subject: [PATCH 03/11] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e41131ef..22c308f0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,7 @@ 1. **Make a community example** and place it inside the `community` folder of the [examples repository][examples]. 2. **Add tests**. There only few tests in Pixel at the moment. Take a look at them and make some similar. 3. **Add a small feature or an improvement**. Feel like some small feature is missing? Just make a PR. Be ready that I might reject it, though, if I don't find it particularly appealing. -4. **Join the big development** by joining the discussion at the [Gitter](https://gitter.im/pixellib/Lobby), where we can discuss bigger changes and implement them after that. +4. **Join the big development** by joining the discussion on our [Discord Server](https://discord.gg/q2DK4MP), where we can discuss bigger changes and implement them after that. ## How to make a pull request From 5e3b82eeabb2b06e9eaa7a57e168d69a1d7703c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gro=C3=9Fe?= Date: Sun, 3 May 2020 19:38:20 +0200 Subject: [PATCH 04/11] Support glfw.TransparentFramebuffer window hint --- CHANGELOG.md | 1 + pixelgl/window.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ed4aded..e236bbfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] - Gamepad API? +- Add `WindowConfig.TransparentFramebuffer` option to support window transparency onto the background ## [v0.10.0-alpha] 2020-05-08 - Upgrade to GLFW 3.3! :tada: diff --git a/pixelgl/window.go b/pixelgl/window.go index 94726590..80bac3c5 100644 --- a/pixelgl/window.go +++ b/pixelgl/window.go @@ -56,6 +56,12 @@ type WindowConfig struct { // implement proper full screen windows. AlwaysOnTop bool + // TransparentFramebuffer specifies whether the window framebuffer will be + // transparent. If enabled and supported by the system, the window + // framebuffer alpha channel will be used to combine the framebuffer with + // the background. This does not affect window decorations. + TransparentFramebuffer bool + // VSync (vertical synchronization) synchronizes Window's framerate with the framerate of // the monitor. VSync bool @@ -112,6 +118,7 @@ func NewWindow(cfg WindowConfig) (*Window, error) { glfw.WindowHint(glfw.Decorated, bool2int[!cfg.Undecorated]) glfw.WindowHint(glfw.Floating, bool2int[cfg.AlwaysOnTop]) glfw.WindowHint(glfw.AutoIconify, bool2int[!cfg.NoIconify]) + glfw.WindowHint(glfw.TransparentFramebuffer, bool2int[cfg.TransparentFramebuffer]) var share *glfw.Window if currWin != nil { From 6a71f07d1221454f9d0651c797dba0be023c0fb5 Mon Sep 17 00:00:00 2001 From: "Alex R. Delp" Date: Sat, 9 May 2020 12:43:38 -0700 Subject: [PATCH 05/11] Update README.md --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index f8f5fd84..51181696 100644 --- a/README.md +++ b/README.md @@ -172,10 +172,6 @@ better result. Take a look at [CONTRIBUTING.md](CONTRIBUTING.md) for further information. -For any kind of discussion, feel free to use our -[Gitter](https://gitter.im/pixellib/Lobby) -community. - ## License [MIT](LICENSE) From d2d1f03c32421f241a2b30ae87afb23feb12085d Mon Sep 17 00:00:00 2001 From: "Alex R. Delp" Date: Sat, 9 May 2020 12:46:09 -0700 Subject: [PATCH 06/11] Add a clarifying comment in imdraw push --- imdraw/imdraw.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/imdraw/imdraw.go b/imdraw/imdraw.go index e616c39c..9de21c9d 100644 --- a/imdraw/imdraw.go +++ b/imdraw/imdraw.go @@ -128,7 +128,9 @@ func (imd *IMDraw) Draw(t pixel.Target) { // Push adds some points to the IM queue. All Pushed points will have the same properties except for // the position. func (imd *IMDraw) Push(pts ...pixel.Vec) { + //Assert that Color is of type pixel.RGBA, if _, ok := imd.Color.(pixel.RGBA); !ok { + //otherwise cast it imd.Color = pixel.ToRGBA(imd.Color) } opts := point{ From 8792d4436c3725964ef097acda9c32cb54ce8dec Mon Sep 17 00:00:00 2001 From: Ben Cragg Date: Sun, 10 May 2020 14:13:46 +0100 Subject: [PATCH 07/11] Adding vert and horz tests --- geometry_test.go | 74 ++++++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/geometry_test.go b/geometry_test.go index e3af737a..91cf81e1 100644 --- a/geometry_test.go +++ b/geometry_test.go @@ -1002,6 +1002,18 @@ func TestLine_Closest(t *testing.T) { args: args{v: pixel.V(20, 20)}, want: pixel.V(10, 10), }, + { + name: "Vertical line", + fields: fields{A: pixel.V(0, -10), B: pixel.V(0, 10)}, + args: args{v: pixel.V(-1, 0)}, + want: pixel.V(0, 0), + }, + { + name: "Horizontal line", + fields: fields{A: pixel.V(-10, 0), B: pixel.V(10, 0)}, + args: args{v: pixel.V(0, -1)}, + want: pixel.V(0, 0), + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -1267,36 +1279,42 @@ func TestLine_IntersectRect(t *testing.T) { args args want pixel.Vec }{ - { - name: "Line through rect vertically", - fields: fields{A: pixel.V(0, 0), B: pixel.V(0, 10)}, - args: args{r: pixel.R(-1, 1, 5, 5)}, + //{ + // name: "Line through rect vertically", + // fields: fields{A: pixel.V(0, 0), B: pixel.V(0, 10)}, + // args: args{r: pixel.R(-1, 1, 5, 5)}, + // want: pixel.V(-1, 0), + //}, + //{ + // name: "Line through rect horizontally", + // fields: fields{A: pixel.V(0, 1), B: pixel.V(10, 1)}, + // args: args{r: pixel.R(1, 0, 5, 5)}, + // want: pixel.V(0, -1), + //}, + //{ + // name: "Line through rect diagonally bottom and left edges", + // fields: fields{A: pixel.V(0, 0), B: pixel.V(10, 10)}, + // args: args{r: pixel.R(0, 2, 3, 3)}, + // want: pixel.V(-1, 1), + //}, + //{ + // name: "Line through rect diagonally top and right edges", + // fields: fields{A: pixel.V(10, 0), B: pixel.V(0, 10)}, + // args: args{r: pixel.R(5, 0, 8, 3)}, + // want: pixel.V(-2.5, -2.5), + //}, + //{ + // name: "Line with not rect intersect", + // fields: fields{A: pixel.V(0, 0), B: pixel.V(10, 10)}, + // args: args{r: pixel.R(20, 20, 21, 21)}, + // want: pixel.ZV, + //}, + { + name: "Line intersects at 0,0", + fields: fields{A: pixel.V(0, -10), B: pixel.V(0, 10)}, + args: args{r: pixel.R(-1, 0, 2, 2)}, want: pixel.V(-1, 0), }, - { - name: "Line through rect horizontally", - fields: fields{A: pixel.V(0, 1), B: pixel.V(10, 1)}, - args: args{r: pixel.R(1, 0, 5, 5)}, - want: pixel.V(0, -1), - }, - { - name: "Line through rect diagonally bottom and left edges", - fields: fields{A: pixel.V(0, 0), B: pixel.V(10, 10)}, - args: args{r: pixel.R(0, 2, 3, 3)}, - want: pixel.V(-1, 1), - }, - { - name: "Line through rect diagonally top and right edges", - fields: fields{A: pixel.V(10, 0), B: pixel.V(0, 10)}, - args: args{r: pixel.R(5, 0, 8, 3)}, - want: pixel.V(-2.5, -2.5), - }, - { - name: "Line with not rect intersect", - fields: fields{A: pixel.V(0, 0), B: pixel.V(10, 10)}, - args: args{r: pixel.R(20, 20, 21, 21)}, - want: pixel.ZV, - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { From 76534cb8d07813b9f5528ad621423d982b5f2c28 Mon Sep 17 00:00:00 2001 From: Ben Cragg Date: Sun, 10 May 2020 14:24:07 +0100 Subject: [PATCH 08/11] Removing commented out tests --- geometry_test.go | 60 ++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/geometry_test.go b/geometry_test.go index 91cf81e1..da633143 100644 --- a/geometry_test.go +++ b/geometry_test.go @@ -1279,36 +1279,36 @@ func TestLine_IntersectRect(t *testing.T) { args args want pixel.Vec }{ - //{ - // name: "Line through rect vertically", - // fields: fields{A: pixel.V(0, 0), B: pixel.V(0, 10)}, - // args: args{r: pixel.R(-1, 1, 5, 5)}, - // want: pixel.V(-1, 0), - //}, - //{ - // name: "Line through rect horizontally", - // fields: fields{A: pixel.V(0, 1), B: pixel.V(10, 1)}, - // args: args{r: pixel.R(1, 0, 5, 5)}, - // want: pixel.V(0, -1), - //}, - //{ - // name: "Line through rect diagonally bottom and left edges", - // fields: fields{A: pixel.V(0, 0), B: pixel.V(10, 10)}, - // args: args{r: pixel.R(0, 2, 3, 3)}, - // want: pixel.V(-1, 1), - //}, - //{ - // name: "Line through rect diagonally top and right edges", - // fields: fields{A: pixel.V(10, 0), B: pixel.V(0, 10)}, - // args: args{r: pixel.R(5, 0, 8, 3)}, - // want: pixel.V(-2.5, -2.5), - //}, - //{ - // name: "Line with not rect intersect", - // fields: fields{A: pixel.V(0, 0), B: pixel.V(10, 10)}, - // args: args{r: pixel.R(20, 20, 21, 21)}, - // want: pixel.ZV, - //}, + { + name: "Line through rect vertically", + fields: fields{A: pixel.V(0, 0), B: pixel.V(0, 10)}, + args: args{r: pixel.R(-1, 1, 5, 5)}, + want: pixel.V(-1, 0), + }, + { + name: "Line through rect horizontally", + fields: fields{A: pixel.V(0, 1), B: pixel.V(10, 1)}, + args: args{r: pixel.R(1, 0, 5, 5)}, + want: pixel.V(0, -1), + }, + { + name: "Line through rect diagonally bottom and left edges", + fields: fields{A: pixel.V(0, 0), B: pixel.V(10, 10)}, + args: args{r: pixel.R(0, 2, 3, 3)}, + want: pixel.V(-1, 1), + }, + { + name: "Line through rect diagonally top and right edges", + fields: fields{A: pixel.V(10, 0), B: pixel.V(0, 10)}, + args: args{r: pixel.R(5, 0, 8, 3)}, + want: pixel.V(-2.5, -2.5), + }, + { + name: "Line with not rect intersect", + fields: fields{A: pixel.V(0, 0), B: pixel.V(10, 10)}, + args: args{r: pixel.R(20, 20, 21, 21)}, + want: pixel.ZV, + }, { name: "Line intersects at 0,0", fields: fields{A: pixel.V(0, -10), B: pixel.V(0, 10)}, From 5254b4eb62ae6f24f2635314c141fb5e73636900 Mon Sep 17 00:00:00 2001 From: Ben Cragg Date: Sun, 10 May 2020 14:25:05 +0100 Subject: [PATCH 09/11] Fixing 0,0 being legit closest point --- geometry.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/geometry.go b/geometry.go index 2d902dc5..a98b78ca 100644 --- a/geometry.go +++ b/geometry.go @@ -406,12 +406,12 @@ func (l Line) IntersectRect(r Rect) Vec { // - the point is contained by the rectangle // - the point is not the corner itself corners := r.Vertices() - closest := ZV + var closest *Vec closestCorner := corners[0] for _, c := range corners { cc := l.Closest(c) - if closest == ZV || (closest.Len() > cc.Len() && r.Contains(cc)) { - closest = cc + if closest == nil || (closest.Len() > cc.Len() && r.Contains(cc)) { + closest = &cc closestCorner = c } } From 6b712453243e2ff071d64ebcc97cd476c7d20fce Mon Sep 17 00:00:00 2001 From: Ben Cragg Date: Sun, 10 May 2020 14:34:10 +0100 Subject: [PATCH 10/11] Updated change log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ed4aded..e3232c01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] - Gamepad API? +- Fixed Line intersects failing on lines passing through (0, 0) ## [v0.10.0-alpha] 2020-05-08 - Upgrade to GLFW 3.3! :tada: From c35e0abd1c597aedbe98053e26c68265810afb7b Mon Sep 17 00:00:00 2001 From: "Alex R. Delp" Date: Sun, 10 May 2020 14:09:06 -0700 Subject: [PATCH 11/11] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26095cad..9f08417e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] -- Gamepad API support +- Pending physical testing, Gamepad API support from [PR-233](https://github.com/faiface/pixel/pull/233) - Add `WindowConfig.TransparentFramebuffer` option to support window transparency onto the background - Fixed Line intersects failing on lines passing through (0, 0)