From 9748b28c0ef471a8c1b3811a4bb40cb3ee46c366 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 11 Feb 2017 03:44:29 +0900 Subject: [PATCH] graphics: Try to make CI happy --- image_test.go | 2 +- vertices.go | 21 +++++++++++++++++++++ vertices_js.go | 4 ++-- vertices_notjs.go | 4 ++-- 4 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 vertices.go diff --git a/image_test.go b/image_test.go index 6c95e5c5d..8053e4563 100644 --- a/image_test.go +++ b/image_test.go @@ -642,7 +642,7 @@ func TestImageEdge(t *testing.T) { if c == transparent { continue } - t.Errorf("img1.At(%d, %d) want: red or transparent, got: %v", i, j, c) + t.Errorf("img1.At(%d, %d) (angle: %d) want: red or transparent, got: %v", i, j, a, c) } } } diff --git a/vertices.go b/vertices.go new file mode 100644 index 000000000..d933407f9 --- /dev/null +++ b/vertices.go @@ -0,0 +1,21 @@ +// Copyright 2017 The Ebiten Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ebiten + +// texelAdjustment represents a number to be used to adjust texel. +// Texels are adjusted by amount propotional to inverse of texelAdjustment. +// This is necessary not to use unexpected pixels outside of texels. +// See #317. +const texelAdjustment = 128 diff --git a/vertices_js.go b/vertices_js.go index 350f633f7..0df8349d0 100644 --- a/vertices_js.go +++ b/vertices_js.go @@ -57,8 +57,8 @@ func vertices(parts ImageParts, width, height int, geo *affine.GeoM) []float32 { } u0, v0, u1, v1 := float64(sx0)/wf, float64(sy0)/hf, float64(sx1)/wf, float64(sy1)/hf // Adjust texels to fix a problem that outside texels are used (#317). - u1 -= 1.0 / wf / 256.0 - v1 -= 1.0 / hf / 256.0 + u1 -= 1.0 / wf / texelAdjustment + v1 -= 1.0 / hf / texelAdjustment vs.SetIndex(n, dx0) vs.SetIndex(n+1, dy0) vs.SetIndex(n+2, u0) diff --git a/vertices_notjs.go b/vertices_notjs.go index 4393643b0..47b866a31 100644 --- a/vertices_notjs.go +++ b/vertices_notjs.go @@ -56,8 +56,8 @@ func vertices(parts ImageParts, width, height int, geo *affine.GeoM) []float32 { } u0, v0, u1, v1 := float32(sx0)/wf, float32(sy0)/hf, float32(sx1)/wf, float32(sy1)/hf // Adjust texels to fix a problem that outside texels are used (#317). - u1 -= 1.0 / wf / 256.0 - v1 -= 1.0 / hf / 256.0 + u1 -= 1.0 / wf / texelAdjustment + v1 -= 1.0 / hf / texelAdjustment vs[n] = x0 vs[n+1] = y0 vs[n+2] = u0