GH Developer: Issue rendering in macOS

Hello!

As part of Sheepdog, I have noticed an issue with rendering my Fence objects between Windows and Mac. Fences are drawn fine in Windows. However, in Mac, they are not shown in the right colour (shown in black instead, but notice the name is indeed shown with the correct colour, purple in this case).

When the Fence is selected though, it is shown in the right colour.

And finally, beyond a certain zoom level, the fence is shown with some transparency (again, it is drawn fine when selected)

None of this happens in Windows version, so I’m assuming it is a bug.

These are being drawn with this method:
graphics.DrawPath(pen, path);

Any ideas why this might happen/how to fix it?

Thanks,
Pablo

Hi,

I’m not 100% sure, but this looks to me like a Mac drawing/rendering difference rather than a problem with the actual colour.

The text is coming through in the right colour, and the selected state also seems to draw correctly, so I’d guess the colour value itself is fine. The suspicious part is the path stroke, especially if the pen has any dash pattern, custom caps, joins, transparency, etc.

I’d probably try reducing it to a very plain pen first:

using (var testPen = new Pen(Color.Magenta, 6f))
{
    graphics.DrawPath(testPen, path);
}

If that works on Mac, then add the original pen settings back one by one until it breaks. My first guess would be something related to the dashed/rounded pen settings.

If it turns out to be the dashed pen, a possible workaround would be to draw the dash segments yourself with a normal solid pen instead of relying on the Pen dash style.

Also, check which GH_CanvasChannel you’re drawing in, just in case Grasshopper is applying some canvas/wire fading behaviour there.

So I don’t think this is obviously something wrong in your code. It might just be one of those System.Drawing / Grasshopper canvas differences between Windows and macOS. A small sample with the exact pen setup would probably help narrow it down.