Property As Color

It’s a design question:

How do you deal with Color Property(ies) ?

a. Dim it in code (this may be multiple times), as cmy()
b. Create a Property in the window (cmy, RGB, csl,…) ?
c. Do you add it (them) it a module ?
if so, where do you fill the property(ies) ?

tia

[quote=206857:@Emile Schwarz]It’s a design question:

How do you deal with Color Property(ies) ?

a. Dim it in code (this may be multiple times), as cmy()
b. Create a Property in the window (cmy, RGB, csl,…) ?
c. Do you add it (them) it a module ?
if so, where do you fill the property(ies) ?
[/quote]

All depends where and when you need such properties/variables. If all these methods are available, it is because they each have their own use.

Do they have to be modifiable? If not, I would use IDE constants.

ColorModul with some colors

The fact is that only one of these methods are available when we talk about Properties. Look at Axel screen shot above.[quote=206890:@Axel Schneider]ColorModul with some colors[/quote]
Thanks Axel: I forgot that it is possible to add Properties to an xml exported module and reimport it. Of course, a license is needed to achive the job.

BTW: Don’t you fear anything using these names for the colors ?

I used some sort of prefix for (at least) two projects: in the first one I used “k” to mean these are constants, the second one prefix is lost in my brain’s RAM (and my memory is really Random Access Memory…)

As far as I can recall, I do not change the color Properties values: I use only some pre-defined Properties (or Constants).

To be complete, I found that cmy better: I get faster the color I love vs RGB or… The only downside is when cmy is not available… and that I need to make a conversion that never gaves me the same color.

[quote=207108:@Emile Schwarz]The fact is that only one of these methods are available when we talk about Properties. Look at Axel screen shot above.
[/quote]

You are not forced to do constants. Programming is all about choices. Your question was about differences between dim and properties. Properties in Windows or Modules are simply more and more global. Scope, to be exact. They can be variables or constants. It’s all up to you. If you like creating CMY, then you probably do not want to use constants.

No. But if you do not change some Properties values, isn’t it more secure to use Contants instead Properties ?
Sometimes I feel that way.

I just get an eye on a project and I used Constants for default colours, Properties for… something else! (printings in colours it seems)

A stupid question:

How can I set the constant color to cmy(0.25,0,0) ?

As far as I know we can only use &cACDAE9…

And usually, the cmy to rgb conversion don’t gives me the same colour (sometimes I like it better on RGB, but most of the time, it is the cmy colour that I love); but this is a different matter

[quote=207142:@Emile Schwarz]No. But if you do not change some Properties values, isn’t it more secure to use Contants instead Properties ?
Sometimes I feel that way.

I just get an eye on a project and I used Constants for default colours, Properties for… something else! (printings in colours it seems)

A stupid question:

How can I set the constant color to cmy(0.25,0,0) ?

As far as I know we can only use &cACDAE9…

And usually, the cmy to rgb conversion don’t gives me the same colour (sometimes I like it better on RGB, but most of the time, it is the cmy colour that I love); but this is a different matter[/quote]

Emile, I am sorry, you are making it way too hard on yourself.

Why would a constant be more secure than a variable ? If you do not mess with it, it will not change by itself.

There is no way I can think of to assign variables to constants, so neither RGB nor CMY can be used.

The best you can do if you fear modifying a property by accident is to use a computed property, put nothing in Set, and initialize directly its master property in Open. Then for all intents and purposes, it will work as a constant.

  • Add myColor as Color to your window or module
  • Right click on it and select “Convert to Computed Property”
  • Click on myColor, and comment out the content of Set
  • In Open, go
mmyColor = cmy(0.25,0,0)

Even if you try to modify myColor, it will do nothing.

You don’t need a private property for that and you don’t need any code in the Open event:

Computed Property MyColor As Color Get Static c As Color = CMY(0.25, 0, 0) // will be executed only once in the lifetime of the application Return c End // Do not implement the Set part End

Emile, your original post said nothing about constants, only properties (variables). I think that may have confused us. But, yes, if your question is regarding constants, the “&c” notation is your only option.

How is that possible? cmy simply returns a color value in the form &cRRGGBBAA.

[quote=207186:@Eli Ott]You don’t need a private property for that and you don’t need any code in the Open event:

Computed Property MyColor As Color Get Static c As Color = CMY(0.25, 0, 0) // will be executed only once in the lifetime of the application Return c End // Do not implement the Set part End[/quote]

Great. But where do you place that code to have a window wide or app wide scope ?

Emile was referring to Axel’s module, I think. Not to an event declaration.

Computed property of a module?

Oh, I see. The use of Static is in Set.

Thank you.

Must have been tired. Talking about programmers love of complexity, and need for simplicity. Sorry for my initial suggestion.

A good night sleep helps.

Create a Computed property myColor as Color,

Here is what to put in Get :

Get Return CMY(0.25, 0, 0) End Get

Nothing goes in Set.

I’ve made the convesion by hand, I used a web site (once) to make the conversion.

How is that possible ?
So if this is impossible, then the faultive is my old eye. Sorry.

Thank you all.

i add in a lot of new constants very similar to the properties but starting with k

https://dl.dropboxusercontent.com/u/7474523/XojoForum/ColorModul%20v2.zip

Hi all,

I found it late, but better late than never…

html_colornames.asp

…and i had this page open in a Firefox tab (certainly since… ages).