Copy link to clipboard
Copied
I have a grayscale mosaic consisting of 75x75 tiles, created by Create Object Mosaic. Each tile/object ranges from 0% - 100%. I want to round each of thos tiles/objects to their closest quarter percent, 0%, 25%, 50%, 75% or 100%. Meaning if the object is 15%, I want it to be rounded to 25%. If it's 57% then rounded to 50%, and so on. Is there a method or a plugin that allows me to take all the tiles and and have them rounded automatically? I tried doing this by using the select same method, but no matter if I use Same > Appearance, Same > Color & Stroke, or Same > Fill Color, there are no other objects that also become selected.
I'd deeply appreciate any time and help you may be able to give.
1 Correct answer
See if this works for you.
// select group
var sel = app.selection[0];
for (var i = 0; i < sel.pathItems.length; i++) {
var fill = sel.pathItems[i].fillColor;
if (fill.gray >= 0 && fill.gray <12.5) {
fill.gray = 0;
} else if (fill.gray >= 12.5 && fill.gray <37.5) {
fill.gray = 25;
} else if (fill.gray >= 37.5 && fill.gray <62.5) {
fill.gray = 50;
} else if (fill.gray >= 62.5 && fill.gray <87.5) {
fill.gray = 75;
} else {
fill.gray =
...
Explore related tutorials & articles
Copy link to clipboard
Copied
Maybe playing with the tolerance setting of the Magic Wand Tool will help?
Copy link to clipboard
Copied
Thank you for the reply. I was trying to find any and all information I could regarding the Wand before replying, but it's frustrating. It's like there's so much obvious potential there for the wand, but it's so limited. I wish I could adjust Brightness range instead of tolerance. I also tried to mess with "Recolor Artwork", but thats excruciating as it's picking up over 2500 "color" viariations. Program keeps wanting to crash. I wish I could have 5 objects or swatchese that I could go based off, maybe eye-drop, and it just selects a determined range 1-12.5%, 12.6%-25%, etc... then when that range is selected, I change it to what I need.
There has got to be a way to do this. I like the Wand suggestion, but it just doesn't take brightness into considereation.
Copy link to clipboard
Copied
It should be doable with a simple script. What type of color is being used? If you select your mosaic and run this line, what does the message read?
alert(app.selection[0].pathItems[0].fillColor);
Copy link to clipboard
Copied
Thank you! Sorry for the delayed response. grayscale confirmed as [GrayColor]
Copy link to clipboard
Copied
See if this works for you.
// select group
var sel = app.selection[0];
for (var i = 0; i < sel.pathItems.length; i++) {
var fill = sel.pathItems[i].fillColor;
if (fill.gray >= 0 && fill.gray <12.5) {
fill.gray = 0;
} else if (fill.gray >= 12.5 && fill.gray <37.5) {
fill.gray = 25;
} else if (fill.gray >= 37.5 && fill.gray <62.5) {
fill.gray = 50;
} else if (fill.gray >= 62.5 && fill.gray <87.5) {
fill.gray = 75;
} else {
fill.gray = 100;
}
}
Copy link to clipboard
Copied
How on earth did you find/make this?? It's exactly what I was needing. Im so sorry that it took me so long to come back around and see this. Thank you very very much. Is there a name to this script? Also, I know it's a bit off subject, but in trying to achieve a triangular mosaic, and the method Im going with results in two groups that you overlap and then use Darken for blending mode. Is there a way to merge the two groups (or even just two objects, and I can figure it from there) that overlap, so that the color looks the way it did with Blend Mode. I know this is not Photoshop, but in Ps, merge down or visible options gives you a resulting layer that looks the way it did with multiple larys with blend modes. Is there any way to acheive this is Ai?
Copy link to clipboard
Copied
It's a simple script I wrote based on the information you provided (it doesn't have a name).
Regarding the triangular mosaic, I am unable to visualise your request without pictures. Are you able to demonstrate what you mean with screenshots? Also, starting a new post will get you more traction.
Copy link to clipboard
Copied
Thank you, I'll go ahead and create a new topic aswell. Im just always scared of the idea of seeing myself jump around "Hey, how do you do this? Hey, How do you do that? Hey, How do you...". Yes, I know the irony being that thats exactly what im doing here lol.
So, I apologize about creating confusion by emphasizing "Mosaic" and "Triangles". Though they are crucial to my project, they aren't for what Im asking. Im sorry again. The key is merging/flattening object with Blending Modes. I want to know how to take two objects that are on top of eachother, with the top having a blending mode, and merge them as one object, retaining the look the blending mode produced. I know that, like Photoshop, you can do this as rasterized images, but I need to keep the independent vector shapes/objects in tact. With the obvious exception that the result would be one object instead of two. Here is my drawing of Pina as a mosaic in triangles.
 
The method I followed resulted in two groups of mosaics, the objects being sheared squares. One group of squares sheared 30 degrees, the other -30. The trick was aligning the two groups and applying the Darken blend mode to the top group. This gives it the look of triangles, The retro Pixel look is awesome, but I needed triangles. More importantly to this discussion, it adds a bit more shading. Now, I went the extra step or two using Divide in pathfinder and made the object in the groups actual triagles.  
So... now you have triangle on top of triangle. Im emphasizing this because my desire to "merge" or whatever may have been more difficult if the objects had only been halfway overlapping (like a Venn Diagram.). Now it is just triangle over triangle. Currently the Darken blend mode is assigned to the group, but if need be, I could assign it to all objects within the group.
The following are the two seperate groups side by side.
 So, ya. . . um. . . Taaa daaaa.
Thank you for your help!
Copy link to clipboard
Copied
Object > Flatten Transparency will give new objects with the combined color.
Copy link to clipboard
Copied
That did the trick! Thank you very much!
Copy link to clipboard
Copied
Good to hear that helped.
Copy link to clipboard
Copied
I could Kiss you!
Copy link to clipboard
Copied
That's a plain and very useful script, Femke.
Thanks for sharing it.
As well as you already requested, I would also welcome some more clarification from varxtis.

