コード例 #1
0
        private int AddJoint(int pointIndex, ref JoinSample joinSample, PenWorkspace ws, Buffer <CCVector2> insetBuffer, Buffer <CCVector2> outsetBuffer)
        {
            InsetOutsetCount vioCount = new InsetOutsetCount();

            switch (_pen.LineJoin)
            {
            case LineJoin.Miter:
                vioCount = _pen.ComputeMiter(ref joinSample, ws);
                break;

            case LineJoin.Bevel:
                vioCount = _pen.ComputeBevel(ref joinSample, ws);
                break;
            }

            if (insetBuffer != null)
            {
                for (int i = 0; i < vioCount.InsetCount; i++)
                {
                    insetBuffer.SetNext(ws.XYInsetBuffer[i]);
                }
            }
            if (outsetBuffer != null)
            {
                for (int i = 0; i < vioCount.OutsetCount; i++)
                {
                    outsetBuffer.SetNext(ws.XYOutsetBuffer[i]);
                }
            }

            return((_strokeType != StrokeType.Outline) ? AddJoint(pointIndex, vioCount, ws) : 0);
        }
コード例 #2
0
        private int AddJoint(int pointIndex, InsetOutsetCount vioCount, PenWorkspace ws)
        {
            int vIndex = _vertexBufferIndex;

            _vertexBufferIndex += vioCount.InsetCount + vioCount.OutsetCount;

            if (!vioCount.CCW)
            {
                _jointCCW[pointIndex]     = false;
                _positionData[vIndex + 0] = ws.XYOutsetBuffer[0];
                for (int i = 0; i < vioCount.InsetCount; i++)
                {
                    _positionData[vIndex + 1 + i] = ws.XYInsetBuffer[i];
                }

                for (int i = 0; i < vioCount.InsetCount - 1; i++)
                {
                    _indexData[_indexBufferIndex++] = (short)(vIndex);
                    _indexData[_indexBufferIndex++] = (short)(vIndex + i + 2);
                    _indexData[_indexBufferIndex++] = (short)(vIndex + i + 1);
                }
            }
            else
            {
                _jointCCW[pointIndex]     = true;
                _positionData[vIndex + 0] = ws.XYInsetBuffer[0];
                for (int i = 0; i < vioCount.OutsetCount; i++)
                {
                    _positionData[vIndex + 1 + i] = ws.XYOutsetBuffer[i];
                }

                for (int i = 0; i < vioCount.OutsetCount - 1; i++)
                {
                    _indexData[_indexBufferIndex++] = (short)(vIndex);
                    _indexData[_indexBufferIndex++] = (short)(vIndex + i + 1);
                    _indexData[_indexBufferIndex++] = (short)(vIndex + i + 2);
                }
            }

            if (_colorData != null)
            {
                if (!vioCount.CCW)
                {
                    _colorData[vIndex] = _pen.ColorAt(ws.UVOutsetBuffer[0], ws.PathLengthScale);
                    for (int i = 0; i < vioCount.InsetCount; i++)
                    {
                        _colorData[vIndex + 1 + i] = _pen.ColorAt(ws.UVInsetBuffer[i], ws.PathLengthScale);
                    }
                }
                else
                {
                    _colorData[vIndex] = _pen.ColorAt(ws.UVInsetBuffer[0], ws.PathLengthScale);
                    for (int i = 0; i < vioCount.OutsetCount; i++)
                    {
                        _colorData[vIndex + 1 + i] = _pen.ColorAt(ws.UVOutsetBuffer[i], ws.PathLengthScale);
                    }
                }
            }

            if (_textureData != null)
            {
                int texWidth  = _pen.Brush.Texture.XNATexture.Width;
                int texHeight = _pen.Brush.Texture.XNATexture.Height;

                for (int i = vIndex; i < _vertexBufferIndex; i++)
                {
                    CCVector2 pos = _positionData[i];
                    _textureData[i] = new CCVector2(pos.X / texWidth, pos.Y / texHeight);
                }
            }

            return(_vertexBufferIndex - vIndex);
        }
