Example #1
0
		// Used by the workspace drawing area expose render loop.
		// Takes care of the clipping.
		public void RenderLivePreviewLayer (Cairo.Context ctx, double opacity)
		{
			if (!IsEnabled)
				throw new InvalidOperationException ("Tried to render a live preview after live preview has ended.");
						
			// TODO remove seam around selection during live preview.
			
			ctx.Save ();
			if (selection_path != null) {
				
				// Paint area outsize of the selection path, with the pre-effect image.
				var imageSize = PintaCore.Workspace.ImageSize;
				ctx.Rectangle (0, 0, imageSize.Width, imageSize.Height);
				ctx.AppendPath (selection_path);
				ctx.Clip ();
				layer.Draw(ctx, layer.Surface, opacity);
				ctx.ResetClip ();
				
				// Paint area inside the selection path, with the post-effect image.
				ctx.AppendPath (selection_path);
				ctx.Clip ();
				
				layer.Draw(ctx, live_preview_surface, opacity);
				ctx.PaintWithAlpha (opacity);
				
				ctx.AppendPath (selection_path);
				ctx.FillRule = Cairo.FillRule.EvenOdd;
				ctx.Clip ();			
			} else {
				
				layer.Draw(ctx, live_preview_surface, opacity);
			}
			ctx.Restore ();
		}
Example #2
0
        public void Draw(Cairo.Context g, double scale, bool fillSelection)
        {
            g.Save ();
            g.Translate (0.5, 0.5);
            g.Scale (scale, scale);

            g.AppendPath (selection_path);

            if (fillSelection)
            {
                g.Color = new Cairo.Color (0.7, 0.8, 0.9, 0.2);
                g.FillRule = Cairo.FillRule.EvenOdd;
                g.FillPreserve ();
            }

            g.LineWidth = 1 / scale;

            // Draw a white line first so it shows up on dark backgrounds
            g.Color = new Cairo.Color (1, 1, 1);
            g.StrokePreserve ();

            // Draw a black dashed line over the white line
            g.SetDash (new double[] { 2 / scale, 4 / scale }, 0);
            g.Color = new Cairo.Color (0, 0, 0);

            g.Stroke ();
            g.Restore ();
        }