示例#1
0
        void _drawImageNine(Image image, Rect src, Rect center, Rect dst, Paint paint)
        {
            D.assert(image != null);
            D.assert(center != null);
            D.assert(dst != null);
            D.assert(paint != null);

            var scaleX = 1f / image.width;
            var scaleY = 1f / image.height;

            if (src == null)
            {
                src = Rect.one;
            }
            else
            {
                src = src.scale(scaleX, scaleY);
            }

            center = center.scale(scaleX, scaleY);

            var layer = this._currentLayer;
            var state = layer.currentState;

            var mesh = ImageMeshGenerator.imageNineMesh(state.matrix, src, center, image.width, image.height, dst);

            if (!this._applyClip(mesh.bounds))
            {
                return;
            }

            layer.draws.Add(CanvasShader.tex(layer, paint, mesh, image));
        }
示例#2
0
        public void drawImageRect(Image image, Rect src, Rect dst, Paint paint)
        {
            D.assert(image != null);
            D.assert(dst != null);
            D.assert(paint != null);

            if (src == null)
            {
                src = Rect.one;
            }
            else
            {
                src = src.scale(1f / image.width, 1f / image.height);
            }

            var state = this._getState();
            var mesh  = ImageMeshGenerator.imageMesh(state.matrix, src, dst);

            if (!this._applyClip(mesh.bounds))
            {
                return;
            }

            var layer = this._getLayer();

            layer.draws.Add(CanvasShader.tex(layer, paint, mesh, image));
        }