[code] On Screen GUI RGB Colorpicker
-
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.
Make it run by calling it as a tool:
Sketchup.active_model.select_tool(Col_pick.new)
Here's the video:
[flash=600,460:379qv0ox]http://www.youtube.com/v/6YkrigdSd-g&feature=player_embedded[/flash:379qv0ox]
-
that's cool
john
-
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:
%(#000000)[min 0.094, max 0.384, average 0.163]
with Thomthom's DrawCache:
%(#000000)[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 said:
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.)
-
been awhile since last post on this thread, but does anyone know how to retrieve the value of a slider?
I can get the screen position but need to return the value at position...
from my own tool that uses require...
class NextTool require "/Users/johns_iMac/Library/Application Support/SketchUp 2015/SketchUp/Plugins/OnScreenGUI/ae_OnScreenGUI.rb" include AE;;GUI;;OnScreen def initialize window.layout=({;margin=>5, ;orientation=>;horizontal, ;align=>;center, ;valign=>;top}) slider = Slider.new("Radius", [0,100]){|value| @@radius = value p value # this is screen position... } window.add(slider) end end Sketchup.active_model.select_tool(NextTool.new)
john
-
@driven said:
been awhile since last post on this thread, but does anyone know how to retrieve the value of a slider?
I can get the screen position but need to return the value at position...
from my own tool that uses require...
class NextTool > require "/Users/johns_iMac/Library/Application Support/SketchUp 2015/SketchUp/Plugins/OnScreenGUI/ae_OnScreenGUI.rb" > include AE;;GUI;;OnScreen > > def initialize > > window.layout=({;margin=>5, ;orientation=>;horizontal, ;align=>;center, ;valign=>;top}) > > slider = Slider.new("Radius", [0,100]){|value| > @@radius = value > p value # this is screen position... > } > > window.add(slider) > > end > > end > > Sketchup.active_model.select_tool(NextTool.new)
john
Based on the source, it should be
slider.value
Does that not work?
-
-
Hi Im on a Mac and really don't understand computers, is there a simple detailed explanation of how you install RGB Color picker ?
-
This is really just an experiment for developers, i.e. not a really useful for day to day modelling...
Still want to know?
john
-
If it is not to complicated please. I would like to know
-
download the ruby file...
open SU menu >> 'Window' >> 'Ruby Console'
copy/paste/return the first lineload "~/Downloads/rgb_picker.rb"
should return
true
in 'RC' if that's of your path...
copy/paste/return the second line...Sketchup.active_model.select_tool(Col_pick.new)
should work...
hit spacebar to close the color picker...john
Advertisement