コード例 #3
0
ファイル: GraphicsPath.cs プロジェクト: Luckyknight1/LilyPath
        private int AddJoint (int pointIndex, InsetOutsetCount vioCount, PenWorkspace ws)
        {
            int vIndex = _vertexBufferIndex;

            _vertexBufferIndex += vioCount.InsetCount + vioCount.OutsetCount;

            if (!vioCount.CCW) {
                _jointCCW[pointIndex] = false;
                _positionData[vIndex + 0] = ws.XYOutsetBuffer[0];
                for (int i = 0; i < vioCount.InsetCount; i++)
                    _positionData[vIndex + 1 + i] = ws.XYInsetBuffer[i];

                for (int i = 0; i < vioCount.InsetCount - 1; i++) {
                    _indexData[_indexBufferIndex++] = (short)(vIndex);
                    _indexData[_indexBufferIndex++] = (short)(vIndex + i + 2);
                    _indexData[_indexBufferIndex++] = (short)(vIndex + i + 1);
                }
            }
            else {
                _jointCCW[pointIndex] = true;
                _positionData[vIndex + 0] = ws.XYInsetBuffer[0];
                for (int i = 0; i < vioCount.OutsetCount; i++)
                    _positionData[vIndex + 1 + i] = ws.XYOutsetBuffer[i];

                for (int i = 0; i < vioCount.OutsetCount - 1; i++) {
                    _indexData[_indexBufferIndex++] = (short)(vIndex);
                    _indexData[_indexBufferIndex++] = (short)(vIndex + i + 1);
                    _indexData[_indexBufferIndex++] = (short)(vIndex + i + 2);
                }
            }

            if (_colorData != null) {
                if (!vioCount.CCW) {
                    _colorData[vIndex] = _pen.ColorAt(ws.UVOutsetBuffer[0], ws.PathLengthScale);
                    for (int i = 0; i < vioCount.InsetCount; i++)
                        _colorData[vIndex + 1 + i] = _pen.ColorAt(ws.UVInsetBuffer[i], ws.PathLengthScale);
                }
                else {
                    _colorData[vIndex] = _pen.ColorAt(ws.UVInsetBuffer[0], ws.PathLengthScale);
                    for (int i = 0; i < vioCount.OutsetCount; i++)
                        _colorData[vIndex + 1 + i] = _pen.ColorAt(ws.UVOutsetBuffer[i], ws.PathLengthScale);
                }
            }

            if (_textureData != null) {
                int texWidth = _pen.Brush.Texture.Width;
                int texHeight = _pen.Brush.Texture.Height;

                for (int i = vIndex; i < _vertexBufferIndex; i++) {
                    Vector2 pos = _positionData[i];
                    _textureData[i] = new Vector2(pos.X / texWidth, pos.Y / texHeight);
                }
            }

            return _vertexBufferIndex - vIndex;
        }
コード例 #4
0
ファイル: GraphicsPath.cs プロジェクト: Luckyknight1/LilyPath
        private int AddJoint (int pointIndex, ref JoinSample joinSample, PenWorkspace ws, Buffer<Vector2> insetBuffer, Buffer<Vector2> outsetBuffer)
        {
            InsetOutsetCount vioCount = new InsetOutsetCount();

            switch (_pen.LineJoin) {
                case LineJoin.Miter:
                    vioCount = _pen.ComputeMiter(ref joinSample, ws);
                    break;
                case LineJoin.Bevel:
                    vioCount = _pen.ComputeBevel(ref joinSample, ws);
                    break;
            }

            if (insetBuffer != null) {
                for (int i = 0; i < vioCount.InsetCount; i++)
                    insetBuffer.SetNext(ws.XYInsetBuffer[i]);
            }
            if (outsetBuffer != null) {
                for (int i = 0; i < vioCount.OutsetCount; i++)
                    outsetBuffer.SetNext(ws.XYOutsetBuffer[i]);
            }

            return (_strokeType != StrokeType.Outline) ? AddJoint(pointIndex, vioCount, ws) : 0;
        }