Color interpolation across a face
-
If you are thinking of creating the images "on-the-fly" then you'll need to use a 3rd party Library, such as ImageMajik etc. SketchUp does use PaintLib internally, but I do not know of anyone accessing it.
-
@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 -
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.
-
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
-
To draw in OpenGL style (either 3D or 2D,) in SketchUp, must be done within a
Tool
class, using theView
instance's family ofdraw
methods.see:
https://developers.google.com/sketchup/docs/ourdoc/view#draw -
So.. for color interpolation within a
Tool
class, when you set the color (just prior to painting a point,) withview.drawing_color=()
you would evaluate the argument using color.blendThe 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. -
The API doesn't let you set vertex colour. Wish it did.
-
That's not what he wants.
He wants to draw multi-gradient color fill, on-the-fly.
-
@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.
-
Yep.. it would be nice to have more OpenGL draw functions.
Implementing a shader in Ruby is bound to be slow. -
@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 takeColor.interpolate(color1, color2,...)
of https://bitbucket.org/Aerilius/color/wiki/Home -
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.
Advertisement