B4A Class ColorPalette and CircularPalette

There are many ways to pick a color from within an application, so I contribute another.
You select any possible color in a the color palette, modify the brightness and press ok.
Some subs useful with colors which were used are enabled as functions in the class:
- ParseColor - returns the components of the color
- HSLToRGB
- COLORtoHSL

The class needs the pictures in files.

Edit: ver 1.1, landscape fills the screen.
Edit: Ver. 2.0
Edit: Ver 2.1 limits the cursor movements to the palette.
Edit: ver 2.2 - added the freeze orientation code by stevel05 (Thanks !)
from here http://www.b4x.com/android/forum/threads/freeze-orientation.41681/
Edit: Ver 2.3 with modified code for Freezing the orientation. This may behave wrongly with some devices.

Edit: CircularPalette added as another class. It is very simple and is a color picker, see photo.
 

Attachments

  • cp.png
    cp.png
    102 KB · Views: 984
  • ColorPalette_2.3.zip
    88.9 KB · Views: 758
  • cp.png
    cp.png
    97 KB · Views: 696
  • CircularPalette.zip
    123.4 KB · Views: 724
Last edited:

mr23

Active Member
Licensed User
Longtime User
I needed a quick relatively lightweight picker, so I started with the CircularPalette from derez, and found a few things to improve or change to my liking.
I don't like the picker adding a panel to 'parent' aka main's Activity, but I stopped for the time being before doing anything about that.
I moved the buttons to the top so the color is always visible while selecting, the hand otherwise obscures it (especially lefty's).
I set the V,X buttons to New,Original and set the X/Original background to the color upon entry.
V/New,X/Original are placed next to each other so you can more readily observe/select the color change especially a small one.
The picker's panel is also colored to the V/New button color as it is chosen.
Minor code speedup in the outer ring, cleaned up some artifacts by improving the rotational resolution, a 1 pixel radius tweak and dropping the unused 201st column in the color wheel png.
Some additional minor changes beyond that.
Included in the zip is the modified CircularPalette.bas, the modified rpc.png, and for convenience, the untouched cursor.png.
Free to use, donate if you wish.
 

Attachments

  • CircularPaletteFiles.zip
    53.4 KB · Views: 285
  • ColorPicker.png
    ColorPicker.png
    102.8 KB · Views: 274

derez

Expert
Licensed User
Longtime User
mr23, you used my class and even didn't give me a "like" - not that I need it, but in this forum I believe we act differently.
 

Ivan Aldaz

Member
Licensed User
Longtime User
Thanks again for your work, derez.

For my app, I needed the user to choose color, but also transparency, so I've improved the class and adding this feature to your code. I've put files here, for anyone interested on how it could be done. There are also minor changes as, for example, what mr23 said about placing buttons together to compare old and new colors, or start the palette with an initial color.

Hope it's useful, especially for non-expert programmers, like me.

Best regards.
 

Attachments

  • CircularPaletteWithAlpha.zip
    148.9 KB · Views: 312
Top