Random Background change with programming languege xojo - colors

I've tried to create a button with the programming languege xojo, so every time I press it the background color should randomly change. The name of my window is just Window1. I can't figure out how to do it, I would appreciate an example please, I know how to generate random colors, but how do it do it with the background ?

If you've already tried to set the background color, please also ensure the HasBackgroundColor property of your window is set to True:
Self.HasBackgroundColor = True
Self.BackgroundColor = Color.Red // Use your random color variable instead

Related

Permanently change the color palette in the GTK color picker

When using the color picker widget GTK applications I often use a different color Palette to the one given by default, as shown in the picture below. While the program is running I can change the defaults colors and they stay changed, however, when I close the program those modifications disappear.
I wonder how I can make those modifications to persistent in disk.
From the tags you chose, the application name seems to be Dia. In the application, nothing lets you set this option. So the short answer is: no.
The issue is that Dia uses the now deprecated GtkColorSelectionDialog (in favor of GtkColorChooserDialog). In the deprecated version, there is a flag to tell the widget to show/hide the color palette, but that's pretty much the only control you have (see gtk_color_selection_set_has_palette).
In the new widget version (which, by the way, looks totally different), you have direct access to a gtk_color_chooser_add_palette:
void
gtk_color_chooser_add_palette (GtkColorChooser *chooser,
GtkOrientation orientation,
gint colors_per_line,
gint n_colors,
GdkRGBA *colors);
You can see you have much more options as far as customizing the palette is concerned. You even have the ability to decide the colors. This means you could save your current selection in the palette. Then, at application quit, you could save all the palette's colors in some sort of settings, and load them back at application start.
As a final note, I looked at the Dia source code and found that they seem to be looking to make the move to the new widget. Here is an excerpt:
// ...
window = self->color_select =
/*gtk_color_chooser_dialog_new (self->edit_color == FOREGROUND ?
_("Select foreground color") : _("Select background color"),
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))));*/
gtk_color_selection_dialog_new (self->edit_color == FOREGROUND ?
_("Select foreground color") : _("Select background color"));
selection = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (self->color_select));
self->color_select_active = 1;
//gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (window), TRUE);
gtk_color_selection_set_has_opacity_control (GTK_COLOR_SELECTION (selection), TRUE);
// ...
From the commented code, it seems they are trying to make the move...

change color for only one Console.WriteLine

I know, this is a beginner question, but I want to change the background colour only for this sentence but it colours all the text.
Console.WriteLine("healing spell:", Console. BackgroundColor = ConsoleColor.Green);
This is what I tried but doesn't work.
Try it
Console.ForegroundColor=ConsoleColor.Cyan;

renderer.material.color giving strange results

I have a weird problem, that i can't figure out.
I want to change a gameobjects base color via renderer.material.color.
But for whatever reason, this only works for some colors.
This is my code:
first, I declare the colors:
var color_movement_available = Color(0.17,0.68,0.05,1);
var color_movement_available_hover = Color(0.33,1.00,0.17,1);
then i assign them, like this
case ("movement_available") :
renderer.material.color = color_movement_available;
break;
case ("movement_available_hover") :
renderer.material.color = color_movement_available_hover;
break;
However, when I test the script, the hovering color (pinkish) will not show.
I checked in the inspector and the color is the one i aimed for and is correctly switched.
When i change it to a bright (basecolor) green, red, blue or yellow, it works as supposed.
Other colors will produce white and some wont change anything.
Has anyone an idea what's causing this effect, or better yet, how to solve it?
What i tried so far:
switching the material renderer to diffuse (from transparent/diffuse):
same results
changing the materials initial basecolor to grey (from white):
also, no change
Maybe this has something to do with the way colors are applied ...
cheers
Edit: Screenshots:
Also, apparently, colors that are close to each other, like the same color only darker/lighter appear to be the ones producing white
I'm guessing you have a mesh renderer on your object.
Try GetComponent< MeshRenderer >().material.color

wxpython textctrl change caret colour

I'm using a wxpython textctrl & would like to hide the caret. After a lot of searching it would appear that the best approach would be to simply change it's colour to white. However I can not work out how to do this.
I found the following info:
SetCaretForeground(fore)
Sets the foreground color of the caret. The parameter fore is a wxColour object, a #RRGGBB string, or a color spec like "white". Returns None.
from here: http://www.yellowbrain.com/stc/caret.html#setfg
The code for my current textctrl is below. Any help would be appreciated.
self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL)
Clinton.
You are using a wx.TextCtrl and the link you give is for a wx.StyledTextCtrl. These are completely different animals, and the wx.StyledTextCtrl has a lot more functionality than the simple wx.TextCtrl.
I don't think there's a way to set the caret color in an ordinary wx.TextCtrl.

Changing the color of an EditorGUI.ProgressBar?

I want to show a ProgressBar. I am using this code:
EditorGUI.ProgressBar(Rect(3,45,100-6,20),20/700.0, "Armor");
I want to change the color of the ProgressBar from a light blue color to a red color. How can I do this?
As it stands, it doesn't appear that you can. However, I had a similar issue where I wanted a very customized bar with different colors to denote different things. I ended up using EditorGUI.DrawPreviewTexture. If you initialize the colors you want to use as a Texture2D, then pass them into that function with the properly placed rectangles, you can create portions of a bar that can change size and location to give the appearance of a standalone progress bar, especially if you keep the positions and size updated in the Update() function.

Resources