Color Gradient script?
 1-20  21-40  41-60  …  81-92

Next
 From:  amur (STEFAN)
9676.1 
Hi Michael and all,

I am a bit out of the loop with MoI and was wondering if there is
a color gradient script available, which allows me to colorize splines
or tubes, made out of splines, so that I have for example a rainbow
effect on let's say n number of objects?

Best regards
Stefan
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
9676.2 In reply to 9676.1 
Hi Stefan, I don't remember any already existing script that would do that type of coloring.

How were your splines or tubes created? One thing that might be difficult to make a script like that would be if the script needed to figure out how the objects were ordered. If the objects were created by something like a Transform > Array command then maybe their natural order in the geometry database would be ok though.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
9676.3 In reply to 9676.1 
Hi Stefan,
I recall a node script of Karsten's which created a "rainbow" of color styles.
A color "gradient", or at least color changing in quantized steps,
Like some canvass programs, would be nice.
I assume that the colors would have to be in the color styles list?
- Brian

p.s. My tablet is now showing Post etc buttons
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  amur (STEFAN)
9676.4 
Hi Michael and Brian,

It is all created in MoI and I would assume that the order would depend
on the object creation list in the browser, like starting from the first object
in the browser until the last. Then I gues it would only need to define a starting
color and a second end color, which then computes the steps between.
To have a rainbow one starts with red values on the left and the second color
would be the red on the right. Maybe you have a better idea.

I had such a script years ago for Shade3D and it worked in the same way.

@Thanks Brian! Do you have a link for Karsten's node handy?

Best regards
Stefan
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
9676.5 In reply to 9676.4 
Hi Stefan, objects only show up in the browser if they are assigned an object name, and they are displayed in alphabetic order there.

So to use the browser order like you're describing you would need to assign an object name to each individual object that you wanted to have in the gradient and make the names in increasing alphabetic order.

That seems kind of cumbersome but it could be possible to set it up that way if that would work best for you.

It would probably help if you could post an example file that had the objects in it that you wanted to apply the gradient onto.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  amur (STEFAN)
9676.6 In reply to 9676.5 
Hi Michael,

that would be perfect, because I often name my objects in the browser and I have no
problem to rename them in an alphabetic order etc.

Sorry that I can not post a file currently, because I am working on such a project
right now which takes a little time, but could send you later the file.

Best regards
Stefan
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
9676.7 In reply to 9676.4 
The function createRainbow() is located in nodeeditor/nodes/extensions/libs/basicfunctions.js.

It is called from the SetStyle node, under the nodeeditor objects2 menu.

- Brian

I do not claim to understand it. It looks like it may create 255 colors?
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  amur (STEFAN)
9676.8 
Hi Michael,

i just send you some splines I am currently working on. If it is required to
use surfaces or solids I will resend the same file this afternoon or evening.

Best regards
Stefan
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  amur (STEFAN)
9676.9 
Hi Brian,

thanks a lot! I will have to take a look, even If I am not much familar
with NodeEditor.

Regards
Stefan
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
9676.10 
There was this gradient...by Michael ;)

script: /* Gradient Styles */ var red = 12, green = 15, blue = 20; for ( var i = 1; i <= 100; ++i ) { var style = moi.geometryDatabase.addStyle(); style.name = 'Gradient ' + i; style.color = (Math.abs(red%256)<<16) | (Math.abs(green%256)<<8) | Math.abs(blue%256); red += 2; green += 3; blue -= 7; }

Pas possitif= Positive Steps
Framboise = Raspberry
Vers du Bleu des mers du sud = Toward South Sea blue
La case fait 2.55 = Box width is 2.55
130 en 100 cases = 130 in 100 boxes

Il faut donc écrire dans le script = So you have to write in the script




EDITED: 9 Feb 2020 by PILOU

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  amur (STEFAN)
9676.11 
Oh, cool Pilou!

But I can not get it to work ... :-(

I select all my splines and run the shortcut but the script then
writes all color styles in the browser, but does not apply the
colors to the selected splines. :-(

Regards
Stefan
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
9676.12 In reply to 9676.11 
It looks like the script referenced by Pilou only creates the color styles, as stated in French it doesn't write to the geometry.

Eight !! years ago, Michael provided help in how to write color styles to objects, in one of the scripts that I was
working on. It was the Gradient script. Also used in the JacobianFunctionGraph script.

https://moi3d.com/forum/index.php?webtag=MOI&msg=5592.5

- Brian

EDITED: 9 Feb 2020 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  amur (STEFAN)
9676.13 
Ah, o.k.

meanwhile I also found the second script in Pilou's old thread.

So, one has to create two shortcut keys, one for creating the
styles and one for applying all the styles, including the standard
ones.

Regards
Stefan
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
9676.14 
Yes sorry i have forgotten this one!
was descripted on my Gradient page as link! :)
http://moiscript.weebly.com/make-gradient-styles.html
http://moiscript.weebly.com/assign-styles-to-solids.html

script: /* Assign styles to solids*/ var styles = moi.geometryDatabase.getObjectStyles(); var breps = moi.geometryDatabase.getObjects().getBReps(); var style_index = 0; for ( var i = 0; i < breps.length; ++i, ++style_index ) { if ( style_index == styles.length ) { style_index = 0; } var brep = breps.item(i); brep.styleIndex = style_index; }

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
9676.15 In reply to 9676.14 
There is also an "Assign styles to curves version".
Both have been in my shortcut keys for a long time...:-)
- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
9676.16 In reply to 9676.13 
Hi Stefan, does the above stuff do what you need or did you need something different?

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  amur (STEFAN)
9676.17 
Hi Michael,

I did a quick test and I don't know how to get rid of the main MoI colors when applying the gradient.

What I had like seen, as I described, is to have in the script a way to select a starting and an end
color, while the script computes then the steps betweenthose two colors.

Regards
Stefan
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
9676.18 In reply to 9676.17 
Suggestion:
Place the desired gradient colors at the end of the color styles list, and note the index of the first gradient color. If there were say 10 colors before the gradient start style, their indexes would be 0 thru 9, and the style index of the first gradient color would be 10, due to zero indexing.
Edit the script to start at style index 10. If gradient colors run out, reset index to 10.
Or a Moi script with .htm could be written...
- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
9676.19 In reply to 9676.17 
Hi Stefan,

> What I had like seen, as I described, is to have in the script a way to select a starting and an end
> color, while the script computes then the steps betweenthose two colors.

It should be possible to make a script that does this.

What color space do you want to use for specifying the colors?

If using RGB colors, going from Red to Red like you mentioned above would only yield red for all the steps in between.

But something using Hue, Saturation, Value colors could probably give more of a rainbow type effect.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
9676.20 In reply to 9676.17 
Hi Stefan,

re:
> I did a quick test and I don't know how to get rid of the main MoI
> colors when applying the gradient.

If this is the only problem, I think you could solve it by deleting the main MoI styles, then apply the gradient, then use "Add default styles" on the Styles menu in the Scene browser to bring back in the regular default MoI styles again.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
Show messages:  1-20  21-40  41-60  61-80  81-92