polyline with gradient#452
Conversation
f886cc6 to
0b72df1
Compare
| ..strokeJoin = StrokeJoin.round | ||
| ..blendMode = BlendMode.src; | ||
|
|
||
| if (polylineOpt.gradientColors == null) { |
There was a problem hiding this comment.
need to also handle the isEmpty case
* master: (73 commits) 去掉不要的 Update CHANGELOG.md (fleaflet#511) Proj4dart update (fleaflet#541) Support custom CRS (fleaflet#529) docs(readme): add details about open street map provider (fleaflet#495) Wms support. (fleaflet#500) 0.8.2 release polyline with gradient (fleaflet#452) clean up from fleaflet#487 0.8.1 release Zoombutton plugin (fleaflet#487) dartfmt 0.8.0 release (Flutter 1.12) Use Wrap for marker_anchor sample Polygon culling (fleaflet#449) Tidyup (fleaflet#469) Update build files from fleaflet#478 upgrade flutter version, support Flutter 1.12 Update README.md (fleaflet#465) add opacity option to tile layers (fleaflet#453) ... # Conflicts: # example/android/app/build.gradle # example/android/app/src/debug/AndroidManifest.xml # example/android/app/src/main/AndroidManifest.xml # example/android/app/src/profile/AndroidManifest.xml # example/android/build.gradle # example/android/gradle.properties # example/ios/Runner.xcodeproj/project.pbxproj # example/lib/pages/home.dart # example/web/index.html # lib/flutter_map.dart # lib/src/geo/crs/crs.dart # lib/src/layer/overlay_image_layer.dart # lib/src/layer/tile_layer.dart # lib/src/layer/tile_provider/mbtiles_image_provider.dart # lib/src/map/flutter_map_state.dart # pubspec.yaml
|
@SebWojd Does this pr support using a gradient of only two colors over the whole line, instead of defining a color for every point? What does stop colors do? It is undocumented and not used in the example. |
|
@FilipeLarga This feature support as many colors as you wish. You have to play with gradientColors and colorsStop. I implemented here the standard way how Dart use linear gradient. Here you have a snippet: and the result is: |
|
Hi, i have the same error like in #772 |
|
I'm also facing a similar issue here - suffering from the gradient being referenced to a straight line from first to last points. This makes colouring polylines by arbitrary variable difficult/innacurate when the polyline is not a straight line (or close to one). If the polyline curves back towards the first point it's colour goes "backwards" up the colour gradient. |
|
Hi, I've done this a while ago and I have never coded in dart again but looking into my code it seems I had replace this : gradientColors: _generateGradientColors(colors), by this : and then this : return Polyline( by this return Polyline( Maybe it will help good luck ! |
|
From what I can tell, only workarounds of splitting up the line into smaller lines will work. Maybe a shader could work but I don't think so with the basic shader support Flutter has (it would need flutter_gpu). I've looked into this quite a bit, and actually it doesn't seem to be implemented in many places except in editing software. Even on the web it's not possible. See for example https://github.com/cereallarceny/gradient-path. |

Add possibility to create polyline with gradient color.
closes #486