sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update

    Color interpolation across a face

    Scheduled Pinned Locked Moved Developers' Forum
    14 Posts 4 Posters 1.4k Views 4 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.
    • Dan RathbunD Offline
      Dan Rathbun
      last edited by

      If you know the binary fileformat for some image filetype, you could write out a file in binary mode:

      ` img = File.open('myimage.bmp',"wb")

      img.write(value)

      ...

      img.close`

      Then bring that image into your materials collection.

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        Hmmm.. I'll need to think on that...

        Have you been following what Aerilius' OnScreen GUI Toolkit

        or: Chris Fullmer's On Screen GUI RGB Colorpicker

        ❓

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          To draw in OpenGL style (either 3D or 2D,) in SketchUp, must be done within a Tool class, using the View instance's family of draw methods.

          see:
          https://developers.google.com/sketchup/docs/ourdoc/view#draw

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            So.. for color interpolation within a Tool class, when you set the color (just prior to painting a point,) with view.drawing_color=() you would evaluate the argument using color.blend

            The receiver color would be color of one vertice, arg1 the other vertice's color, and the weight arg would be percentage ( Float) of the distance between the two vertices.

            I'm not here much anymore.

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

              The API doesn't let you set vertex colour. 😞 Wish it did.

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

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                That's not what he wants.

                He wants to draw multi-gradient color fill, on-the-fly.

                I'm not here much anymore.

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

                  @dan rathbun said:

                  That's not what he wants.

                  He wants to draw multi-gradient color fill, on-the-fly.

                  Yes - and in OpenGL you do that by defining a colour for each vertex in a polygon where the shader then creates a gradient between each vertex colour across the polygon surface.

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

                  1 Reply Last reply Reply Quote 0
                  • Dan RathbunD Offline
                    Dan Rathbun
                    last edited by

                    Yep.. it would be nice to have more OpenGL draw functions.
                    Implementing a shader in Ruby is bound to be slow.

                    I'm not here much anymore.

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

                      @dan rathbun said:

                      ... you would evaluate the argument using color.blend

                      color.blend makes brown out of red and green.
                      In case you need a different interpolation (where you want red and green to result yellow), you need to write your own interpolation method, or take Color.interpolate(color1, color2,...) of https://bitbucket.org/Aerilius/color/wiki/Home

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

                        Thanks everyone for the replies.

                        @Dan using the draw in a tool's view method looks like a plausible option. Let me dig into it and get back.

                        Thanks again.

                        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