how to detect colors from asset in flutter - flutter

i have design like below.
i need to put number widget in the path above and change the color of number based on some logic
provided with path asset like this (it's too long to be shown here)
while thinking how to achieve this, it's impossible to draw path from scratch because it's too complex (is it?),, i think if there's a way to detect list of coordinates of color from path provided above would be helpful, or maybe any other suggestion to achieve this? thank you..
===== edit
the requirement is so similar with map in game development like this
i wonder how they could accurately put the number widget in such position. hardcoding x and y coordinate wouldn't work in terms of responsiveness i think

Related

Custom circle shape reactive model

Trying to reach design from screenshot.
All elements in circle must be able to work with logic which include change color.
Gray and green'ish one elements are disabled and blue'ish is active.
Probably I should use some kind of canvas to get this done, but I am not sure.
Thanks for all response!
Edit:
Very important part of logic. I want to dynamicaly change number of those circular elements.
You would need to use custom painter to achieve this.
You can check out Flutter shape maker! its a tool that can help with drawing this out.

How to bend / crook a Flutter widget? (non-affine widget render transform)

Let's say you have some flutter widget, for example, a TabBar. It is rendered in a rectangular box. I need it to be rendered in an arc so that the text and the underline follow part of a circle (or better still, a bezier curve).
How can that be achieved?
This illustrates what I am trying to achieve - bent TabBar widget:
Please note that in this case, the TabBar bends following and an arc (edge of a circle). This is what I need immediately. However, in the future, I might need bending that follows the edge of an eclipse so a solution that allows it would be preferable.
Also, a solution that works for different widgets is preferred.
IMPORTANT: I do NOT want to clip a curved shape of the widget. The entire area of the widget should stay visible. Instead, I need to bend the content of the widget (=bend its render image).
Apologies for the bold font but without it, people will keep posting answers about how to clip a widget which is trivial in comparison and useless for my problem.
An answer "this is currently not supported by Flutter" from authority (e.g. high reputation in Flutter tag or Flutter a team member) will also be accepted.
One approach: Use a CustomPaint to draw lines/areas/etc freely
You can use a CustomPaint to draw whatever curved lines, areas, etc freely. Therefore, you can definitely achieve your goal - since they are nothing but curved lines, areas with curved edges, rotated texts, etc.
That will take a bit of work, but if you encapsulate it well enough, it is not that hard to implement. For example, draw a Path with filled red area, then draw a white arc, then draw several texts with calculated rotations, etc. Sounds like you can do that within maybe hundreds of lines. If you find difficulty implementing this please comment and I will explain.
Another approach: Hack Canvas such that the call to drawLine becomes indeed calls to drawPath, etc.
You may do the following to allow bend/crook for any widget (and their combination, of course), but this may need a bit of engineering. You can make your own Canvas, say, class BendCanvas implements Canvas {}. The BendCanvas.drawLine, for example, has an implementation of Canvas.drawPath with a curved path cooresponding to the input "line". Similar things hold for drawing rectangles, etc. Then you need to hack Flutter's painting logic, such that it takes in your own BendCanvas instead of the original canvas. This is a universal solution, and it is much more efficient (less code) if you plan to have a lot of bend UI; but if only on bend TabBar, maybe use the first approach.
As for the bend text
In the two approaches above, we have mainly described how you draw the bended rectangle (i.e. draw an arbitrary shaped widget). As for bending text, see: https://github.com/flutter/flutter/issues/16477 , which is still an open issue.
Remarks
It is not possible using transformations. As explained in the comments, you already see Transform does not work - it is affine or perspective, which, by definition, will not bend. Then what about other transforms? After some research there seems to be none. Then, what about looking under the scene. We know Flutter uses Skia under it to draw the UI with high performance, then let us search through Skia. However, it does not provide any transformations like bending. So there seems no use.
P.S. I am not that high reputation in Flutter tag, but I did answer >100 Flutter questions (including some dig-into-source-code style ones), and have developed >100k lines of Flutter code in the production app.

Google Maps GMSGroundOverlay shape of state or country

I would like to place an image on google maps so that it fits the shape of the country or state that it is placed in. I've been looking in to the GMSGroundOverlay as a potential way of accomplishing this, but I can't figure out an easy way to make the overlay take on the shape of a state/country. I was hoping someone might have a suggestion on how to do this?
Thanks in advance

Draw color on country (Mapkit) when it is selected

I want to color the country on selection of the country from a tableView. Can you help me please?
Considering your case, let me give you a heads up that this would require edge detection (so if you haven't done that before, it will take a LONG time), though not lots of it and the following is just one way of approaching this problem:
1) Take out an image context from the map you have.
2) Apply relevant edge detection algorithms in the area you want and use a bright color to differentiate. Note that this way, the inside would not be colored and I can't tell you for sure if that's possible or not.
3) Add that context as a subView on top of the map.
Also take a look at the Quartz 2D programming guide for more tips.
I would suggest something different, though. Keep pre-stored images for all the possibilities and just put a UIImageView with that as its image in front of the map - this will save you a lot of headache.

what libraries, data, algorithms exist for simulation of paint?

I would like to model oil and acrylic paint on a canvas in such a way that I can add a brush stroke to the canvas and have the colours mix.
I don't want to animate this happening, I just want to be able to model the final outcome of a brush stroke on existing paint.
Any suggestions?
The program ArtRage does this very well, I think by looking at that you can get a good idea of how to do this.
Each pixel on the canvas needs to store several attributes related to paint; you can imagine that each pixel will store the amount and color of the paint at that point at the minimum. Painting would be a matter of starting with a set amount of paint on the brush, then as the mouse traces a path to paint, remove some from the brush and add some to the affected pixels.
This is just an overview of the most simple way to do this, there are many more details that will make this look much better (such as shading with a light source to get the 'bump' appearance).
You need to study liquid dynamics. Far too complicated for me, but that might be a good starting point for you. Not sure many people will be able to help you. Good luck