Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
93159e32
Commit
93159e32
authored
Oct 13, 2010
by
Nigel Tao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
image: add an offset to Tiled.
R=r, r2 CC=golang-dev
https://golang.org/cl/2469041
parent
712109f1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
16 deletions
+15
-16
geom.go
src/pkg/image/geom.go
+6
-8
names.go
src/pkg/image/names.go
+9
-8
No files found.
src/pkg/image/geom.go
View file @
93159e32
...
...
@@ -43,15 +43,13 @@ func (p Point) Div(k int) Point {
func
(
p
Point
)
Mod
(
r
Rectangle
)
Point
{
w
,
h
:=
r
.
Dx
(),
r
.
Dy
()
p
=
p
.
Sub
(
r
.
Min
)
if
p
.
X
>=
0
{
p
.
X
=
p
.
X
%
w
}
else
{
p
.
X
=
w
-
1
-
(
-
1
-
p
.
X
)
%
w
p
.
X
=
p
.
X
%
w
if
p
.
X
<
0
{
p
.
X
+=
w
}
if
p
.
Y
>=
0
{
p
.
Y
=
p
.
Y
%
h
}
else
{
p
.
Y
=
h
-
1
-
(
-
1
-
p
.
Y
)
%
h
p
.
Y
=
p
.
Y
%
h
if
p
.
Y
<
0
{
p
.
Y
+=
h
}
return
p
.
Add
(
r
.
Min
)
}
...
...
src/pkg/image/names.go
View file @
93159e32
...
...
@@ -15,7 +15,7 @@ var (
Opaque
=
NewColorImage
(
Alpha16Color
{
0xffff
})
)
// A ColorImage is a
practically
infinite-sized Image of uniform Color.
// A ColorImage is a
n
infinite-sized Image of uniform Color.
// It implements both the Color and Image interfaces.
type
ColorImage
struct
{
C
Color
...
...
@@ -43,11 +43,12 @@ func NewColorImage(c Color) *ColorImage {
return
&
ColorImage
{
c
}
}
// A Tiled is a
practically infinite-sized Image that repeats another Image in
//
both directions. Tiled{i}.At(x, y) will equal i.At(x, y) for all points
// within i's Bounds.
// A Tiled is a
n infinite-sized Image that repeats another Image in both
//
directions. Tiled{i, p}.At(x, y) will equal i.At(x+p.X, y+p.Y) for all
//
points {x+p.X, y+p.Y}
within i's Bounds.
type
Tiled
struct
{
I
Image
I
Image
Offset
Point
}
func
(
t
*
Tiled
)
ColorModel
()
ColorModel
{
...
...
@@ -57,10 +58,10 @@ func (t *Tiled) ColorModel() ColorModel {
func
(
t
*
Tiled
)
Bounds
()
Rectangle
{
return
Rectangle
{
Point
{
-
1e9
,
-
1e9
},
Point
{
1e9
,
1e9
}}
}
func
(
t
*
Tiled
)
At
(
x
,
y
int
)
Color
{
p
:=
Point
{
x
,
y
}
.
Mod
(
t
.
I
.
Bounds
())
p
:=
Point
{
x
,
y
}
.
Add
(
t
.
Offset
)
.
Mod
(
t
.
I
.
Bounds
())
return
t
.
I
.
At
(
p
.
X
,
p
.
Y
)
}
func
NewTiled
(
i
Image
)
*
Tiled
{
return
&
Tiled
{
i
}
func
NewTiled
(
i
Image
,
offset
Point
)
*
Tiled
{
return
&
Tiled
{
i
,
offset
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment