Commit 5e381d3a authored by Nigel Tao's avatar Nigel Tao

image: delete the image.Repeated type.

R=r
CC=golang-dev
https://golang.org/cl/5636045
parent 2f8e5a5f
......@@ -1115,9 +1115,7 @@ packages.
The old <code>image.ColorImage</code> type is still in the <code>image</code>
package but has been renamed
<a href="/pkg/image/#Uniform"><code>image.Uniform</code></a>,
while <code>image.Tiled</code>
has been renamed
<a href="/pkg/image/#Repeated"><code>image.Repeated</code></a>.
while <code>image.Tiled</code> has been removed.
</p>
<p>
......@@ -1178,7 +1176,6 @@ This table lists the renamings.
<td colspan="2"><hr></td>
</tr>
<tr><td>image.ColorImage</td> <td>image.Uniform</td></tr>
<tr><td>image.Tiled</td> <td>image.Repeated</td></tr>
</table>
<p>
......
......@@ -1018,9 +1018,7 @@ packages.
The old <code>image.ColorImage</code> type is still in the <code>image</code>
package but has been renamed
<a href="/pkg/image/#Uniform"><code>image.Uniform</code></a>,
while <code>image.Tiled</code>
has been renamed
<a href="/pkg/image/#Repeated"><code>image.Repeated</code></a>.
while <code>image.Tiled</code> has been removed.
</p>
<p>
......@@ -1081,7 +1079,6 @@ This table lists the renamings.
<td colspan="2"><hr></td>
</tr>
<tr><td>image.ColorImage</td> <td>image.Uniform</td></tr>
<tr><td>image.Tiled</td> <td>image.Repeated</td></tr>
</table>
<p>
......
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"go/ast"
)
func init() {
register(imagetiledFix)
}
var imagetiledFix = fix{
"imagetiled",
"2012-01-10",
imagetiled,
`Rename image.Tiled to image.Repeated.
http://codereview.appspot.com/5530062
`,
}
func imagetiled(f *ast.File) bool {
if !imports(f, "image") {
return false
}
fixed := false
walk(f, func(n interface{}) {
s, ok := n.(*ast.SelectorExpr)
if !ok || !isTopName(s.X, "image") || s.Sel.String() != "Tiled" {
return
}
s.Sel = &ast.Ident{Name: "Repeated"}
fixed = true
})
return fixed
}
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
func init() {
addTestCases(imagetiledTests, imagetiled)
}
var imagetiledTests = []testCase{
{
Name: "imagetiled.0",
In: `package main
import (
"foo"
"image"
)
var (
_ foo.Tiled
_ image.RGBA
_ image.Tiled
)
`,
Out: `package main
import (
"foo"
"image"
)
var (
_ foo.Tiled
_ image.RGBA
_ image.Repeated
)
`,
},
}
......@@ -50,30 +50,3 @@ func (c *Uniform) Opaque() bool {
func NewUniform(c color.Color) *Uniform {
return &Uniform{c}
}
// Repeated is an Image that is a source Image translated by -Offset and then
// repeated in all four directions to infinity.
//
// Repeated{src, off}.At(x, y) will equal src.At(x+off.X, y+off.Y) for all
// points {x+off.X, y+off.Y} within src's Bounds.
type Repeated struct {
// I is the source image.
I Image
// Offset is the translation vector from result pixel to source pixel.
Offset Point
}
func (r *Repeated) ColorModel() color.Model {
return r.I.ColorModel()
}
func (r *Repeated) Bounds() Rectangle { return Rectangle{Point{-1e9, -1e9}, Point{1e9, 1e9}} }
func (r *Repeated) At(x, y int) color.Color {
p := Point{x, y}.Add(r.Offset).Mod(r.I.Bounds())
return r.I.At(p.X, p.Y)
}
func NewRepeated(i Image, offset Point) *Repeated {
return &Repeated{i, offset}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment