Comments (7)
@huycozy that's just one example of what I feel is missing. Another would be accessing the sets of styled "runs" of text from the Paragraph
class passed to drawParagraph
.
The basic problem statement is, the classes passed to the various draw*
commands in the Canvas
class don't seem like they were designed to be useful outside of their native implementations. There's no particular reason for this that I can think of except that it just hasn't been done yet.
from flutter.
the passed Path does not seem to support actually accessing the history of the commands (lineTo, moveTo, etc) used to define the path.
Similarly the Paragraph passed to drawParagraph doesn't expose the actual text itself (that I can tell), which I would need.
Could you please be more specific by giving an example of these expectations?
from flutter.
@huycozy sure. For example, a Widget's painter might do something like this:
final path = Path();
path.moveTo(0, 0);
path.lineTo(5, 5);
canvas.drawPath(path, paint);
In my custom Canvas implementation, I need to know what commands were called (in this case, a moveTo
followed by a lineTo
). So I implement drawPath
:
class MyCanvas implements Canvas {
@override
void drawPath(Path path, Paint paint) {
// `path` was called with `moveTo(0, 0)` and `lineTo(5, 5)`, but I can't extract that information
// I would like to do something like this (`getCommands` doesn't exist)
for (final command in path.getCommands()) {
// do something with command
switch (command) {
case MoveTo(:x, :y): {
// build svg
}
}
}
}
}
from flutter.
Thanks for clarifying it. Marking this as a feature request.
from flutter.
We're not going to add the functionality to introspect over all canvas operations. I would suggest writing shim classes that intercept the path/canvas ops you care about and then implementing your own recorder in Dart.
from flutter.
@jonahwilliams I'm a bit confused because your suggestion is exactly what I'm trying to do but can't because of how it works under the hood. I'm trying to write my own canvas recorder. As far as I know, I can't override how the dart Path
class in dart:ui
works, so I can't do anything about how it gets instantiated/written to. But it's genuinely surprising to me that, when I implement my own drawPath
class on my custom canvas, I get a Path
object that's practically useless. I can't "draw" it because it exposes none of the actual path information. It's all obfuscated in the native implementation.
from flutter.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v
and a minimal reproduction of the issue.
from flutter.
Related Issues (20)
- [et]: make rbe builds against wrong macos sdk an error
- rbe: no cache hits when building `ios_profile` HOT 2
- mac-29 lost external connection phone device. HOT 1
- mac-26 lost external connection phone device. HOT 1
- [image_picker] cannot select images downloaded by Safari on iOS HOT 4
- [video_player_avfoundation] Video FPS is SLOW from version 2.5.7+ HOT 2
- Username or Picture not available when login in web with signInSilently HOT 2
- DropdownMenu allow setting keyboard type
- SelectionArea intermittently interferes with listview scrolling (and possibly other scrolls) HOT 2
- Linux Desktop App: Memory usage while opening links HOT 2
- [Add-to-App] [Android] Flutter Engine on Android still active after FlutterActivity get disposed HOT 2
- iOS crash when converting `ui.Image` to PNG: image_encoding.cc: Could not convert raster image to PNG HOT 1
- [material/menu_anchor.dart][web] Menu anchor panel is not focused on web. HOT 2
- Migrate flutter_tool fully away from `.packages`
- `Shadow` Gradient in TextField HOT 2
- [material/menu_anchor.dart] Switching between hover focus and directional focus leads to incorrect focus order. HOT 1
- [material/menu_anchor.dart] Hovering over menu item affects scrolling and focus order. HOT 1
- [url_launcher] `Uri` APIs should throw `ArgumentError` when `hasScheme` is false HOT 8
- Flutter web cannot run on chrome HOT 2
- [video_player] Does not work on webOS (LG) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter.