internal HistoryData(int Capacity, IColorType Color) { m_Color = Color.GetAsRGBA_Bytes(); m_Capacity = Capacity; m_Data = new TwoSidedStack<double>(); Reset(); }
public PointLight(LightMaterial mt, Point pt) : base(mt) { float pdf; this.Position = pt; this.power = mt.GetEmittance(0f, 0f, out pdf); }
internal HistoryData(int capacity, IColorType lineColor) { this.lineColor = lineColor.GetAsRGBA_Bytes(); this.capacity = capacity; data = new List<double>(); Reset(); }
public override void EvaluateShadow(ShadePointInfo pt, float u0, float u1, float u2, out IColorType radiance, out float pdf, out RayData ray) { var wi = MC.CosineSampleHemisphere(u1, u2); pdf = wi.z * MathLab.INVPI; wi = pt.Frame.ToWorld(ref wi); ray = new RayData(ref pt.HitPoint, ref wi, 1e-4f, float.MaxValue); radiance = Le(ref wi); }
public override void F(ShadePointInfo pt, out IColorType fs, BrdfType types = BrdfType.Diffuse) { float c = 1f - Vector.Dot(ref pt.IncomingDirection, ref pt.ShadingNormal); float Re = R0 + (1f - R0) * c * c * c * c * c; float P = .25f + .5f * Re; fs = pt.Diffuse.CloneValue().Mul(MathLab.INVPI).Mul((1f - Re) / (1f - P)); }
public override void EvaluateIllumination(RayEngineScene scn, float u0, float u1, float u2, float u3, float u4, out RayData ray, out float pdf, out IColorType radiance) { Vector dir = MC.UniformSampleSphere(u0, u1); ray = new RayData(ref Position, ref dir, 1e-4f, 1e4f); pdf = MathLab.INV4PI; radiance = (power.Mul(MathLab.M_PI * 4f)); }
public override void EvaluateShadow(ShadePointInfo pt, float u0, float u1, float u2, out IColorType radiance, out float pdf, out RayData ray) { var dir = -(Position - pt.HitPoint); var l2 = dir.Length2(); var l = MathLab.Sqrt(l2); dir.Normalize(); pdf = MC.UniformSpherePdf(); ray = new RayData(ref pt.HitPoint, ref dir, 1e-4f, l - 1e-4f); radiance = power.Mul(1f / l); //float theta = Vector.SphericalTheta(ref dir); //Profile.Evaluate(Vector.SphericalPhi(ref dir) * MathLab.INVTWOPI, theta * MathLab.INVPI); }
public RadioButtonGroup(Vector2 location, Vector2 size) : base(FlowDirection.TopToBottom) { Margin = new BorderDouble(); Padding = new BorderDouble(5); LocalBounds = new RectangleDouble(0, 0, size.x, size.y); OriginRelativeParent = location; radioButtons = new List<RadioButton>(); backgroundColor = (new RGBA_Floats(1.0, 1.0, 0.9)); borderColor = (new RGBA_Floats(0.0, 0.0, 0.0)); textColor = (new RGBA_Floats(0.0, 0.0, 0.0)); inactiveColor = (new RGBA_Floats(0.0, 0.0, 0.0)); activeColor = (new RGBA_Floats(0.4, 0.0, 0.0)); }
public TextWidget(string Text, double left, double bottom, double CapitalHeight) : base(0, 0, 0, 0) { m_text_color = (new RGBA_Doubles(0.0, 0.0, 0.0)); m_BorderSize = CapitalHeight * .2; m_Thickness = CapitalHeight / 8; m_CapsHeight = CapitalHeight; m_text = new GsvText(); m_text.Text = Text; m_text_poly = new StrokeConverter(m_text); m_idx = (0); double MinX, MinY, MaxX, MaxY; GetTextBounds(out MinX, out MinY, out MaxX, out MaxY); double FullWidth = MaxX - MinX + m_BorderSize * 2; double FullHeight = m_CapsHeight + m_text.AscenderHeight + m_text.DescenderHeight + m_BorderSize * 2; Bounds = new RectD(left, bottom, left + FullWidth, bottom + FullHeight); }
public override void Render(IVertexSource vertexSource, int pathIndexToRender, IColorType colorBytes) { rasterizer.reset(); Affine transform = GetTransform(); if (!transform.is_identity()) { vertexSource = new VertexSourceApplyTransform(vertexSource, transform); } rasterizer.add_path(vertexSource, pathIndexToRender); if (destImageByte != null) { scanlineRenderer.RenderSolid(destImageByte, rasterizer, m_ScanlineCache, colorBytes.GetAsRGBA_Bytes()); DestImage.MarkImageChanged(); } else { scanlineRenderer.RenderSolid(destImageFloat, rasterizer, m_ScanlineCache, colorBytes.GetAsRGBA_Floats()); destImageFloat.MarkImageChanged(); } }
public override void Clear(IColorType iColor) { RectangleDouble clippingRect = GetClippingRect(); RectangleInt clippingRectInt = new RectangleInt((int)clippingRect.Left, (int)clippingRect.Bottom, (int)clippingRect.Right, (int)clippingRect.Top); if (DestImage != null) { RGBA_Bytes color = iColor.GetAsRGBA_Bytes(); int width = DestImage.Width; int height = DestImage.Height; byte[] buffer = DestImage.GetBuffer(); switch (DestImage.BitDepth) { case 8: { byte byteColor = (byte)iColor.Red0To255; for (int y = clippingRectInt.Bottom; y < clippingRectInt.Top; y++) { int bufferOffset = DestImage.GetBufferOffsetXY((int)clippingRect.Left, y); int bytesBetweenPixels = DestImage.GetBytesBetweenPixelsInclusive(); for (int x = 0; x < clippingRectInt.Width; x++) { buffer[bufferOffset] = color.blue; bufferOffset += bytesBetweenPixels; } } } break; case 24: for (int y = clippingRectInt.Bottom; y < clippingRectInt.Top; y++) { int bufferOffset = DestImage.GetBufferOffsetXY((int)clippingRect.Left, y); int bytesBetweenPixels = DestImage.GetBytesBetweenPixelsInclusive(); for (int x = 0; x < clippingRectInt.Width; x++) { buffer[bufferOffset + 0] = color.blue; buffer[bufferOffset + 1] = color.green; buffer[bufferOffset + 2] = color.red; bufferOffset += bytesBetweenPixels; } } break; case 32: { for (int y = clippingRectInt.Bottom; y < clippingRectInt.Top; y++) { int bufferOffset = DestImage.GetBufferOffsetXY((int)clippingRect.Left, y); int bytesBetweenPixels = DestImage.GetBytesBetweenPixelsInclusive(); for (int x = 0; x < clippingRectInt.Width; x++) { buffer[bufferOffset + 0] = color.blue; buffer[bufferOffset + 1] = color.green; buffer[bufferOffset + 2] = color.red; buffer[bufferOffset + 3] = color.alpha; bufferOffset += bytesBetweenPixels; } } } break; default: throw new NotImplementedException(); } } else // it is a float { if (DestImageFloat == null) { throw new Exception("You have to have either a byte or float DestImage."); } RGBA_Floats color = iColor.GetAsRGBA_Floats(); int width = DestImageFloat.Width; int height = DestImageFloat.Height; float[] buffer = DestImageFloat.GetBuffer(); switch (DestImageFloat.BitDepth) { case 128: for (int y = 0; y < height; y++) { int bufferOffset = DestImageFloat.GetBufferOffsetXY(clippingRectInt.Left, y); int bytesBetweenPixels = DestImageFloat.GetFloatsBetweenPixelsInclusive(); for (int x = 0; x < clippingRectInt.Width; x++) { buffer[bufferOffset + 0] = color.blue; buffer[bufferOffset + 1] = color.green; buffer[bufferOffset + 2] = color.red; buffer[bufferOffset + 3] = color.alpha; bufferOffset += bytesBetweenPixels; } } break; default: throw new NotImplementedException(); } } }
public void line_color(IColorType c) { m_color = c.ToColorF(); }
public override unsafe void MakePixel(byte *p, IColorType c) { throw new System.NotImplementedException(); }
public void BackgroundColor(IColorType bk) { unsafe { m_pixf.MakePixel(m_pBackBufferColor, bk); } }
//-------------------------------------------------------------------- unsafe public void MakePixel(byte *p, IColorType c) { p[0] = (byte)c.A_Byte; }
//-------------------------------------------------------------------- unsafe public void MakePixel(byte *p, IColorType c) { p[_orderR] = (byte)c.R_Byte; p[_orderG] = (byte)c.G_Byte; p[_orderB] = (byte)c.B_Byte; }
public void active_color(IColorType c) { activeColor = c.GetAsRGBA_Bytes(); }
public abstract void Render(IVertexSource vertexSource, int pathIndexToRender, IColorType colorType);
public void inactive_color(IColorType c) { inactiveColor = c; }
public void active_color(IColorType c) { activeColor = c; }
public void text_color(IColorType c) { textColor = c; }
public void border_color(IColorType c) { borderColor = c; }
public void background_color(IColorType c) { backgroundColor = c; }
public void line_color(IColorType c) { m_color = c; }
public void Render(IVertexSource vertexSource, IColorType color) { Render(vertexSource, 0, color); }
//-------------------------------------------------------------------- public void Clear(IColorType in_c) { uint y; RGBA_Bytes c = new RGBA_Bytes(in_c.R_Byte, in_c.G_Byte, in_c.B_Byte, in_c.A_Byte); if (Width != 0) { for (y = 0; y < Height; y++) { base.CopyHorizontalLine(0, (int)y, Width, c); } } }
public void Render(IVertexSource vertexSource, double x, double y, IColorType color) { Render(new VertexSourceApplyTransform(vertexSource, Affine.NewTranslation(x, y)), 0, color); }
public void ActiveColor(IColorType c) { m_active_color = c.GetAsRGBA_Doubles(); }
//-------------------------------------------------------------------- public span_image_filter_rgb_bilinear_clip(IRasterBufferAccessor src, IColorType back_color, ISpanInterpolator inter) : base(src, inter, null) { m_back_color = back_color.GetAsRGBA_Bytes(); OrderR = src.PixelFormat.Blender.OrderR; OrderG = src.PixelFormat.Blender.OrderG; OrderB = src.PixelFormat.Blender.OrderB; OrderA = src.PixelFormat.Blender.OrderA; }
public void line_color(IColorType c) { m_color = c.GetAsRGBA_Doubles(); }
//-------------------------------------------------------------------- public void colors(IColorType c1, IColorType c2, IColorType c3) { m_coord[0].color = c1.GetAsRGBA_Bytes(); m_coord[1].color = c2.GetAsRGBA_Bytes(); m_coord[2].color = c3.GetAsRGBA_Bytes(); }
public curve3_ctrl() { m_color = new ColorF(0.0, 0.0, 0.0); }
public abstract void Clear(IColorType color);
public void colors(IColorType c1, IColorType c2, IColorType c3) { m_coord[0].color = c1.ToColor(); m_coord[1].color = c2.ToColor(); m_coord[2].color = c3.ToColor(); }
public void FillRectangle(Vector2 leftBottom, Vector2 rightTop, IColorType fillColor) { FillRectangle(leftBottom.x, leftBottom.y, rightTop.x, rightTop.y, fillColor); }
public override void FillRectangle(double left, double bottom, double right, double top, IColorType fillColor) { RoundedRect rect = new RoundedRect(left, bottom, right, top, 0); Render(rect, fillColor.GetAsRGBA_Bytes()); }
public span_image_filter_rgba_bilinear_clip(IImageBufferAccessor src, IColorType back_color, ISpanInterpolator inter) : base(src, inter, null) { m_OutsideSourceColor = back_color.GetAsRGBA_Bytes(); }
public void Render(IVertexSource vertexSource, Vector2 position, IColorType color) { Render(new VertexSourceApplyTransform(vertexSource, Affine.NewTranslation(position.x, position.y)), 0, color); }
public curve3_ctrl() { m_color = new RGBA_Doubles(0.0, 0.0, 0.0); }
public void background_color(IColorType v) { m_back_color = v.GetAsRGBA_Bytes(); }
public void FillRectangle(RectangleInt rect, IColorType fillColor) { FillRectangle(rect.Left, rect.Bottom, rect.Right, rect.Top, fillColor); }
public abstract void FillRectangle(double left, double bottom, double right, double top, IColorType fillColor);
public override void FillRectangle(double left, double bottom, double right, double top, IColorType fillColor) { var rect = new RoundedRect(left, bottom, right, top, 0); Render(rect, fillColor.ToColor()); }
public void background_color(IColorType v) { m_OutsideSourceColor = v.GetAsRGBA_Bytes(); }
public override void Clear(IColorType iColor) { RectangleDouble clippingRect = GetClippingRect(); var clippingRectInt = new RectangleInt((int)clippingRect.Left, (int)clippingRect.Bottom, (int)clippingRect.Right, (int)clippingRect.Top); if (DestImage != null) { var color = iColor.ToColor(); byte[] buffer = DestImage.GetBuffer(); switch (DestImage.BitDepth) { case 8: { for (int y = clippingRectInt.Bottom; y < clippingRectInt.Top; y++) { int bufferOffset = DestImage.GetBufferOffsetXY((int)clippingRect.Left, y); int bytesBetweenPixels = DestImage.GetBytesBetweenPixelsInclusive(); for (int x = 0; x < clippingRectInt.Width; x++) { buffer[bufferOffset] = color.blue; bufferOffset += bytesBetweenPixels; } } } break; case 24: for (int y = clippingRectInt.Bottom; y < clippingRectInt.Top; y++) { int bufferOffset = DestImage.GetBufferOffsetXY((int)clippingRect.Left, y); int bytesBetweenPixels = DestImage.GetBytesBetweenPixelsInclusive(); for (int x = 0; x < clippingRectInt.Width; x++) { buffer[bufferOffset + 0] = color.blue; buffer[bufferOffset + 1] = color.green; buffer[bufferOffset + 2] = color.red; bufferOffset += bytesBetweenPixels; } } break; case 32: { for (int y = clippingRectInt.Bottom; y < clippingRectInt.Top; y++) { int bufferOffset = DestImage.GetBufferOffsetXY((int)clippingRect.Left, y); int bytesBetweenPixels = DestImage.GetBytesBetweenPixelsInclusive(); for (int x = 0; x < clippingRectInt.Width; x++) { buffer[bufferOffset + 0] = color.blue; buffer[bufferOffset + 1] = color.green; buffer[bufferOffset + 2] = color.red; buffer[bufferOffset + 3] = color.alpha; bufferOffset += bytesBetweenPixels; } } } break; default: throw new NotImplementedException(); } DestImage.MarkImageChanged(); } else // it is a float { if (DestImageFloat == null) { throw new Exception("You have to have either a byte or float DestImage."); } var color = iColor.ToColorF(); int height = DestImageFloat.Height; float[] buffer = DestImageFloat.GetBuffer(); switch (DestImageFloat.BitDepth) { case 128: for (int y = 0; y < height; y++) { int bufferOffset = DestImageFloat.GetBufferOffsetXY(clippingRectInt.Left, y); int bytesBetweenPixels = DestImageFloat.GetFloatsBetweenPixelsInclusive(); for (int x = 0; x < clippingRectInt.Width; x++) { buffer[bufferOffset + 0] = color.blue; buffer[bufferOffset + 1] = color.green; buffer[bufferOffset + 2] = color.red; buffer[bufferOffset + 3] = color.alpha; bufferOffset += bytesBetweenPixels; } } break; default: throw new NotImplementedException(); } } }
public unsafe override void MakePixel(byte* p, IColorType c) { throw new System.NotImplementedException(); }
public void text_color(IColorType c) { m_text_color = c.GetAsRGBA_Doubles(); }
public void TextColor(IColorType c) { m_text_color = c.GetAsRGBA_Doubles(); }
public void active_color(IColorType c) { m_active_color = c.GetAsRGBA_Doubles(); }
/// <summary> /// /// </summary> /// <param name="color"></param> public void Clear(IColorType color) { /*FormatClippingProxy clipper = (FormatClippingProxy)m_PixelFormat; if(clipper != null) { clipper.Clear(color); }*/ }
public override void FillRectangle(double left, double bottom, double right, double top, IColorType fillColor) { // This only works for translation. If we have a rotation or scale in the transform this will have some problems. Affine transform = GetTransform(); double fastLeft = left; double fastBottom = bottom; double fastRight = right; double fastTop = top; transform.transform(ref fastLeft, ref fastBottom); transform.transform(ref fastRight, ref fastTop); if (Math.Abs(fastLeft - (int)fastLeft) < .01 && Math.Abs(fastBottom - (int)fastBottom) < .01 && Math.Abs(fastRight - (int)fastRight) < .01 && Math.Abs(fastTop - (int)fastTop) < .01) { PushOrthoProjection(); GL.Disable(EnableCap.Texture2D); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.Blend); GL.Color4(fillColor.Red0To255, fillColor.Green0To255, fillColor.Blue0To255, fillColor.Alpha0To255); GL.Begin(BeginMode.Triangles); // triangle 1 { GL.Vertex2(fastLeft, fastBottom); GL.Vertex2(fastRight, fastBottom); GL.Vertex2(fastRight, fastTop); } // triangle 2 { GL.Vertex2(fastLeft, fastBottom); GL.Vertex2(fastRight, fastTop); GL.Vertex2(fastLeft, fastTop); } GL.End(); PopOrthoProjection(); } else { var rect = new RoundedRect(left, bottom, right, top, 0); Render(rect, fillColor.ToColor()); } }