Author Topic: Square radial gradient  (Read 6001 times)

June 12, 2017, 11:29:10 AM
Read 6001 times

kinezumi89

  • Sr. Newbie

  • Offline
  • **

  • 3
Hello everyone,

I'm trying to make a radial gradient, but I want the gradient's shape to be square rather than circular. My current attempt includes a large solid fill square in the middle, four linear gradient rectangles on the sides, and four radial gradient squares on the corners. However, because the shapes don't perfectly line up, there are either overlaps or white gaps, and because the linear and radial gradients don't appear to change color at the same rate, the gradients don't match, either. I've attached a screenshot to help explain.

Any suggestions would be greatly appreciated!

June 12, 2017, 12:48:52 PM
Reply #1

Lazur

  • IC Mentor

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

  • 1,154
  • Gender
    Male

    Male
Hi.

I think you are going in the right direction, it can be drawn with linear and radial gradients if you adjust the details right.

Here is a collection of some similar images of a bit related topic.

June 13, 2017, 12:00:43 AM
Reply #2

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Welcome to the forum!

Can you show or explain why simply a blurred square won't work (with or without rounded corners)?  I mean, I'm asking kinezumi89.  But if Lazur already knows, can answer (he's good a mind-reading)  :)

It looks like the arrangment of smaller rectangles is going to be hard to do, as you've already found out.

If your goal is a fully opaque gradient, with different flat colors, that's just not possible, that I know of.  For that, I would use a series of concentric (so to speak) squares, maybe with strokes only, varied widths (depending on the particular colors involved, maybe filled squares better?), and some blur.  But I can imagine certain problems with that, not having actually tried it.

But from your example, it looks like you mean a gradient of all the same color, going from opaque to transparent.  So it seems to me that simply blurring a square should work.
  • 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                       

June 13, 2017, 12:39:14 AM
Reply #3

Lazur

  • IC Mentor

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

  • 1,154
  • Gender
    Male

    Male
Attached two examples.

One with gradients -and a fade to 0 alpha filter- and another with a mesh gradient.
Used the visualize path/draw handles extension for the latter.

With 0.92 -svg "thumbnail" is off in the forum-.



Blurring uses % values, you cannot make sure to have the exact amount of gradient fading and also it renders badly.
As with the first example it also needs rasterization in pdf-s.
« Last Edit: June 13, 2017, 02:53:09 AM by Lazur »

June 13, 2017, 02:26:42 AM
Reply #4

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
No, I think the thumbnail is showing ok in the forum.  It's showing what's inside the page border.  There is a size limit for displaying attachments.  If they are larger than that size, it only shows a thumbnail, and you have to click on it, to see the full size.  Although I think that's for raster attachments.  SVGs are handled differently somehow.  I'd have to dig into the configs, to rattle my memory, haha.  But I think SVGs don't generate a thumbnail.  I think the page border determines what's showing for SVGs.

I don't understand what that b/w raster is showing.  But I did a test with a blurred square.  Now I see what you mean.  You can't adjust any gradient stops, or move where the transparency is more or less.  The blur only makes the same kind of "gradient" every time, it's the same.

Well your example is a filter, not a gradient.  Unless you mean that you created that filter using the mesh?  Hhm, but when I tried to apply that filter to a square, it doesn't work.  It's just a partially transparent square.  No gradient effect.  Oh, I see.  The filter is not what's providing the blur/gradient effect.  It's just proving color.  Now I see what you did!

Thanks for explaining  :)
  • 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                       

June 13, 2017, 02:55:33 AM
Reply #5

Lazur

  • IC Mentor

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

  • 1,154
  • Gender
    Male

    Male
