public static Matrix GetTransform(this Node node) { double anchorX = node.AnchorX * node.Width; double anchorY = node.AnchorY * node.Height; Matrix transform = new Matrix (); transform.Translate (node.X + anchorX, node.Y + anchorY); transform.Rotate (node.Rotation); transform.Scale (node.Scale, node.Scale); transform.Translate (-anchorX, -anchorY); return transform; }
public bool OnExpose(Context ctx, Gdk.Rectangle viewport) { double percent = Math.Min ((DateTime.UtcNow - start).Ticks / (double) duration.Ticks, 1.0); frames ++; //ctx.Matrix = m; SurfacePattern p = new SurfacePattern (buffer.Surface); p.Filter = Filter.Fast; Matrix m = new Matrix (); m.Translate (pan_x * zoom, pan_y * zoom); m.Scale (zoom, zoom); zoom *= .98; p.Matrix = m; ctx.Source = p; ctx.Paint (); p.Destroy (); return percent < 1.0; }
public bool OnExpose(Context ctx, Gdk.Rectangle viewport) { double percent = Math.Min ((DateTime.UtcNow - start).Ticks / (double) duration.Ticks, 1.0); //Matrix m = info.Fill (allocation); Matrix m = new Matrix (); m.Translate (pan_x, pan_y); m.Scale (zoom, zoom); ctx.Matrix = m; SurfacePattern p = new SurfacePattern (info.Surface); ctx.Source = p; ctx.Paint (); p.Destroy (); return percent < 1.0; }
public Matrix Fit(Gdk.Rectangle viewport) { Matrix m = new Matrix (); m.InitIdentity (); double scale = Math.Min (viewport.Width / (double) Bounds.Width, viewport.Height / (double) Bounds.Height); double x_offset = (viewport.Width - Bounds.Width * scale) / 2.0; double y_offset = (viewport.Height - Bounds.Height * scale) / 2.0; m.Translate (x_offset, y_offset); m.Scale (scale, scale); return m; }
// // this functions calculates the transformation needed to center and completely fill the // viewport with the Surface at the given tilt // public Matrix Fill(Gdk.Rectangle viewport, double tilt) { if (tilt == 0.0) return Fill (viewport); Matrix m = new Matrix (); m.InitIdentity (); double len; double orig_len; if (Bounds.Width > Bounds.Height) { len = viewport.Height; orig_len = Bounds.Height; } else { len = viewport.Width; orig_len = Bounds.Width; } double a = Math.Sqrt (viewport.Width * viewport.Width + viewport.Height * viewport.Height); double alpha = Math.Acos (len / a); double theta = alpha - Math.Abs (tilt); double slen = a * Math.Cos (theta); double scale = slen / orig_len; double x_offset = (viewport.Width - Bounds.Width * scale) / 2.0; double y_offset = (viewport.Height - Bounds.Height * scale) / 2.0; m.Translate (x_offset, y_offset); m.Scale (scale, scale); m.Invert (); m.Translate (viewport.Width * 0.5, viewport.Height * 0.5); m.Rotate (tilt); m.Translate (viewport.Width * -0.5, viewport.Height * -0.5); m.Invert (); return m; }
public static Matrix ViewToControlMatrix(Rectangle controlBounds, Rectangle view, double settingsWidth, double settingsHeight) { var m = new Matrix (); m.Translate (view.X - controlBounds.X, view.Y - controlBounds.Y); m.Scale (view.Width / settingsWidth, view.Height / settingsHeight); return m; }
public static Matrix ViewToBufferMatrix(Rectangle controlBounds, Rectangle view, double settingsWidth, double settingsHeight) { var m = new Matrix (); m.Scale ((float)(view.Width / settingsWidth), (float)(view.Height / settingsHeight)); return m; }
private static Matrix ComputeMatrix (RotateZoomData data) { var xform = new Matrix (); var image_size = PintaCore.Workspace.ImageSize; var center_x = image_size.Width / 2.0; var center_y = image_size.Height / 2.0; xform.Translate ((1 + data.Pan.X) * center_x, (1 + data.Pan.Y) * center_y); xform.Rotate ((-data.Angle / 180d) * Math.PI); xform.Scale (data.Zoom, data.Zoom); xform.Translate (-center_x, -center_y); return xform; }