Ejemplo n.º 1
0
 private void SetVertsColor(PositionColorNormalTexture[] verts, int startIndex, int count,
                            double x, double y, double width, double height)
 {
     verts[startIndex].Color     = ColorGradient.Interpolate(x, y).ToArgb();
     verts[startIndex + 1].Color = ColorGradient.Interpolate(x + width, y).ToArgb();
     verts[startIndex + 2].Color = ColorGradient.Interpolate(x, y + height).ToArgb();
     verts[startIndex + 3].Color = ColorGradient.Interpolate(x + width, y + height).ToArgb();
 }
Ejemplo n.º 2
0
        void DrawImpl(float destX, float destY, Rectangle srcRect, float rotationCenterX, float rotationCenterY)
        {
            SizeF dispSize = new SizeF(
                srcRect.Width * (float)ScaleWidth,
                srcRect.Height * (float)ScaleHeight);

            if (DisplaySize.Width < 0)
            {
                destX           -= dispSize.Width;
                rotationCenterX += dispSize.Width;
            }

            if (DisplaySize.Height < 0)
            {
                destY           -= dispSize.Height;
                rotationCenterY += dispSize.Height;
            }

            mTexCoord = GetTextureCoords(srcRect);

            mState.DrawBuffer.SetInterpolationMode(InterpolationHint);

            if (TesselateFactor == 1)
            {
                BufferQuad(destX, destY, rotationCenterX, rotationCenterY,
                           dispSize.Width, dispSize.Height, mTexCoord, ColorGradient);
            }
            else
            {
                TextureCoordinates texCoord = new TextureCoordinates();
                float texWidth  = mTexCoord.Right - mTexCoord.Left;
                float texHeight = mTexCoord.Bottom - mTexCoord.Top;

                float displayWidth  = DisplayWidth / (float)TesselateFactor;
                float displayHeight = DisplayHeight / (float)TesselateFactor;

                for (int j = 0; j < TesselateFactor; j++)
                {
                    texCoord.Top    = mTexCoord.Top + j * texHeight / TesselateFactor;
                    texCoord.Bottom = mTexCoord.Top + (j + 1) * texHeight / TesselateFactor;

                    for (int i = 0; i < TesselateFactor; i++)
                    {
                        texCoord.Left  = mTexCoord.Left + i * texWidth / TesselateFactor;
                        texCoord.Right = mTexCoord.Left + (i + 1) * texWidth / TesselateFactor;

                        float dx = destX + i * displayWidth * mRotationCos + j * displayHeight * mRotationSin;
                        float dy = destY - i * displayWidth * mRotationSin + j * displayHeight * mRotationCos;

                        double cx = i / (double)TesselateFactor;
                        double cy = j / (double)TesselateFactor;

                        Gradient color = new Gradient(
                            ColorGradient.Interpolate(cx, cy),
                            ColorGradient.Interpolate(cx + 1.0 / TesselateFactor, cy),
                            ColorGradient.Interpolate(cx, cy + 1.0 / TesselateFactor),
                            ColorGradient.Interpolate(cx + 1.0 / TesselateFactor, cy + 1.0 / TesselateFactor));

                        BufferQuad(dx, dy,
                                   rotationCenterX, rotationCenterY,
                                   displayWidth, displayHeight, texCoord, color);
                    }
                }
            }
            //GL.PushMatrix();

            //GL.Translatef(-translatePoint.X, -translatePoint.Y, 0);
            //GL.Rotatef((float)-RotationAngleDegrees, 0.0f, 0.0f, 1.0f);


            // restore the matrix
            //GL.PopMatrix();
        }