sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    [code] On Screen GUI RGB Colorpicker

    Scheduled Pinned Locked Moved Developers' Forum
    14 Posts 6 Posters 2.9k Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Chris FullmerC Offline
      Chris Fullmer
      last edited by

      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]


      rgb_picker.rb

      Lately you've been tan, suspicious for the winter.
      All my Plugins I've written

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by

        that's cool

        and works on a mac....

        john

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

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          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.

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • A Offline
            Aerilius
            last edited by

            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!

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              @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.

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • Chris FullmerC Offline
                Chris Fullmer
                last edited by

                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.

                Lately you've been tan, suspicious for the winter.
                All my Plugins I've written

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  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.)

                  Thomas Thomassen β€” SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    driven
                    last edited by

                    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

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

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      slbaumgartner
                      last edited by

                      @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?

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        driven
                        last edited by

                        @steve...

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

                        john

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

                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          Herdsman1971
                          last edited by

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

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            driven
                            last edited by

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

                            Still want to know?

                            john

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

                            1 Reply Last reply Reply Quote 0
                            • H Offline
                              Herdsman1971
                              last edited by

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

                              1 Reply Last reply Reply Quote 0
                              • D Offline
                                driven
                                last edited by

                                download the ruby file...
                                open SU menu >> 'Window' >> 'Ruby Console'
                                copy/paste/return the first line

                                 load "~/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

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

                                1 Reply Last reply Reply Quote 0
                                • 1 / 1
                                • First post
                                  Last post
                                Buy SketchPlus
                                Buy SUbD
                                Buy WrapR
                                Buy eBook
                                Buy Modelur
                                Buy Vertex Tools
                                Buy SketchCuisine
                                Buy FormFonts

                                Advertisement