Author Topic: making curved gradient with mesh for animation  (Read 5298 times)

February 02, 2017, 02:21:25 PM
Read 5298 times

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Hi Friends,
I've been waiting for the gradient mesh, ever since I tried to animate my old avatar (the endless knot) so many years ago (something like 6 or 7), and discovered I couldn't bend the gradient.  So now I've picked that up again, and wanted to discuss if there's a better way than my first attempt.

Here's one of the 9 pieces, and you can see what I did with the mesh.  First, I added extra path nodes evenly spaced, so I could snap the mesh nodes to them.  I started at the top, imagining the mesh as a ribbon.  At the corners, I sort of mitered the ribbon.  So on the outside of the corners, the nodes are placed one by one.  But the inner side of the corners, each corner has 3 mesh nodes on top of each other.

As the nodes go along the outside of the corners, the color and transparency changes in a regular way.  I think each step the opacity changes by 30%.  About halfway along, I also changed the lightness, because the natural change of opacity, without changing the lightness, looked a little odd.  The green color seemed to get grayer as it became more transparent.  So somewhere in the middle, the lightness went up some.  It still seems to get grayish on the end, and I might even change the hue towards the end, more towards yellow.

It didn't work so well for the inner nodes to match the outer ones, because 2 steps are combined into one step.  There was a sudden change in the middle of the corner which looked unnatural.  So all 3 corner mesh nodes are the same lightness, with only the opacity changing.  I'm not sure if that's exactly proper.  Maybe the opacity should hold the same as well??

Then for that middle column of mesh nodes....I guess they should be the same as the outer nodes for color and opacity, at the corners.  But I'm not sure.

But what I'm really not that sure about is whether mitering is the best approach.  I wonder if it would be better not to have the 3 mesh nodes on top of each other, and instead, just have them spaced evenly between the nodes before and after the corner.

Or, I wonder if there would be some way to use a conical gradient, somehow??  Would that be better?  More or less realistic?  The center of it would not be seen.  The center of it would be in the center of the corners, about where that little black circle is, and I would clip it with the outline of the knot piece.  But it seems like the conical gradient wouldn't work because those corners are 90° angles there, rather than curves.

What do you all think?  Do you have any other ideas?

Of course, whenever I finally get to the animation part, I'll export PNGs, so there won't be any transparency in the gradients.  It will just go green to white.  And then iirc, the PNGs get converted to GIFs in GIMP.

Use SMIL, you say?  Or maybe some javascript or ECMAscript?  Hhm....doe SMIL support gradient mesh, or any kind of gradient?  I'm guessing not.  But I wonder about javascript?  Well, that's still for some day in the far future!

OMg, I just thought of a way I might have been able to animate this a long time ago!  I could have solid color circle move its way along through the knot, one position at a time.  Wouldn't be as cool as a trailing light or flame or smoke which the gradient implies.  Well, I could still do that though.  Maybe even using SMIL!
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

February 02, 2017, 03:27:52 PM
Reply #1

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Hi.

Gradient meshes are not part of the current svg specs, regular browsers won't support rendering an svg animation with them.

At the mesh tool you can choose conic gradient, where one "side" of the mesh is snapped to the same coordinate.

Such linear segments in your example's corners can lead to a conical look -colour steps going through one point- but the transition "speed" would be slightly off compared to the rest of the mesh. Nothing noticeable with the present colour setup.

The innermost nodes of that mesh are unnecessary. For drawing the same details you could get rid of them.

Doubt animating mesh nodes would be a feature planned at this stage.
Once I tried animating an object to rotate it came out messed up of transformations that I couldn't get rid of.
So instead of animating by translating-transforming objects, my guess it is easier to animate something like an attribute.
Haven't tried that myself.

Animating colour steps of a gradient attribute doesn't sound anything easier. Like, if you proceed to variate a step's colour in time, how could you ensure an intermediate step would look exactly as the gradient shifted?
Greyscale may work.
But then, it would be easier adding a gradient map filter atop?

Speaking of filtering maybe an easiest animation would be adding a hue rotate effect where the hue changes with time in the animation.


These are just theoretical.
What I saw in practice was a smil animation here.
If the object moved along the path was a dot with a gradient fill, by clipping it, something similar as a "fluid gradient animation" could be achieved.

February 02, 2017, 04:31:57 PM
Reply #2

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Modified the previously linked example a bit -svg source

And here as well.
« Last Edit: February 02, 2017, 05:12:30 PM by Lazur »

February 03, 2017, 04:56:08 AM
Reply #3

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
So far could only make this out from the racetrack:



