static Cairo.Color GetDrawingColorForIter (TextView view, TextIter iter) { TextIter start, end; Gdk.Color color; Gdk.Color bgColor; if (iter.Buffer.GetSelectionBounds (out start, out end) && iter.InRange (start, end)) { bgColor = view.Style.Base (StateType.Selected); color = view.Style.Text (StateType.Selected); } else { bgColor = view.Style.Base (StateType.Normal); color = view.Style.Text (StateType.Normal); } //simple interpolation 1/4 of way between BG colour and text colour int red = (bgColor.Red * 3 + color.Red ) / 4; int green = (bgColor.Green * 3 + color.Green) / 4; int blue = (bgColor.Blue * 3 + color.Blue ) / 4; return new Cairo.Color ((double)(red) / UInt16.MaxValue, (double)(green) / UInt16.MaxValue, (double)(blue) / UInt16.MaxValue); }