sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Color interpolation across a face

    Scheduled Pinned Locked Moved Developers' Forum
    14 Posts 4 Posters 1.2k 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.
    • A Offline
      ArunYoganandan
      last edited by

      @dan rathbun said:

      You might use THAT image as a material applied to the face. Then adjust the corners of the material image to the face's vertices. ??

      Hi Dan,

      Thanks for your reply. What I'm trying to do is build a sliceable color cube like
      http://www.sonycsl.co.jp/person/nielsen/visualcomputing/programs/colorcube-1.png
      This is an immersive system and the user would be able to grab a corner and move it within the original cube's dimensions in 3D to
      indicate the color desired. i.e, position 0.4,0.1,0.3 within the cube will denote the corresponding RGB values.
      When the corner is moved, the faces will also correspondingly change in shape/fragment (Exactly like how it would behave when the vertex of a cube is moved in sketchup)
      revealing new colors at the depth (like slicing a volume with interpolated colors).

      Simply put, the faces of the cube get modified to different configurations and hence I will not be able to use a static texture. Something like a GLSL shader would be perfect except I don't think we could do that in SU?

      Thanks,
      Arun

      1 Reply Last reply Reply Quote 0
      • 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