# Color on a Surface

Wondering if anyone can help me understand why the surface I have here is showing GREEN at the beginning of the list [X,0] and RED at the end of the list [X,10] when the list is telling me otherwise.

Color on Surface.dyn (20.4 KB)

It looks like your colors are based on (121) points but youâ€™re applying them to a single surface.

EDIT: Were you expecting something more like this?

Iâ€™ve never tried applying a color gradient directly to a surface so Iâ€™m not sure if itâ€™s possible. You might try `FaceAnalysisDisplay.ByViewFacePointsAndValues`.

Thanks for the reply Nickâ€¦ Most of what I have is what I was looking for, trying to color the surface and not the points. I am using the Display.BySurfaceColors node. I just have the points up there to see where the color is being applied to along the surface. This is where Iâ€™m thinking that there might be something I donâ€™t understand correctly.

Even when I apply just a gradient color range across the surface I still get this weird thing happening with the color in the beginning and end of the list.

This isnâ€™t for Revit so the FaceAnalysisDisplay node wonâ€™t be much helpâ€¦ Iâ€™m uploading this to the web for use with Fractal.

Right, the only reason I showed the gradient with points is because (as far as Iâ€™m aware) itâ€™s not possible to apply a color gradient to a surface.

Yes you have a color range but thatâ€™s only for determining colors at the specific parameters. If you look at the output from Color Range itâ€™s likely a list of 121 individual colors and you canâ€™t apply multiple colors to a single surface. Your best bet is to either divide your surface into multiple smaller surfaces and apply colors to those OR use a lot more points to visually render a surface.

Using a 100x100 array of points instead of 10x10.

I thought the `Display.BySurfaceColors` node does just thatâ€¦ Colors a surface by individual colors at specific UV parameters based upon the list structureâ€¦ No?

Very possible. Iâ€™ve only ever used points to represent a gradient surface because it lets me run checks at a lower fidelity.

Can you explain more why you use points to do a gradient?

Honestly itâ€™s partly because Iâ€™ve never had any luck getting surface gradients to work. But it looks like thatâ€™s definitely possible.
Also because I can grade a large area quickly if I use a smaller fidelity (spacing of my points). But I donâ€™t know if thatâ€™s any quicker than properly using a surface gradient.

Still wondering if anyone has any possible explanations for this?.. Thanks!

Hi Amyâ€¦ the `.dyn` file is attached in the original post above

@Jason.Wheeler Ok I just had a look at it, the bool output of the â€śGeometry.DoesIntersectâ€ť was maintaining the list structure of the lines, which was formed by the z values of their start points, and the geometry intersects at x and y values so thatâ€™s why the list outputs all begin with red and ended with green.

I tried grouping the linesâ€™ start points by their y values, which fixed the list mixing, but still showed the strange gradients and color at the beginning and the end and also transposed the color mapping. The only way I can get a clean distinction of the two colors on the surface is by using â€ścount trueâ€ť and â€ścount falseâ€ť then list of repeated item (as shown below) but this also transposed the color mapping.

Thereâ€™s probably something I donâ€™t know about how the Display.BySurfaceColors node maps the color onto the surface but this has me curious In any case, the reason your lists were showing red in the beginning and green at the end was because of the z value grouping.

Is this the result you seek?

Otherwise, could you explain what you mean with â€śweird thing happening with the color in the beginning and end of the listâ€ť?

@Yna_Db with what you are showing, my question isâ€¦ at either end of the gradient along the surface there is the opposite color and Iâ€™m wondering why that is. Most likely it has to do with the way colors are applied to a surfaceâ€¦ From all my tests, no matter how the colors are applied this will happen, with the exception being that only one color is used instead of more than one.

@awilliams thanks for looking at the problemâ€¦ Iâ€™m sorry if I wasnâ€™t clear. There are no problems with the list structure, the issue Iâ€™m having is why the `Display.BySurfaceColors` node and how the colors are shown on the surface.

If you look again at the first image I posted. I was trying to explain that the point list and color list are the same structure and you can see that all the colors are in the correct locations along the surface. Below I highlighted where the transition from Red to Green is on both lists and that it compares to what is being shown in the geometry previewâ€¦ So the list is correctâ€¦ But what is shown in the geometry display has some kind of defect where the beginning and end are showing slight opposite colors, denoted in the red and blue circles.

I fixed up my graph to look like the one you have shown here, and even though you have changed the list and the color distribution from that list I donâ€™t completely understand, if you zoom in close to the top and bottom edges of that surface you will get the same problem with their being slight gradients.

The unwanted gradient border effect tends to disappear when increasing the density of UVs but it takes also longer to compute:

1 Like

@Jason.Wheeler ohh I had thought you were wondering about both the list structure showing mixed colors within the sublist, and the odd gradient effect. I hadnâ€™t zoomed in so much so the graph I set up had appeared to me to be a clean color distribution. My guess is that @Yna_Dbâ€™s suggestion makes the most sense, and that the slight gradients are due to a less dense UV distribution.

It looks like the color gradient is trying to wrap. This makes sense if you had a continuous surface but Iâ€™m not sure how you go about â€śfixingâ€ť it besides higher UV density, like @Yna_Db said.

1 Like

Maybe @Racel can shed some light on why the `Display.BySurfaceColors` node is acting this way, with the colors trying to wrap?

You can see with the default coloring that the color coordinates are â€ścenteredâ€ť unlike the UV coordinates that (most likely) go from `parameter = 0` to `parameter = 1` and hit the edges of the surface. So there is always a â€śborderâ€ť area around the color coordinate that wraps or transitions to the adjacent color.