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
99112425
Commit
99112425
authored
Jan 08, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1143 from Hixie/GridPaper
GridPaper updates
parents
8899fe5a
d502d237
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
15 deletions
+31
-15
gridpaper.dart
packages/flutter/lib/src/widgets/gridpaper.dart
+31
-15
No files found.
packages/flutter/lib/src/widgets/gridpaper.dart
View file @
99112425
...
...
@@ -10,29 +10,38 @@ import 'framework.dart';
class
_GridPaperPainter
extends
CustomPainter
{
const
_GridPaperPainter
({
this
.
color
,
this
.
interval
this
.
interval
,
this
.
divisions
,
this
.
subDivisions
});
final
Color
color
;
final
double
interval
;
final
int
divisions
;
final
int
subDivisions
;
void
paint
(
Canvas
canvas
,
Size
size
)
{
Paint
linePaint
=
new
Paint
()
..
color
=
color
;
for
(
double
x
=
0.0
;
x
<=
size
.
width
;
x
+=
interval
/
10.0
)
{
linePaint
.
strokeWidth
=
(
x
%
interval
==
0.0
)
?
1.0
:
(
x
%
(
interval
/
2.0
)
==
0.0
)
?
0.5
:
0.25
;
double
allDivisions
=
(
divisions
*
subDivisions
).
toDouble
();
for
(
double
x
=
0.0
;
x
<=
size
.
width
;
x
+=
interval
/
allDivisions
)
{
linePaint
.
strokeWidth
=
(
x
%
interval
==
0.0
)
?
1.0
:
(
x
%
(
interval
/
subDivisions
)
==
0.0
)
?
0.5
:
0.25
;
canvas
.
drawLine
(
new
Point
(
x
,
0.0
),
new
Point
(
x
,
size
.
height
),
linePaint
);
}
for
(
double
y
=
0.0
;
y
<=
size
.
height
;
y
+=
interval
/
10.0
)
{
linePaint
.
strokeWidth
=
(
y
%
interval
==
0.0
)
?
1.0
:
(
y
%
(
interval
/
2.0
)
==
0.0
)
?
0.5
:
0.25
;
for
(
double
y
=
0.0
;
y
<=
size
.
height
;
y
+=
interval
/
allDivisions
)
{
linePaint
.
strokeWidth
=
(
y
%
interval
==
0.0
)
?
1.0
:
(
y
%
(
interval
/
subDivisions
)
==
0.0
)
?
0.5
:
0.25
;
canvas
.
drawLine
(
new
Point
(
0.0
,
y
),
new
Point
(
size
.
width
,
y
),
linePaint
);
}
}
bool
shouldRepaint
(
_GridPaperPainter
oldPainter
)
{
return
oldPainter
.
color
!=
color
||
oldPainter
.
interval
!=
interval
;
||
oldPainter
.
interval
!=
interval
||
oldPainter
.
divisions
!=
divisions
||
oldPainter
.
subDivisions
!=
subDivisions
;
}
bool
hitTest
(
Point
position
)
=>
false
;
}
/// Draws a rectalinear grid of 1px width lines at the specified color and interval.
...
...
@@ -40,21 +49,28 @@ class _GridPaperPainter extends CustomPainter {
class
GridPaper
extends
StatelessComponent
{
GridPaper
({
Key
key
,
this
.
color
:
const
Color
(
0xFF000000
),
this
.
interval
:
100.0
this
.
color
:
const
Color
(
0x7FC3E8F3
),
this
.
interval
:
100.0
,
this
.
divisions
:
2
,
this
.
subDivisions
:
5
,
this
.
child
})
:
super
(
key:
key
);
final
Color
color
;
final
double
interval
;
final
int
divisions
;
final
int
subDivisions
;
final
Widget
child
;
Widget
build
(
BuildContext
context
)
{
return
new
IgnorePointer
(
child:
new
CustomPaint
(
painter:
new
_GridPaperPainter
(
color:
color
,
interval:
interval
)
)
return
new
CustomPaint
(
foregroundPainter:
new
_GridPaperPainter
(
color:
color
,
interval:
interval
,
divisions:
divisions
,
subDivisions:
subDivisions
),
child:
child
);
}
}
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