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
4df24abb
Commit
4df24abb
authored
Mar 31, 2016
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3016 from vlidholt/linedrawing
Initial version of Fancy line drawer demo
parents
243960d7
a1212dbc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
2 deletions
+88
-2
flutter.yaml
examples/material_gallery/flutter.yaml
+1
-0
drawing_demo.dart
examples/material_gallery/lib/demo/drawing_demo.dart
+83
-0
home.dart
examples/material_gallery/lib/gallery/home.dart
+2
-0
pubspec.yaml
examples/material_gallery/pubspec.yaml
+1
-1
sprite_box.dart
packages/flutter_sprites/lib/src/sprite_box.dart
+1
-1
No files found.
examples/material_gallery/flutter.yaml
View file @
4df24abb
...
...
@@ -24,3 +24,4 @@ assets:
-
packages/flutter_gallery_assets/jumpingjack.json
-
packages/flutter_gallery_assets/jumpingjack.png
-
packages/flutter_gallery_assets/grain.png
-
packages/flutter_gallery_assets/fancylines.png
examples/material_gallery/lib/demo/drawing_demo.dart
0 → 100644
View file @
4df24abb
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_sprites/flutter_sprites.dart'
;
class
DrawingDemo
extends
StatefulWidget
{
@override
_DrawingDemoState
createState
()
=>
new
_DrawingDemoState
();
}
class
_DrawingDemoState
extends
State
<
DrawingDemo
>
{
_LineDrawingNode
_rootNode
;
ImageMap
_images
;
Future
<
Null
>
_loadAssets
(
AssetBundle
bundle
)
async
{
_images
=
new
ImageMap
(
bundle
);
await
_images
.
load
(<
String
>[
'packages/flutter_gallery_assets/fancylines.png'
]);
}
@override
void
initState
()
{
super
.
initState
();
_loadAssets
(
DefaultAssetBundle
.
of
(
context
)).
then
((
_
)
{
setState
(()
{
_rootNode
=
new
_LineDrawingNode
(
_images
);
});
});
}
@override
Widget
build
(
BuildContext
context
)
{
Widget
body
;
if
(
_rootNode
==
null
)
{
body
=
new
Center
(
child:
new
CircularProgressIndicator
()
);
}
else
{
body
=
new
SpriteWidget
(
_rootNode
,
SpriteBoxTransformMode
.
nativePoints
);
}
return
new
Scaffold
(
appBar:
new
AppBar
(
title:
new
Text
(
"Fancy Lines"
)
),
body:
body
);
}
}
class
_LineDrawingNode
extends
NodeWithSize
{
_LineDrawingNode
(
this
.
_images
)
:
super
(
const
Size
(
1024.0
,
1024.0
))
{
userInteractionEnabled
=
true
;
}
final
ImageMap
_images
;
EffectLine
_currentLine
;
@override
bool
handleEvent
(
SpriteBoxEvent
event
)
{
if
(
event
.
type
==
PointerDownEvent
)
{
_currentLine
=
new
EffectLine
(
texture:
new
Texture
(
_images
[
'packages/flutter_gallery_assets/fancylines.png'
]),
colorSequence:
new
ColorSequence
.
fromStartAndEndColor
(
Colors
.
purple
[
500
],
Colors
.
purple
[
600
]),
fadeAfterDelay:
3.0
,
fadeDuration:
1.0
);
_currentLine
.
addPoint
(
event
.
boxPosition
);
addChild
(
_currentLine
);
}
else
if
(
event
.
type
==
PointerMoveEvent
)
{
_currentLine
.
addPoint
(
event
.
boxPosition
);
}
return
true
;
}
}
examples/material_gallery/lib/gallery/home.dart
View file @
4df24abb
...
...
@@ -16,6 +16,7 @@ import '../demo/chip_demo.dart';
import
'../demo/date_picker_demo.dart'
;
import
'../demo/dialog_demo.dart'
;
import
'../demo/drop_down_demo.dart'
;
import
'../demo/drawing_demo.dart'
;
import
'../demo/fitness_demo.dart'
;
import
'../demo/flexible_space_demo.dart'
;
import
'../demo/grid_list_demo.dart'
;
...
...
@@ -80,6 +81,7 @@ class GalleryHomeState extends State<GalleryHome> {
children:
<
Widget
>[
new
GalleryItem
(
title:
"Weather"
,
builder:
()
=>
new
WeatherDemo
()),
new
GalleryItem
(
title:
"Fitness"
,
builder:
()
=>
new
FitnessDemo
()),
new
GalleryItem
(
title:
"Fancy Lines"
,
builder:
()
=>
new
DrawingDemo
()),
]
),
new
TwoLevelSublist
(
...
...
examples/material_gallery/pubspec.yaml
View file @
4df24abb
...
...
@@ -7,4 +7,4 @@ dependencies:
path
:
../../packages/flutter
flutter_sprites
:
path
:
../../packages/flutter_sprites
flutter_gallery_assets
:
'
0.0.1
2
'
flutter_gallery_assets
:
'
0.0.1
3
'
packages/flutter_sprites/lib/src/sprite_box.dart
View file @
4df24abb
...
...
@@ -228,7 +228,7 @@ class SpriteBox extends RenderBox {
// Check if this event should be dispatched
if
(
node
.
handleMultiplePointers
||
event
.
pointer
==
node
.
_handlingPointer
)
{
// Dispatch event
bool
consumedEvent
=
node
.
handleEvent
(
new
SpriteBoxEvent
(
event
.
position
,
event
.
runtimeType
,
event
.
pointer
));
bool
consumedEvent
=
node
.
handleEvent
(
new
SpriteBoxEvent
(
globalToLocal
(
event
.
position
)
,
event
.
runtimeType
,
event
.
pointer
));
if
(
consumedEvent
==
null
||
consumedEvent
)
break
;
}
...
...
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