Here is some code I wrote a while ago for an RGB color picker. It works pretty well. I think there is something that doesn't work right, but I can't remember what it is. But if anyone ever needs it or wants to use it, here it is. I was thinking maybe eventually we could clean it up and put it into the GUI Development kit. That was the initial idea for it, to be used in a GUI kit that we never got around to working on a few years ago. SOOOooo, anyhow. Here is the code.
Cool, thanks for the screenshot John. I got a video made and uploaded to YouTube now so you can see it in action and see a few sort of hidden features I built into it.
That's great! (I also have a color html chooser in an unreleased plugin.) In HTML, one can easily create the gradient with a png image (black/white/transparent) on a colored box. We should maybe discuss on BaseCamp whether the SketchUp devs can create a (native) View.draw_image(point, width, height) method?
I did some performance tests for the draw method (on a rather slow computer): without DrawCache: min 0.094, max 0.384, average 0.163 with Thomthom's DrawCache: min 0.032, max 0.070, average 0.037 With highest resolution it's average 50s vs 10s. The draw cache can only reduce overhead for calculating colors/shapes etc, but drawing the gradient stays a very expensive operation.
I'm still working on big changes in the onscreen toolkit before writing new controls, but then it will be very easy to implement this color picker!
Aerilius wrote:The draw cache can only reduce overhead for calculating colors/shapes etc, but drawing the gradient stays a very expensive operation.
Only way to speed up actual drawing is to draw in bulk. But for this is difficult due to different colours. Same thing with my code that draws BMP images - the best optimisation I can do is grouping same colour pixels into one draw operation. So the more colours - the slower it gets.
Yeah, which is why I made different level of pixelization possible in the large gradient. It works great for this. I haven't tested it on a large model though. If a large model is already making the system lag, this color picker might be the death of it.
While at basecamp, this is one of the things I'd like to talk to the SketchUp devs about. Being able to load and draw bitmaps on the viewport would be a big thing. (Even creating bitmaps on the fly.)
class NextTool require "/Users/johns_iMac/Library/Application Support/SketchUp 2015/SketchUp/Plugins/OnScreenGUI/ae_OnScreenGUI.rb" include AE::GUI::OnScreen
class NextTool require "/Users/johns_iMac/Library/Application Support/SketchUp 2015/SketchUp/Plugins/OnScreenGUI/ae_OnScreenGUI.rb" include AE::GUI::OnScreen