apply random colour from palette to objects
-
- Posts: 40
- Joined: Tue Jul 31, 2018 4:47 am
apply random colour from palette to objects
Hello everybody, first post
I have created a canvas full of stars and want to randomly apply three colours from a palette (red, white and blue) to each of the stars.
Doing it manually is a lot of work because i have so many stars, is there a script that does this ?
I have created a canvas full of stars and want to randomly apply three colours from a palette (red, white and blue) to each of the stars.
Doing it manually is a lot of work because i have so many stars, is there a script that does this ?
Re: apply random colour from palette to objects
Hi.
Can't think of a script/current extension at hand (however I'm using an outdated version...) that would do exactly as per se.
If it's for a raster export as a final output format and not a printable pdf etc., I'd use the tweak tool to colour the stars to random luminance levels, then use a colormap filter to map 3 colours to the full luminance range.
That filter can be generated with an extension, so the goal can be achieved in minutes.
If it wasn't for existing stars, you could have used the spray tool with clones, tracing the colours beneath them.
And/or use cloning, random alignment through the align and distribute panel etc.
Can't think of a script/current extension at hand (however I'm using an outdated version...) that would do exactly as per se.
If it's for a raster export as a final output format and not a printable pdf etc., I'd use the tweak tool to colour the stars to random luminance levels, then use a colormap filter to map 3 colours to the full luminance range.
That filter can be generated with an extension, so the goal can be achieved in minutes.
If it wasn't for existing stars, you could have used the spray tool with clones, tracing the colours beneath them.
And/or use cloning, random alignment through the align and distribute panel etc.
Re: apply random colour from palette to objects
You could just select one third of your stars, give them a color, repeat for the other two thirds, then distribute the stars randomly (if it doesn't matter where exactly they are).
Else the touch selection might be useful. Hold Alt and drag mouse to select objects that are touched by mouse.
Else the touch selection might be useful. Hold Alt and drag mouse to select objects that are touched by mouse.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
-
- Posts: 40
- Joined: Tue Jul 31, 2018 4:47 am
Re: apply random colour from palette to objects
Lazur wrote:If it's for a raster export as a final output format and not a printable pdf etc., I'd use the tweak tool to colour the stars to random luminance levels, then use a colormap filter to map 3 colours to the full luminance range.
That filter can be generated with an extension, so the goal can be achieved in minutes.
Dear Lazur,
what is this colormap filter that can be generated with an extension ?
Can you give me the steps please.
Moini wrote:You could just select one third of your stars, give them a color, repeat for the other two thirds, then distribute the stars randomly (if it doesn't matter where exactly they are).
Dear Moini,
is there a script to randomly select objects ? Like deselect 66% of my selected objects ?
Doing it by hand is too much work, and hard to get at the right amount.
Last edited by JuliaFlowers2 on Tue Jul 31, 2018 2:58 pm, edited 1 time in total.
Re: apply random colour from palette to objects
Hi.
This is something similar how "it should work": https://youtu.be/ihv8dzc9slo.
But actually had issues when applying the extension, maybe sharex-the screen capturer used- interfered with the window.
It is supposed to generate a custom filter from a gradient, which then you could apply on any selected objects -including raster images too. Similr in style to the "hope" poster.
Surprisingly the filter editor shown it wasn't applied to any object but everything was rendered with it. My guessing somehow the whole document's parent layer got the filter, somewhere hidden in the defs section.
This is something similar how "it should work": https://youtu.be/ihv8dzc9slo.
But actually had issues when applying the extension, maybe sharex-the screen capturer used- interfered with the window.
It is supposed to generate a custom filter from a gradient, which then you could apply on any selected objects -including raster images too. Similr in style to the "hope" poster.
Surprisingly the filter editor shown it wasn't applied to any object but everything was rendered with it. My guessing somehow the whole document's parent layer got the filter, somewhere hidden in the defs section.
-
- Posts: 40
- Joined: Tue Jul 31, 2018 4:47 am
Re: apply random colour from palette to objects
Thank you for making the video for me.
I dont have a Modify Colour in my Extensions list. My Inkscape is version 0.92.3.
Is this something i can download ?
Re: apply random colour from palette to objects
Mea culpa. Thought it made it onto the branch. Extension was added by Suv, not sure about a download link.
However the filter is quite simple, will upload one in a minute.
However the filter is quite simple, will upload one in a minute.
Re: apply random colour from palette to objects
Here is that filter.
You can edit the colours in the filter editor by the flood fill primitives.
You can edit the colours in the filter editor by the flood fill primitives.
- Attachments
-
- redwhiteblue.svg
- (5.51 KiB) Downloaded 222 times
-
- Posts: 40
- Joined: Tue Jul 31, 2018 4:47 am
Re: apply random colour from palette to objects
Lazur wrote:Here is that filter.
You can edit the colours in the filter editor by the flood fill primitives.
Thank you. I was able to use your filter for my stars.
There are two problems with this method:
1.) the stars form big colour clumps (its not random enough)
2.) there are strange glitches where two colours seemingly overlap. what can be done about that ?
EDIT: why dont my images show up ?
Re: apply random colour from palette to objects
@JuliaFlowers2
If the current arrangement of stars doesn't matter (i.e. it's okay to re-arrange, as it's random anyway), then you just need to drag a selection box with the mouse to change the color for one third.
The re-arrangement can be done by using the random functionality of the Align-and-Distribute-Dialog.
I don't know of any functionality or extension that randomly selects/deselects objects (this is, in part, due to the fact that in versions up to and including 0.92.3, after applying an extension, everything is deselected - will change with the next version, where selection is kept).
If the current arrangement of stars doesn't matter (i.e. it's okay to re-arrange, as it's random anyway), then you just need to drag a selection box with the mouse to change the color for one third.
The re-arrangement can be done by using the random functionality of the Align-and-Distribute-Dialog.
I don't know of any functionality or extension that randomly selects/deselects objects (this is, in part, due to the fact that in versions up to and including 0.92.3, after applying an extension, everything is deselected - will change with the next version, where selection is kept).
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Re: apply random colour from palette to objects
Here's another approach: use the Objects dialog (Object ‣ Objects…).
If your stars are randomly distributed then just selecting the first 1/3 of them as listed should get you what you want. Just click the first one, then hold Shift and click the last one, then click the colour swatch to set the fill. If that approach works, repeat for the next third and the last third.
In practice there's a difference between "random" and "what humans perceive as random", so there's likely to be some clumping that you don't like. In that case you can hold Shift to de-select individual items on the canvas, and select others. That will lead to a non-contiguous block of selected entries in the Objects dialog, so you might want to group them all (at least temporarily) so that they get out of the way when you select the next third.
If they're not so randomly arranged that selecting a block gets you close to what you want, you can still use the Objects dialog but will need to do more clicking. Holding Ctrl while clicking on an entry will let you add/remove it from the selection, so you'll need to do that on every third entry. It may take a while, but it will likely be faster than trying to pick out 1/3 of them on the canvas. Again, once you've got your selection you should probably group them to avoid them being selected for the second pass (where you will then select every second entry).
[I did wonder if it might be possible to select roughly 1/3 of the stars using the Find/Replace dialog, on the basis that they've probably got a reasonable distribution of generated IDs. My thinking was to select all those with IDs ending in 0, 1 or 2, then all those ending in 3, 4 or 5, then finally those ending in 6, 7, 8 or 9. Unfortunately it doesn't look like the search field allows for wildcards, or for a way to indicate that the term has to be found at the end of the ID.]
If your stars are randomly distributed then just selecting the first 1/3 of them as listed should get you what you want. Just click the first one, then hold Shift and click the last one, then click the colour swatch to set the fill. If that approach works, repeat for the next third and the last third.
In practice there's a difference between "random" and "what humans perceive as random", so there's likely to be some clumping that you don't like. In that case you can hold Shift to de-select individual items on the canvas, and select others. That will lead to a non-contiguous block of selected entries in the Objects dialog, so you might want to group them all (at least temporarily) so that they get out of the way when you select the next third.
If they're not so randomly arranged that selecting a block gets you close to what you want, you can still use the Objects dialog but will need to do more clicking. Holding Ctrl while clicking on an entry will let you add/remove it from the selection, so you'll need to do that on every third entry. It may take a while, but it will likely be faster than trying to pick out 1/3 of them on the canvas. Again, once you've got your selection you should probably group them to avoid them being selected for the second pass (where you will then select every second entry).
[I did wonder if it might be possible to select roughly 1/3 of the stars using the Find/Replace dialog, on the basis that they've probably got a reasonable distribution of generated IDs. My thinking was to select all those with IDs ending in 0, 1 or 2, then all those ending in 3, 4 or 5, then finally those ending in 6, 7, 8 or 9. Unfortunately it doesn't look like the search field allows for wildcards, or for a way to indicate that the term has to be found at the end of the ID.]
Re: apply random colour from palette to objects
JuliaFlowers2 wrote:1.) the stars form big colour clumps (its not random enough)
2.) there are strange glitches where two colours seemingly overlap. what can be done about that ?
Hi.
With the tweak tool you can randomize the luminosity, resulting in different colour arrangement on the filtered results.
Although randomness mathematically means there are "clusters" here and there
This is a filtered solution, meaning the effect is added on in the rendering level -theoretically the objects on the canvas could be substituted with a raster double, the output would look the same.
If you zoom in or increase the resolution, the details should be rendered much clearer.
In that vein if you export the result in a larger size and downscale the png, the result should look way better.
Not sure why your images not showing up.
Try using an online host and then use
Code: Select all
[img][/img]
-
- Posts: 2344
- Joined: Sun Apr 14, 2013 12:04 pm
- Location: Michigan, USA
Re: apply random colour from palette to objects
Seems like a "Random Select" extension could be handy. Maybe something simple?
- Randomly select from:
- Entire document
Selected objects
Visible objects
Have a nice day.
I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1
The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/
I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1
The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/
-
- Posts: 40
- Joined: Tue Jul 31, 2018 4:47 am
Re: apply random colour from palette to objects
Moini wrote:The re-arrangement can be done by using the random functionality of the Align-and-Distribute-Dialog.
This seems the most simple and obvious method so far. I cant understand why i didnt try this.
Thank you so much for telling me !
Is there a place on the internet where i can find detailed information about this particular subsection of the Arrange & Distribution Dialogue ?
Xav wrote:Here's another approach: use the Objects dialog (Object ‣ Objects…).
In practice there's a difference between "random" and "what humans perceive as random", so there's likely to be some clumping that you don't like. In that case you can hold Shift to de-select individual items on the canvas, and select others. That will lead to a non-contiguous block of selected entries in the Objects dialog, so you might want to group them all (at least temporarily) so that they get out of the way when you select the next third.
Yes, its true what you say about perceived randomness.
Using the Object Dialogue for manually re-arraning single objects is a good tip.
Lazur wrote:With the tweak tool you can randomize the luminosity, resulting in different colour arrangement on the filtered results.
Although randomness mathematically means there are "clusters" here and there.
Another good tip to fix the cluster problem !
tylerdurden wrote:Seems like a "Random Select" extension could be handy. Maybe something simple ?
Yes, a random select extension would come in very handy.
On the other hand, re-coloring seems like a common task and shouldnt be too difficult to do.
How about an extension that lets you define a number of colours, or link to a swatch, then apply the colours randomly to a selection of objects ?!
-
- Posts: 40
- Joined: Tue Jul 31, 2018 4:47 am
Re: apply random colour from palette to objects
Lazur wrote:Press Shift+Ctrl+A for the panel, select th objects and click the bottom left icon -- of the distribute options.
your screenshot is missing the button Moini recommend
is was looking for a documentation on the new rearrange buttons, because they are not in the manual
Top
Re: apply random colour from palette to objects
Lazur indeed pointed at the icon I meant, random arrangement.
It exchanges the positions of the selected objects in a way that things that previously were in position 1 on an imaginary clock face are in position 2 after the click on the button. This is relevant when you select more than 2 objects. It swaps positions in a circular fashion, things move clockwise.
what does "exchange position of selected objects - clockwise rotate" mean ?
It exchanges the positions of the selected objects in a way that things that previously were in position 1 on an imaginary clock face are in position 2 after the click on the button. This is relevant when you select more than 2 objects. It swaps positions in a circular fashion, things move clockwise.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
-
- Posts: 40
- Joined: Tue Jul 31, 2018 4:47 am
Re: apply random colour from palette to objects
Moini wrote:Lazur indeed pointed at the icon I meant, random arrangement.what does "exchange position of selected objects - clockwise rotate" mean ?
It exchanges the positions of the selected objects in a way that things that previously were in position 1 on an imaginary clock face are in position 2 after the click on the button. This is relevant when you select more than 2 objects. It swaps positions in a circular fashion, things move clockwise.
Thanks for clearing that up !
I took your advice, recoloured each third of the stars into my desired color, then shuffled the objects with the "exchange position of selected objects - clockwise rotate" button. This doesnt break the arrangement of the stars, just the position. Which is what i needed.
Re: apply random colour from palette to objects
So you had 'constellations' in your night sky? Smart way to solve the problem, I wouldn't have thought of this.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
-
- Posts: 40
- Joined: Tue Jul 31, 2018 4:47 am
Re: apply random colour from palette to objects
Moini wrote:So you had 'constellations' in your night sky? Smart way to solve the problem, I wouldn't have thought of this.
its for a flag, and i just discovered this option because of you
Re: apply random colour from palette to objects
JuliaFlowers2 wrote:Is there a place on the internet where i can find detailed information about this particular subsection of the Arrange & Distribution Dialogue ?
Sounds like you don't really need it any more, but I covered this dialog in parts 38 & 39 of my tutorial series: viewtopic.php?f=6&t=11981
Re: apply random colour from palette to objects
I realize this is mostly solved by now. But I wanted to mention a different approach: Edit menu > Clones > Tiled Clones. Besides making tiled type of arrays, that can create the randomly placed, randomly sized and randomly colored stars, or any kind of object.
For the stars being only 3 colors, I would probably create 3 random arrays - one for each color. That's how I made the fireworks in this image: https://forum.inkscapecommunity.com/ind ... 34#msg1234
For the stars being only 3 colors, I would probably create 3 random arrays - one for each color. That's how I made the fireworks in this image: https://forum.inkscapecommunity.com/ind ... 34#msg1234
Basics - Help menu > Tutorials
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design