Random Theme Generator (Unified Version)

http://www.loadusfx.net/blender/b_ui.jpeg

Random Theme Generator

I was tweaking a script by Kevin Morgan (forTe) - the random theme generator. The script had all the color functions, but it randomized everything, so the interface looked a bit scary afterwards.

I took some time with it to make a ‘unified’ version, that randomizes the colors, but makes them the same for every window. I made mad calculations to it to make different variations but with similar hues.

The calculations are a bit goofy, since I’m no programmer, it might crash because of bad boundaries etc etc. And this kind of script might already be available and be better but I was merely learning the syntax of the Blender python … ^^

The script [Updated with GUI and code-cleanup (thx hiower + dfelinto!)]:
http://www.loadusfx.net/blender/randtheme-uni-gui.py

Have fun with it - if you optimize it, change it, improve it etc then post it here so everyone can enjoy it. :slight_smile:

Tweak the settings to see how it changes the mood. Expect hallucinations. :stuck_out_tongue:

ha, nice one.

That was kinda freaky, I loaded up the script and my computer started beeping at me and all this gibberish appeared in the console. I tried it three times and it happened every time.

Here is a screenshot of the console:
http://i135.photobucket.com/albums/q146/andrew-101/_JPG.jpg

I actually really want to try this script out so if anyone has any ideas on what to do then thanks.

I’m running Window’s XP Home with Blender 2.48 and Python 2.5 if it helps

P.S, add:

# """
# Name: 'Random Theme Generator'
# Blender: 248
# Group: 'Theme'
# Tooltip: 'Make random themes!'
# """

under the ‘#!BPY’ to add it to the themes section of the scripts menu in the scripts window (file has to be placed in scripts first)

Yes, there are some missing int() tags in the script, but it shouldn’t throw that much stuff on you … I run it without errors, but then again I’m in Linux … :stuck_out_tongue:

I can add the description on the file if someone wants to install it … it needs a GUI first though. You should load the script into the texteditor and press ALT+P (Play script).

EDIT:
added the description for the menu …

Cool script. I added the missing int(), so now it shouldn’t spit out any gibberish. I made it spit out the color values instead though, to help with debugging.
[edit: forgot i commented these out. It shouldn’t spit out anything to the console now.]
It seems that it is vertex and text_hi that makes it break, namely because:int(power + random() * power)
can produce values larger than 255. So i changed it to:int(power + random() * power * (1-power/255.))
Try it out, works 100% of the time for me now.
randtheme-uni_debugged.py

Anyone has anywere to host this?

Hey, That’s pretty cool that somebody took my acid trip machine and made it generate really nice themes!

Perhaps I should have posted the script that actually generated my original script, though, to make it easier to modify. Perhaps I should also add my information to the original script too, so people can find me from it…

Scratch that. Uncommented the print lines again, as it still sometimes fails.
*Sometimes fails with hue values over 100
*Seems lamp and textc can get values below 0

As it is, i think coloring of vertices and faces need some work

Perhaps I should also add my information to the original script too, so people can find me from it

the link in your sig helps too.
thanks, I thought I had seen that somewhere before.

Excellent, I can host the debugged version. I was about to attach the code to an UI I did on the Python GUI creator, but I have no understanding how the variables change from the slider controls. I just keep getting error after error (I don’t know the Python syntax properly yet).

Here’s the GUI imported into the file (uncorrected one, though), but the variables are not hooked in yet (I don’t know how). Anyone care to assist? ^^
http://www.loadusfx.net/blender/randtheme-uni-gui.py

And yes, it was from forTe’s original script <------ credit to who credit is due :slight_smile:

Nice script.

I would suggest that instead of load it from the menu, run it as a ScriptLink activated on FrameChanged

And if you add this in the top:

#from Blender.noise import random ### I think is better to use the random below, can delete this line in fact :::
from random import random
from random import seed

seed(Blender.Get("curframe"))

You have a new theme each frame, and because of the seed you can produce the same theme again. :slight_smile: Press Alt+A and pick your theme :smiley:

And I would only suggest that you always avoid to set the same color for the text editor background and foreground.

EDIT::

And if you create a:
[DEBUG = 0] in the top

and use [if DEBUG:] before all the print statements you run it (way) faster :slight_smile:

Took my debugged version and put it into your gui, and hooked up the variables and stuff. Fixed the hue bug as well i think (implemented a check, if lamp or textc created color values below 0, it became 0 instead) I think it was because of multiple int().

randtheme-uni-gui_02.py

Cheers

Ok, I don’t think this can be called random anymore :smiley:

randtheme-uni-gui_03.py

[edit: cleaned up the code slightly + added debug mode]

Latest version. The script now:
*Have a gui
*Uses seed, so lets you change the different values independently + you can regenerate the same theme if you know its values
*Updates automatically when values change
*Catches any rgba values that are outside 0-255
*Has a working randomize function

randtheme-uni-gui_04.py

Wicked mon!
I’ll host this from my server, if it’s ok. The code must’ve been messy, I did it for about 5h and at the last few minutes I couldn’t see line from the other. And my math sucks worse than ever. :D:D

I’d better stick to the graphics side …

Well, I didnt bother much with the math to be honest, and those were the messy lines :rolleyes:
I think it works quite nicely, there are still some things that could be improved though i think…
*if dark > bright, text doesnt do anything sometimes.
*It’s difficult to generate a usable theme with light text on dark

[edit: and of course it’s ok that you host it]

This script is great, you should try getting it into the trunk.

I like the GUI thing, however I still think that this is more useful running as a ScriptLink. There is a way to run the GUI once, configure the parameters and load the parameters from a ScriptLink?

I think it is just a matter of store the parameters in Blender module or something similar.

And if it is to make all the generation through GUI, I would suggest a button to randomly create a new seed and a new theme. That way you can recreate the theme, but don’t need to change parameters all the time to have a different, random, theme.

I was thinking about the same thing after your script link idea. I think one needs 2 different scripts though, one with gui and one without. But saving parameters should be possible.

That would be the “randomize” button :confused: