Exemplo n.º 1
0
 internal HistoryData(int Capacity, IColorType Color)
 {
 	m_Color = Color.GetAsRGBA_Bytes();
     m_Capacity = Capacity;
     m_Data = new TwoSidedStack<double>();
     Reset();
 }
Exemplo n.º 2
0
 public PointLight(LightMaterial mt, Point pt)
     : base(mt)
 {
     float pdf;
     this.Position = pt;
     this.power = mt.GetEmittance(0f, 0f, out pdf);
 }
Exemplo n.º 3
0
			internal HistoryData(int capacity, IColorType lineColor)
			{
				this.lineColor = lineColor.GetAsRGBA_Bytes();
				this.capacity = capacity;
				data = new List<double>();
				Reset();
			}
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
 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);
 }
Exemplo n.º 8
0
		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));
		}
Exemplo n.º 9
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);
 }
Exemplo n.º 10
0
		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();
			}
		}
Exemplo n.º 11
0
		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();
				}
			}
		}
Exemplo n.º 12
0
 public void line_color(IColorType c)
 {
     m_color = c.ToColorF();
 }
Exemplo n.º 13
0
 public override unsafe void MakePixel(byte *p, IColorType c)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 14
0
 public void BackgroundColor(IColorType bk)
 {
     unsafe { m_pixf.MakePixel(m_pBackBufferColor, bk); }
 }
Exemplo n.º 15
0
 //--------------------------------------------------------------------
 unsafe public void MakePixel(byte *p, IColorType c)
 {
     p[0] = (byte)c.A_Byte;
 }
Exemplo n.º 16
0
 public void BackgroundColor(IColorType bk)
 {
     unsafe { m_pixf.MakePixel(m_pBackBufferColor, bk); }
 }
Exemplo n.º 17
0
 //--------------------------------------------------------------------
 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;
 }
Exemplo n.º 18
0
 public void active_color(IColorType c)
 {
     activeColor = c.GetAsRGBA_Bytes();
 }
Exemplo n.º 19
0
 public abstract void Render(IVertexSource vertexSource, int pathIndexToRender, IColorType colorType);
Exemplo n.º 20
0
 public void inactive_color(IColorType c)
 {
     inactiveColor = c;
 }
Exemplo n.º 21
0
 public void active_color(IColorType c)
 {
     activeColor = c;
 }
Exemplo n.º 22
0
 public void text_color(IColorType c)
 {
     textColor = c;
 }
Exemplo n.º 23
0
 public void border_color(IColorType c)
 {
     borderColor = c;
 }
Exemplo n.º 24
0
 public void background_color(IColorType c)
 {
     backgroundColor = c;
 }
Exemplo n.º 25
0
 public void line_color(IColorType c)
 {
     m_color = c;
 }
Exemplo n.º 26
0
 public void Render(IVertexSource vertexSource, IColorType color)
 {
     Render(vertexSource, 0, color);
 }
Exemplo n.º 27
0
 //--------------------------------------------------------------------
 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);
         }
     }
 }
Exemplo n.º 28
0
 public void Render(IVertexSource vertexSource, double x, double y, IColorType color)
 {
     Render(new VertexSourceApplyTransform(vertexSource, Affine.NewTranslation(x, y)), 0, color);
 }
Exemplo n.º 29
0
 public void ActiveColor(IColorType c)
 {
     m_active_color = c.GetAsRGBA_Doubles();
 }
Exemplo n.º 30
0
        //--------------------------------------------------------------------
        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;
        }
Exemplo n.º 31
0
 public void line_color(IColorType c)
 {
     m_color = c.GetAsRGBA_Doubles();
 }
Exemplo n.º 32
0
		public abstract void Render(IVertexSource vertexSource, int pathIndexToRender, IColorType colorType);
Exemplo n.º 33
0
 //--------------------------------------------------------------------
 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();
 }
Exemplo n.º 34
0
		public void Render(IVertexSource vertexSource, double x, double y, IColorType color)
		{
			Render(new VertexSourceApplyTransform(vertexSource, Affine.NewTranslation(x, y)), 0, color);
		}
Exemplo n.º 35
0
 public curve3_ctrl()
 {
     m_color = new ColorF(0.0, 0.0, 0.0);
 }
Exemplo n.º 36
0
		public abstract void Clear(IColorType color);
Exemplo n.º 37
0
 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();
 }
Exemplo n.º 38
0
		public void FillRectangle(Vector2 leftBottom, Vector2 rightTop, IColorType fillColor)
		{
			FillRectangle(leftBottom.x, leftBottom.y, rightTop.x, rightTop.y, fillColor);
		}
Exemplo n.º 39
0
		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());
		}
Exemplo n.º 40
0
 public span_image_filter_rgba_bilinear_clip(IImageBufferAccessor src,
     IColorType back_color, ISpanInterpolator inter)
     : base(src, inter, null)
 {
     m_OutsideSourceColor = back_color.GetAsRGBA_Bytes();
 }
Exemplo n.º 41
0
 public void Render(IVertexSource vertexSource, Vector2 position, IColorType color)
 {
     Render(new VertexSourceApplyTransform(vertexSource, Affine.NewTranslation(position.x, position.y)), 0, color);
 }
Exemplo n.º 42
0
 public curve3_ctrl()
 {
     m_color = new RGBA_Doubles(0.0, 0.0, 0.0);
 }
Exemplo n.º 43
0
 public void background_color(IColorType v)
 {
     m_back_color = v.GetAsRGBA_Bytes();
 }
Exemplo n.º 44
0
 public abstract void Clear(IColorType color);
Exemplo n.º 45
0
		public void Render(IVertexSource vertexSource, IColorType color)
		{
			Render(vertexSource, 0, color);
		}
Exemplo n.º 46
0
 public void FillRectangle(RectangleInt rect, IColorType fillColor)
 {
     FillRectangle(rect.Left, rect.Bottom, rect.Right, rect.Top, fillColor);
 }
Exemplo n.º 47
0
		public void Render(IVertexSource vertexSource, Vector2 position, IColorType color)
		{
			Render(new VertexSourceApplyTransform(vertexSource, Affine.NewTranslation(position.x, position.y)), 0, color);
		}
Exemplo n.º 48
0
 public void FillRectangle(Vector2 leftBottom, Vector2 rightTop, IColorType fillColor)
 {
     FillRectangle(leftBottom.x, leftBottom.y, rightTop.x, rightTop.y, fillColor);
 }
Exemplo n.º 49
0
		public void FillRectangle(RectangleInt rect, IColorType fillColor)
		{
			FillRectangle(rect.Left, rect.Bottom, rect.Right, rect.Top, fillColor);
		}
Exemplo n.º 50
0
 public abstract void FillRectangle(double left, double bottom, double right, double top, IColorType fillColor);
Exemplo n.º 51
0
		public abstract void FillRectangle(double left, double bottom, double right, double top, IColorType fillColor);
Exemplo n.º 52
0
        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());
        }
Exemplo n.º 53
0
 public void background_color(IColorType v) { m_OutsideSourceColor = v.GetAsRGBA_Bytes(); }
Exemplo n.º 54
0
        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();
                }
            }
        }
Exemplo n.º 55
0
 public unsafe override void MakePixel(byte* p, IColorType c)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 56
0
 public void text_color(IColorType c)
 {
     m_text_color = c.GetAsRGBA_Doubles();
 }
Exemplo n.º 57
0
 public void TextColor(IColorType c)
 {
     m_text_color = c.GetAsRGBA_Doubles();
 }
Exemplo n.º 58
0
 public void active_color(IColorType c)
 {
     m_active_color = c.GetAsRGBA_Doubles();
 }
Exemplo n.º 59
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="color"></param>
 public void Clear(IColorType color)
 {
     /*FormatClippingProxy clipper = (FormatClippingProxy)m_PixelFormat;
     if(clipper != null)
     {
         clipper.Clear(color);
     }*/
 }
Exemplo n.º 60
0
        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());
            }
        }