/// <summary> /// <para>Returns the height and width resulting from a transformation of an existing height and width.</para> /// <para>Original signature is : CGSize CGSizeApplyAffineTransform ( CGSize size, CGAffineTransform t );</para> /// <para>Available in Mac OS X version 10.0 and later.</para> /// </summary> /// <param name="size">A size that specifies the height and width to transform.</param> /// <param name="t">The affine transform to apply.</param> /// <returns>A new size resulting from applying the specified affine transform to the existing size.</returns> public static CGSize CGSizeApplyAffineTransform (CGSize size, CGAffineTransform t) { return new CGSize ( t.a * size.width + t.c * size.height + t.tx, t.b * size.width + t.d * size.height + t.ty ); }
public void SetOffsetFromPoint(NSPoint point) { CGSize offset; NSRect bounds = this.Bounds; offset.width = (point.x - NSRect.NSMidX(bounds))/(NSRect.NSWidth(bounds)/2); offset.height = (point.y - NSRect.NSMidY(bounds))/(NSRect.NSHeight(bounds)/2); float radius = (float) Math.Sqrt(offset.width*offset.width + offset.height*offset.height); if (radius > 1) { offset.width /= radius; offset.height /= radius; } if (CGSize.CGSizeEqualToSize(this._offset, offset) == 0) { this._offset = offset; this.NeedsDisplay = true; NSNotificationCenter.DefaultCenter.PostNotificationNameObject(ShadowOffsetChanged, this); } }
public override Id InitWithFrame(NSRect frame) { this.NativePointer = this.SendMessageSuper<IntPtr>(ShadowOffsetViewClass, "initWithFrame:", frame); this._offset = CGSize.CGSizeZero; return this; }
/// <summary> /// Converts a <see cref="CGSize"/> instance to a <see cref="NSSize"/> /// </summary> /// <param name="cgsize">The <see cref="CGSize"/> to convert.</param> /// <returns>A new <see cref="NSSize"/> instance.</returns> public static NSSize NSSizeFromCGSize(CGSize cgsize) { return NSMakeSize(cgsize.width, cgsize.height); }
/// <summary> /// Translates the point by the specified size. /// </summary> /// <param name="cgPoint">A point.</param> /// <param name="cgSize">A size.</param> /// <returns></returns> public static CGPoint Substract(CGPoint cgPoint, CGSize cgSize) { return new CGPoint(cgPoint.x - cgSize.width, cgPoint.y - cgSize.height); }
/// <summary> /// Translates the point by the specified size. /// </summary> /// <param name="cgPoint">A point.</param> /// <param name="cgSize">A size.</param> /// <returns></returns> public static CGPoint Add(CGPoint cgPoint, CGSize cgSize) { return new CGPoint(cgPoint.x + cgSize.width, cgPoint.y + cgSize.height); }