Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
503218cd
Commit
503218cd
authored
Dec 05, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #762 from abarth/image_repeat
Implement ImageRepeat
parents
7eb387b1
9c00bc53
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
7 deletions
+39
-7
box_painter.dart
packages/flutter/lib/src/painting/box_painter.dart
+38
-6
image.dart
packages/flutter/lib/src/rendering/image.dart
+1
-1
No files found.
packages/flutter/lib/src/painting/box_painter.dart
View file @
503218cd
...
...
@@ -573,6 +573,35 @@ enum ImageRepeat {
noRepeat
}
Iterable
<
Rect
>
_generateImageTileRects
(
Rect
outputRect
,
Rect
fundamentalRect
,
ImageRepeat
repeat
)
sync
*
{
if
(
repeat
==
ImageRepeat
.
noRepeat
)
{
yield
fundamentalRect
;
return
;
}
int
startX
=
0
;
int
startY
=
0
;
int
stopX
=
0
;
int
stopY
=
0
;
double
strideX
=
fundamentalRect
.
width
;
double
strideY
=
fundamentalRect
.
height
;
if
(
repeat
==
ImageRepeat
.
repeat
||
repeat
==
ImageRepeat
.
repeatX
)
{
startX
=
((
outputRect
.
left
-
fundamentalRect
.
left
)
/
strideX
).
floor
();
stopX
=
((
outputRect
.
right
-
fundamentalRect
.
right
)
/
strideX
).
ceil
();
}
if
(
repeat
==
ImageRepeat
.
repeat
||
repeat
==
ImageRepeat
.
repeatY
)
{
startY
=
((
outputRect
.
top
-
fundamentalRect
.
top
)
/
strideY
).
floor
();
stopY
=
((
outputRect
.
bottom
-
fundamentalRect
.
bottom
)
/
strideY
).
ceil
();
}
for
(
int
i
=
startX
;
i
<=
stopX
;
++
i
)
{
for
(
int
j
=
startY
;
j
<=
stopY
;
++
j
)
yield
fundamentalRect
.
shift
(
new
Offset
(
i
*
strideX
,
j
*
strideY
));
}
}
/// Paint an image into the given rectangle in the canvas
void
paintImage
(
{
Canvas
canvas
,
...
...
@@ -580,7 +609,7 @@ void paintImage({
ui
.
Image
image
,
ColorFilter
colorFilter
,
ImageFit
fit
,
repeat:
ImageRepeat
.
noRepeat
,
ImageRepeat
repeat:
ImageRepeat
.
noRepeat
,
Rect
centerSlice
,
double
alignX
,
double
alignY
...
...
@@ -640,7 +669,6 @@ void paintImage({
// as we apply a nine-patch stretch.
assert
(
sourceSize
==
inputSize
);
}
// TODO(abarth): Implement |repeat|.
Paint
paint
=
new
Paint
()..
isAntiAlias
=
false
;
if
(
colorFilter
!=
null
)
paint
.
colorFilter
=
colorFilter
;
...
...
@@ -648,10 +676,14 @@ void paintImage({
double
dy
=
(
outputSize
.
height
-
destinationSize
.
height
)
*
(
alignY
??
0.5
);
Point
destinationPosition
=
rect
.
topLeft
+
new
Offset
(
dx
,
dy
);
Rect
destinationRect
=
destinationPosition
&
destinationSize
;
if
(
centerSlice
==
null
)
canvas
.
drawImageRect
(
image
,
Point
.
origin
&
sourceSize
,
destinationRect
,
paint
);
else
canvas
.
drawImageNine
(
image
,
centerSlice
,
destinationRect
,
paint
);
if
(
centerSlice
==
null
)
{
Rect
sourceRect
=
Point
.
origin
&
sourceSize
;
for
(
Rect
tileRect
in
_generateImageTileRects
(
rect
,
destinationRect
,
repeat
))
canvas
.
drawImageRect
(
image
,
sourceRect
,
tileRect
,
paint
);
}
else
{
for
(
Rect
tileRect
in
_generateImageTileRects
(
rect
,
destinationRect
,
repeat
))
canvas
.
drawImageNine
(
image
,
centerSlice
,
tileRect
,
paint
);
}
}
/// A background image for a box.
...
...
packages/flutter/lib/src/rendering/image.dart
View file @
503218cd
...
...
@@ -25,7 +25,7 @@ class RenderImage extends RenderBox {
ColorFilter
colorFilter
,
ImageFit
fit
,
FractionalOffset
alignment
,
repeat:
ImageRepeat
.
noRepeat
,
ImageRepeat
repeat:
ImageRepeat
.
noRepeat
,
Rect
centerSlice
})
:
_image
=
image
,
_width
=
width
,
...
...
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