Oh just realised somehow it was an earlier save :(.
File updated.


Now with a black backdrop it seems the gradient mesh doesn't match exactly at the corners, wondering why.

June 13, 2017, 03:21:55 AM
Reply #6

Lazur

  • IC Mentor

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

  • 1,154
  • Gender
    Male

    Male
Ok, here is another gradient mesh, which renders much better.

General commetns on drawing it with linear and radial gradients:

use the snapping tool to snap the gradient handles to the path nodes,
set height/width/node position precisely so that your image makes up a square and the corners right.

If you want the gradient to have transparency, AND avoid the anti-aliasing rendering gap issue, the only way of achieving that is by using filters which is a bit of a bummer.
For filling up the gaps I used overlapping, hence the corners are not quarter sectors and the sides are not rectangles either. Check it in outlines only rendering mode.

Once you draw a black to white gradient with 0 transparency, with the filter you can map in other colours, just as in the file.
Only problem with that is it's limited to 256 steps since that's the whole luminance range used for the input -a colormatrix filter primitive is used in luminance to alpha mode-.
Would need some tricks avoiding banding with more than 2 colour fades.
And in general rendering the filter may be a bit off since 0.91 and gradients may not be 100% accurate.
(An "extreme" example here. Very small steps in a gradient are not rendered with a smooth fade that aligns fine.)

June 13, 2017, 08:24:47 AM
Reply #7

kinezumi89

  • Sr. Newbie

  • Offline
  • **

  • 3
Thank you both for the replies!

(As an amusing side-note, I thought about using my first name as a username, but given that my name is "brynne", I thought that might get confusing, since a "brynn" seems to post quite frequently on the forums...)

Your understanding of my goal is pretty much spot on. This clipart from Lazur's first post (https://openclipart.org/detail/219842/black-feathered-border-in-fullhd-3) is what I want, but with the colors inverted (dark in the middle, light on the outside). I tried to download and modify the colors, but I think since I'm using a newer version, it just merged all the layers into a single uneditable figure.

It doesn't have to be transparent or opaque specifically, either is fine as long as the end visual effect is the same. I did try blurring, but I had a harder time getting the different squares/rectangles to line up since I couldn't adjust the ranges, as was discussed. I did use the "snap to corners" feature, but I'm very new to Inkscape, so I'm probably not utilizing all the options to make everything precise as I should be (hence why even "snapping" didn't result in the edges aligned).

I've not used meshes or filters at all, so I can look into those features.

Thank you both again for your help!

June 13, 2017, 09:03:03 AM
Reply #8

Lazur

  • IC Mentor

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

  • 1,154
  • Gender
    Male

    Male
Oh ok, thought you had some experience already with inkscape.

Attaching a screen capture of a similar drawing in the making.
Not exactly matches the corners of the previous file but renders pretty much the same.

(If you remove the filter in the previous files it's also black and white.)

Cheers!

June 13, 2017, 10:32:09 AM
Reply #9

kinezumi89

  • Sr. Newbie

  • Offline
  • **

  • 3
Oh ok, thought you had some experience already with inkscape.

Attaching a screen capture of a similar drawing in the making.
Not exactly matches the corners of the previous file but renders pretty much the same.

(If you remove the filter in the previous files it's also black and white.)

Cheers!

Wow, thank you so much for the tutorial, that was very helpful. (I'm happy to see there's a feature to swap the gradient colors....I've been doing that manually thus far.)

I was able to follow everything until the end when you defined the diagonal lines. Can you briefly explain what you're doing there? That seems to be the key step I'm missing to avoid the gaps in the corners.

June 13, 2017, 10:49:47 AM
Reply #10

Lazur

  • IC Mentor

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

  • 1,154
  • Gender
    Male

    Male
Pulled off guide lines from the rulers around the page with the node tool.
You can pull horizontal/vertical/diagonal guide lines as well, and rotate them while holding Shift.
Can switch off their rendering by clicking on the rulers; can delete them by hovering over the cursor while holding Del or by pulling them back to the rulers. Also there is an option in the edit menu to delete all guides.

June 26, 2017, 05:18:16 PM
Reply #11

Lazur

  • IC Mentor

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

  • 1,154
  • Gender
    Male

    Male
Note to self
-I should look more into this topic when dealing with gradient meshes.
And/or make a bug report of a"cornering issue". Although coons is more straightforward with the rendering.