[code] On Screen GUI RGB Colorpicker

[code] On Screen GUI RGB Colorpicker

Postby Chris Fullmer » Sat Sep 15, 2012 2:07 am

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:

0
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer 
SketchUp Team
SketchUp Team
 

Re: [code] On Screen GUI RGB Colorpicker

Postby driven » Sat Sep 15, 2012 2:26 am

that's cool

2012-09-15 02.24.38 am.png


john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [code] On Screen GUI RGB Colorpicker

Postby Chris Fullmer » Sat Sep 15, 2012 4:34 am

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.
0
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer 
SketchUp Team
SketchUp Team
 

Re: [code] On Screen GUI RGB Colorpicker

Postby Aerilius » Sat Sep 15, 2012 9:12 am

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!
0

Aerilius 
PluginStore Author
PluginStore Author
 

Re: [code] On Screen GUI RGB Colorpicker

Postby thomthom » Sat Sep 15, 2012 10:42 am

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.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [code] On Screen GUI RGB Colorpicker

Postby Chris Fullmer » Sat Sep 15, 2012 2:59 pm

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.
0
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer 
SketchUp Team
SketchUp Team
 

Re: [code] On Screen GUI RGB Colorpicker

Postby thomthom » Sat Sep 15, 2012 4:31 pm

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.)
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

On Screen GUI Slider

Postby driven » Thu Mar 05, 2015 2:33 pm

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...
Code: Select all
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
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: On Screen GUI Slider

Postby slbaumgartner » Thu Mar 05, 2015 2:51 pm

driven wrote: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...
Code: Select all
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
Code: Select all
slider.value

Does that not work?
0

slbaumgartner 
PluginStore Author
PluginStore Author
 

Re: [code] On Screen GUI RGB Colorpicker

Postby driven » Thu Mar 05, 2015 2:56 pm

@steve...

yes, I must have tried every other possible way, but not the obvious...

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [code] On Screen GUI RGB Colorpicker

Postby Herdsman1971 » Thu Apr 09, 2015 3:17 pm

Hi Im on a Mac and really don't understand computers, is there a simple detailed explanation of how you install RGB Color picker ?
0

Herdsman1971 
 

Re: [code] On Screen GUI RGB Colorpicker

Postby driven » Thu Apr 09, 2015 5:26 pm

This is really just an experiment for developers, i.e. not a really useful for day to day modelling...

Still want to know?

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [code] On Screen GUI RGB Colorpicker

Postby Herdsman1971 » Thu Apr 16, 2015 1:44 pm

If it is not to complicated please. I would like to know
0

Herdsman1971 
 

Re: [code] On Screen GUI RGB Colorpicker

Postby driven » Thu Apr 16, 2015 5:37 pm

download the ruby file...
open SU menu >> 'Window' >> 'Ruby Console'
copy/paste/return the first line
Code: Select all
 load "~/Downloads/rgb_picker.rb"

should return true in 'RC' if that's of your path...
copy/paste/return the second line...
Code: Select all
 Sketchup.active_model.select_tool(Col_pick.new)

should work...
hit spacebar to close the color picker...

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 7 guests

Visit our sponsors: