Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSGraphicsMBS class.

NSGraphicsMBS.clipRect(r as NSRectMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacCocoa Plugin 12.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Intersects the specified rectangle with the clipping path of the current graphics context and makes the resulting shape the current clipping path

r: The rectangle to intersect with the current clipping path.

NSGraphicsMBS.concat(transform as NSAffineTransformMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacCocoa Plugin 15.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Concats this transform to the current transform of the graphics environment.

NSGraphicsMBS.ConcatTransform(NSAffineTransform as Variant)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacCocoa Plugin 12.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Appends the receiver's matrix to the current transformation matrix stored in the current graphics context, replacing the current transformation matrix with the result.

Please use saveGraphicsState so you can restore the state before applying matrix for other drawings.

Concatenation is performed by matrix multiplication.

If this method is invoked from within an NSView drawRect method, then the current transformation matrix is an accumulation of the screen, window, and any superview's transformation matrices. Invoking this method defines a new user coordinate system whose coordinates are mapped into the former coordinate system according to the receiver's transformation matrix. To undo the concatenation, you must invert the receiver's matrix and invoke this method again.

NSAffineTransform must be a NSAffineTransformMBS object.

NSGraphicsMBS.Constructor(targetImage as NSBitmapImageRepMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacCocoa Plugin 12.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates a new graphics context for drawing into a bitmap image representation.
Example
Var n as new NSImageMBS(300,300)
Var r as new NSBitmapImageRepMBS(300, 300, 8, 4, true, NSColorSpaceMBS.NSCalibratedRGBColorSpace, 4*300, 32)

Var g as new NSGraphicsMBS(r)
g.SetColorRGB 1.0,0,0,0.5
g.fillRect 0, 0, 100, 100
g = nil // flush
n.addRepresentation r

Backdrop = n.CopyPictureWithMask

Please make sure the graphics object is destroyed (Set to nil) so the drawings flush to the image.
Returns nil on any error.

See also:

NSGraphicsMBS.Constructor(targetImage as NSImageMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacCocoa Plugin 12.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a new graphics context for drawing into an image.
Example
// make new image
Var myImage as new NSImageMBS(500,500)
Var myGraphics as new NSGraphicsMBS(myImage)

// make logo image
Var myPicture as Picture = LogoMBS(500)
Var anotherImage as new NSImageMBS(myPicture)

// draw logo image to new image
myGraphics.drawInRect(anotherImage, 0, 0, myImage.width, myImage.height, 0, 0, anotherImage.width, anotherImage.height, myGraphics.NSCompositeSourceOver, 1.0)
myGraphics = nil // flush drawing

// save to file
Var f as FolderItem = SpecialFolder.Desktop.Child("test.jpg")
Var b as BinaryStream = BinaryStream.Create(f, True)
if b<>nil then
b.Write myImage.JPEGRepresentation
b.Close
end if

Please make sure the graphics object is destroyed (Set to nil) so the drawings flush to the image.

See also:

NSGraphicsMBS.Constructor(targetView as NSViewMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Creates a new graphics context for drawing into a Cocoa view.

Please make sure the graphics object is destroyed (Set to nil) so the drawings flush to the window.

See also:

The items on this page are in the following plugins: MBS MacCocoa Plugin.


The biggest plugin in space...