Exemple #1
0
        public override ICanvasImage GetRender(ICanvasResourceCreator resourceCreator, Layerage layerage)
        {
            Transformer transformer = base.Transform.Transformer;

            CanvasGeometry geometry = transformer.ToRectangle(resourceCreator);


            CanvasCommandList command = new CanvasCommandList(resourceCreator);

            using (CanvasDrawingSession drawingSession = command.CreateDrawingSession())
            {
                if (this.Transform.IsCrop)
                {
                    CanvasGeometry geometryCrop = this.Transform.CropTransformer.ToRectangle(resourceCreator);

                    CanvasGeometryRelation relation = geometry.CompareWith(geometryCrop);
                    switch (relation)
                    {
                    case CanvasGeometryRelation.Disjoint:
                        return(null);

                    case CanvasGeometryRelation.Contained:
                        this.PatternRenderCore(resourceCreator, drawingSession, geometry, geometry);
                        break;

                    case CanvasGeometryRelation.Contains:
                        this.PatternRenderCore(resourceCreator, drawingSession, geometry, geometryCrop);
                        break;

                    case CanvasGeometryRelation.Overlap:
                        Matrix3x2      zero    = Matrix3x2.CreateTranslation(0.0f, 0.0f);
                        CanvasGeometry combine = geometry.CombineWith(geometryCrop, zero, CanvasGeometryCombine.Intersect);
                        this.PatternRenderCore(resourceCreator, drawingSession, geometry, combine);
                        break;

                    default:
                        return(null);
                    }
                }
                else
                {
                    this.PatternRenderCore(resourceCreator, drawingSession, geometry, geometry);
                }
            }
            return(command);
        }