How to achieve Custom Gradient Shapes/Patterns in Flutter - user-interface

Out of the box we get LinearGradient, RadialGradient and SweepGradient. What I would like to do is something similar to the shown image below. Let's say we draw a custom shape with CustomPainter. When this customShapeGradient is applied on it, the gradient should start from the border of the custom shape and go towards the center. I realize that this might introduce wierd effects since our shape will mostly be not symmetric and a "border to center" approach is not as easy as a "center to border" approach(like the 3 out of the box methods). Here it will be the developer's responsibility to make sure the gradient fill do not overlap with itself, meaning it won't go all the way to the center.
Here is an image I found for an Elliptic shape which most closely describe what I want. Let's say our shape is the line with the yellow color. And I want to achieve the gradient which fills inside.
This is a similar image too:
The two examples I have provided are for ellipses however my question is for any type of shape that is created by a CustomPainter.
I am almost sure this is possible since a shadow(gradient in nature) is basically the inverse of this. We can apply a shadow to a CustomPainter shape. The only difference will be that the shadow will grow towards inside of the shape(maybe like a inner shadow).

Related

I need an algorithm to indentify created shapes on the ground and fill them(change the colors of the blocks within)

I am building a game where 8 players are spawned in an arena and each has their own color and they are suppose to roam around the arena(the blocks they walk on change to the player's color) with the purpose to fill as much of the arena's ground with their color.
When they create a shape they inside of the shape is also supposed to change to their color but I can't think of a way to actually implement this so I would really appreciate some help.
I broke down the process of implementing this into 2 steps:
Identify when a shape is created
Find all the blocks that are inside the perimeter of that shape an fill them
An example for shape that I would like to fill(The blue blocks are supposed to be the perimeter of the shape

Building custom Shapes in Konva

I've been asked to build something similar to this so that customers can draw basics shapes of kitchen tops. Similar to that in the image below but also have dimensions.
It looks like konva has support for basic shapes like rectangle and circle etc and it also includes a transformer which allows for resizing. However, I think if I want to build a custom shape like the one in green and have individual sizing i.e. resize each individual line. I am going to have to build something myself.
I was hoping someone could point me in the right direction. I have seen an example where someone has used a "line" class which takes a series of points and then sets the attribute to closed which fills in the shape. Obviously I would need to extend this to allow the custom resizing. However, Im not sure this is the correct path to head down?
Any suggestions?
.
How about using rectangles and having an option to snap them together. It should be fairly simple to do the edge detection and snapping. Then show the result as a Konva.Line around the perimeter.
Then you can show all the control handles for the rectangles except those on the sides where another Rect has joined.

Is there any way to implement this beautiful image effect?

Recently I found an amazing APP called Photo Lab,and I'm curious about one effect called Paper Rose.In the pictures below,one is the original picture,the other is the effected picture.My question is what kind of algorithm can do this effect,and it would be better if you can show me some code or demo.Thanks in advance!
enter image description here
enter image description here
I am afraid that this is not just an algorithm, but a complex piece of software.
The most difficult part is to model the shape of the rose. The petals are probably a meshed surface. It is not so difficult to give them a curved shape, but the hard issue is to group them in such a way that they do not intersect.
It is not quite impossible that this can be achieved by first putting them in a flat geometry where you can master intersections, then to wrap it around an axis with a king of polar transform. But I don't really believe in that. I rather think that they have a collision-avoiding geometric modeller.
The next steps, which are more classical, are to texture-map the pictures onto the petals and to perform the realistic rendering of the whole scene.
But there's another option, which I'll call the "poor man's rendering".
You can start from a real picture of a paper rose, where the petals have an empty black, thick frame. Then on the picture, you detect (either in some automated way or just by hand) points that correspond to a regular grid on the flattened paper.
As the petals are not wholly visible, the hidden parts must be clipped out from the mesh, possibly by using a polygonal fence.
Now you can take any picture, fit it over the undistorted mesh, clip out the hidden areas and warp to the distorted position. Then by compositing tricks, you will give it a natural shaded appearance on the rose.
Note: the process is eased by drawing a complet grid inside the frame. Anyway, you will need to somehow erase it before doing the compositing, in order to retrieve just the shading information.
I would tend to believe that the second approach was used here, as I see a few mapping anomalies along some edges, which would not arise on a fully synthetic scene.
In any case, hard work.

Get bounding box / extent of visible map tiles in d3

Let's say I have a standard tiled map like this: http://bl.ocks.org/mbostock/4132797
How can I get the bounding box coordinates of the visible map?
In other words, how can I say exactly the extent of the map shown at any given time. I understand this as a bounding box but also as an extent.
Thank you.
I was able to find answers to similar but specific questions but am leaving this up in case someone is searching for the general case.
From Elijah Meeks's answer:
To find the bounding box of the visual area of your map on screen,
simply use the projection.invert() function and feed it the top-left
and bottom-right corners of your SVG. If you have a 500x500 SVG, then
that looks like this:
projection.invert([0,0]) projection.invert([500,500]) This is a
bounding box of your screen, in lat-long (or whatever coordinate
system you're using).
After that, you can get the bounds of your features and test to see if
they are fully-contained or intersecting or have their centroid within
those bounds. I'm not going to explain how to do that here, because
that's a different question with many different answers depending on
which definition of "within these bounds" you decide on.
So, plug in the width and heightof the visible area into the projection generator. Voila, you have the box.

Outline rendering of transparent cylinders

I am trying to render cylinders for a CAD-like project. As multiple of these will be nested in each other, I am looking to display them similar to this: http://mrwadeturner.pbworks.com/f/1305815353/FC_Cylinder_41702_lg.gif
i.e. I want the outline and the base and bottom circles traced out and the rest should be (semi-)transparent.
Note that this is different from using regular wireframe settings, because that will trace out every face of the sides of the cylinder. The other approach I found - rendering the object twice, once in color and slightly enlarged and once it "regular" version on top - unfortunately won't work either, since multiple cylinders will be nested.
I think this should be possible with custom vertex and fragment shaders, but I am not very proficient in using them. What would be the best way of achieving this effect?
Thanks a lot!
Sound like you just need to apply various textures to the same faces. Next you want to try to create custom texture that is going to be a simple transparent .png image with solid dashed border. Then you'll have to set side:THREE.FrontSide and side:THREE.BackSide to your textures and play around with depthTest.
Another approach is to use lines that you age going to create vertex-by-vertex. See this example for custom line implementation: Hilbert curve and Shapes generation
Hope that helps!

Resources