public RGBA_Doubles(RGBA_Doubles c, double a_) { m_r = c.m_r; m_g = c.m_g; m_b = c.m_b; m_a = a_; }
public override void Render(IVertexSource vertexSource, int pathIndexToRender, RGBA_Bytes colorBytes) { #if use_timers OpenGLRenderTimer.Start(); #endif PushOrthoProjection(); vertexSource.rewind(pathIndexToRender); RGBA_Doubles color = colorBytes.GetAsRGBA_Doubles(); Gl.glColor4d(color.m_r, color.m_g, color.m_b, color.m_a); Affine transform = GetTransform(); if (!transform.is_identity()) { vertexSource = new conv_transform(vertexSource, transform); } if (m_ForceTexturedEdgeAntiAliasing) { DrawAAShape(vertexSource); } else { SendShapeToTeselator(m_RenderNowTesselator, vertexSource); } PopOrthoProjection(); #if use_timers OpenGLRenderTimer.Stop(); #endif }
public override void Render(IVertexSource vertexSource, uint pathIndexToRender, RGBA_Bytes colorBytes) { #if use_timers OpenGLRenderTimer.Start(); #endif PushOrthoProjection(); vertexSource.rewind(pathIndexToRender); RGBA_Doubles color = colorBytes.GetAsRGBA_Doubles(); Gl.glColor4d(color.m_r, color.m_g, color.m_b, color.m_a); m_Tesselator.BeginPolygon(); uint PathAndFlags = 0; double x, y; bool haveBegunContour = false; while (!Path.is_stop(PathAndFlags = vertexSource.vertex(out x, out y))) { if (Path.is_close(PathAndFlags) || (haveBegunContour && Path.is_move_to(PathAndFlags))) { m_Tesselator.EndContour(); haveBegunContour = false; } if (!Path.is_close(PathAndFlags)) { if (!haveBegunContour) { m_Tesselator.BeginContour(); haveBegunContour = true; } m_Tesselator.AddVertex(x, y); } } if (haveBegunContour) { m_Tesselator.EndContour(); } #if use_timers OpenGLEndPolygonTimer.Start(); #endif m_Tesselator.EndPolygon(); #if use_timers OpenGLEndPolygonTimer.Stop(); #endif PopOrthoProjection(); #if use_timers OpenGLRenderTimer.Stop(); #endif }
//-------------------------------------------------------------------- public RGBA_Bytes Gradient(RGBA_Bytes c_8, double k) { RGBA_Doubles c = c_8.GetAsRGBA_Doubles(); RGBA_Doubles ret; ret.m_r = m_r + (c.m_r - m_r) * k; ret.m_g = m_g + (c.m_g - m_g) * k; ret.m_b = m_b + (c.m_b - m_b) * k; ret.m_a = m_a + (c.m_a - m_a) * k; return(ret.GetAsRGBA_Bytes()); }
//-------------------------------------------------------------------- public RGBA_Doubles(RGBA_Doubles c) : this(c, 1) { }
public RGBA_Bytes(RGBA_Doubles c) { m_R = ((byte)Basics.RoundUint(c.m_r * (double)BaseMask)); m_G = ((byte)Basics.RoundUint(c.m_g * (double)BaseMask)); m_B = ((byte)Basics.RoundUint(c.m_b * (double)BaseMask)); m_A = ((byte)Basics.RoundUint(c.m_a * (double)BaseMask)); }
//-------------------------------------------------------------------- RGBA_Bytes(RGBA_Doubles c, double a_) { m_R = ((byte)Basics.RoundUint(c.m_r * (double)BaseMask)); m_G = ((byte)Basics.RoundUint(c.m_g * (double)BaseMask)); m_B = ((byte)Basics.RoundUint(c.m_b * (double)BaseMask)); m_A = ((byte)Basics.RoundUint(a_ * (double)BaseMask)); }
public static RGBA_Doubles GetTweenColor(RGBA_Doubles Color1, RGBA_Doubles Color2, double RatioOf2) { if (RatioOf2 <= 0) { return new RGBA_Doubles(Color1); } if (RatioOf2 >= 1.0) { return new RGBA_Doubles(Color2); } // figure out how much of each color we should be. double RatioOf1 = 1.0 - RatioOf2; return new RGBA_Doubles( Color1.m_r * RatioOf1 + Color2.m_r * RatioOf2, Color1.m_g * RatioOf1 + Color2.m_g * RatioOf2, Color1.m_b * RatioOf1 + Color2.m_b * RatioOf2); }
public static RGBA_Doubles RgbaPre(RGBA_Doubles c, double a) { return new RGBA_Doubles(c, a).PreMultiply(); }
public static RGBA_Doubles RgbaPre(RGBA_Doubles c) { return new RGBA_Doubles(c).PreMultiply(); }
public static RGBA_Doubles FromWavelength(double wl, double gamma) { RGBA_Doubles t = new RGBA_Doubles(0.0, 0.0, 0.0); if (wl >= 380.0 && wl <= 440.0) { t.m_r = -1.0 * (wl - 440.0) / (440.0 - 380.0); t.m_b = 1.0; } else if (wl >= 440.0 && wl <= 490.0) { t.m_g = (wl - 440.0) / (490.0 - 440.0); t.m_b = 1.0; } else if (wl >= 490.0 && wl <= 510.0) { t.m_g = 1.0; t.m_b = -1.0 * (wl - 510.0) / (510.0 - 490.0); } else if (wl >= 510.0 && wl <= 580.0) { t.m_r = (wl - 510.0) / (580.0 - 510.0); t.m_g = 1.0; } else if (wl >= 580.0 && wl <= 645.0) { t.m_r = 1.0; t.m_g = -1.0 * (wl - 645.0) / (645.0 - 580.0); } else if (wl >= 645.0 && wl <= 780.0) { t.m_r = 1.0; } double s = 1.0; if (wl > 700.0) s = 0.3 + 0.7 * (780.0 - wl) / (780.0 - 700.0); else if (wl < 420.0) s = 0.3 + 0.7 * (wl - 380.0) / (420.0 - 380.0); t.m_r = Math.Pow(t.m_r * s, gamma); t.m_g = Math.Pow(t.m_g * s, gamma); t.m_b = Math.Pow(t.m_b * s, gamma); return t; }
public void BeginCallBack(Tesselator.TriangleListType type) { m_VertexIndexList.Clear(); m_LineWidthList.Clear(); m_TriangleListType = type; m_LineWidth = .5; switch (m_TriangleListType) { case Tesselator.TriangleListType.Triangles: m_TriangleColor = new RGBA_Doubles(.1, 0, 0, .2); m_LineColor = new RGBA_Doubles(0, 0, 0); break; case Tesselator.TriangleListType.TriangleFan: m_TriangleColor = new RGBA_Doubles(0, 1, 0, .2); m_LineColor = new RGBA_Doubles(0, 0, 0); break; case Tesselator.TriangleListType.TriangleStrip: m_TriangleColor = new RGBA_Doubles(0, 0, 1, .2); m_LineColor = new RGBA_Doubles(0, 0, 0); break; case Tesselator.TriangleListType.LineLoop: m_LineColor = new RGBA_Doubles(m_ColorRand.NextDouble(), m_ColorRand.NextDouble(), m_ColorRand.NextDouble()); break; } }