If there were alot of diamond shapes animated with even shifts in the starting time, all coloured in a different shade, stacked atop eachother, and
if those animated objects were cloned and clones clipped here and there, a gradient look could be achieved (if the renderig didn't lag so much).

February 03, 2017, 08:22:42 PM
Reply #4

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Such linear segments in your example's corners can lead to a conical look -colour steps going through one point- but the transition "speed" would be slightly off compared to the rest of the mesh.

Yes, that's exactly the unnatural look I saw at the corner.  But making all 3 nodes the same seems to have fixed it.  We'll see what happens as the work goes along.  There will be places where the color is darker and less transparent at the corners, than in this one.  So I'm not sure if the same routine will work for every "frame".

The innermost nodes of that mesh are unnecessary. For drawing the same details you could get rid of them.

Yeah, you're probably right about that.  Unfortunately, there's no way to delete mesh nodes!  I'll just have to make another.

Doubt animating mesh nodes would be a feature planned at this stage.
Once I tried animating an object to rotate it came out messed up of transformations that I couldn't get rid of.
So instead of animating by translating-transforming objects, my guess it is easier to animate something like an attribute.
Haven't tried that myself.

Animating colour steps of a gradient attribute doesn't sound anything easier. Like, if you proceed to variate a step's colour in time, how could you ensure an intermediate step would look exactly as the gradient shifted?
Greyscale may work.
But then, it would be easier adding a gradient map filter atop?

Oh no, it's nothing as fancy as all that.  I'm just thinking of simple GIF "frames" animation.  Although I might try my 2nd idea first.  And I might even try to use SMIL!  I know that browser support is sketchy.  But it will be another example on the web, and hoping to prevent all browsers from dropping it (besides just Chrome).

Oh, I just noticed you already did my idea of moving a circle or something along through the knot!  Is that using SMIL?  You just did it today?  Well that's depressing - will probably take me weeks to figure out, if not months. 

Uh-oh......red car just ran over top of the yellow car.  Not fast enough for red, I guess -- how rude!

Anyway, thanks frot the info!
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

February 13, 2017, 05:36:19 PM
Reply #5

k-drive

  • Jr. Member

  • Offline
  • ***

  • 30
Brynn:

Since you have been using Gradient Meshes, perhaps you can help me get them started up.

I have been trying to activate Gradient Meshes in the Edit - Preferences window.
I have been following instructions I found online.

1. After opening the Preferences window, you search for "toolmesh".
2. Under the "Context" section, there is a "Mesh".
3. I click on the Shortcut column, and I get the text "New Accelerator...".

At this point I am supposed to enter some new keyboard shortcut combination.
I have tried Alt + m and others. But, they never appear where the "New Accelerator..." text appears.

So, is there something I am missing?
I am using version 92. From what I've read, this feature should be available.

Is there a way to just edit the XML file at this path?
...\InkscapePortable\App\Inkscape\share\keys\Inkscape.xml


Ken

February 13, 2017, 10:39:15 PM
Reply #6

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Yes, I think that is not very clear.  What the heck is an accelerator?!!  What's wrong with "type the new key here" or something very literal!

When you see "New Accelerator....", just press the key that you want to assign.  I don't remember if I also pressed the Enter key or not.  But afterwards, it is showing the new key that I chose where it used to say "New Accelerator....".  For my Windows theme, I have to deselect the Mesh tool to actually see the new key there.

But yes, in version 0.92, you should have the new Gradient Mesh tool right in the tool menu.  It's 3rd from the bottom, and right below the Gradient tool.  This is the icon/button   :mgr:

I think the old way of changing key binding is to edit that file, and as far as I know it still should work.  Although I'm not positive.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

February 16, 2017, 12:07:11 PM
Reply #7

k-drive

  • Jr. Member

  • Offline
  • ***

  • 30
Brynn:

Well, I am red-faced. Geez. I didn't even think to look for that icon. I guess I don't have to mess with the XML file or preferences.

Thanks. I wouldn't have thought to look for that icon without asking you. I am just not familiar with the Inkscape layout of elements like you.

Have a good day! I am going to mess around with that new little gradient toy/tool!

Ken


p.s.

Just a note from being in software development from both a programmer's point of view and a tester's point of view: Sometimes you put stuff in a program using the language that you use every day that makes sense to you. That is why testers are needed who can look at something (design, wording, workflow, etc.) and try things out before they go out to end users. The company I used to work for got the end users involved early in the development process so they could look at something and ask questions like "What's wrong with "type the new key here" or something very literal!"


February 16, 2017, 04:08:20 PM
Reply #8

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Oh, no worries.  I was a newbie once myself  :)

Of course proprietary programs are developed in a very different way from open source.  But I think some developers would like to do some user testing.  Especially Martin, aka doctormo.  We're just discussing creating a new Advocacy Team, and I wonder if user testing would be something such a team could do?  I mean, testing is a form of advocacy, sort of, although it has other purposes too.

And I think there will be some work done on UX, and as far as I understand, mostly on dialogs and various messages, in th near future.  And there has been some talk of user testing for that.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

August 16, 2017, 03:39:03 PM
Reply #9

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Think, simplify, repeat.

Will have to redo this nearly from scratch to overcome chrome's rendering issue.
Anyway, here goes nothing:

August 17, 2017, 08:16:45 AM
Reply #10

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male

August 17, 2017, 05:15:42 PM
Reply #11

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male

August 17, 2017, 08:16:48 PM
Reply #12

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Wow, amazing!

You used filters though, right?  Instead of gradient mesh?

The last one, with only blue and white, seems to be throbbing.

Edit
Not throbbing on Inkscape website.
« Last Edit: August 17, 2017, 08:52:24 PM by brynn »
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

August 18, 2017, 03:39:26 AM
Reply #13

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Thank's!
Used linear gradients as a base -the unfiltered version looks similar to this.

If you zoom out the svg in the browser, the animation is more fluid (the gallery also scales it down).