Platforms to show: All Mac Windows Linux Cross-Platform

Back to CGContextMBS class.

CGContextMBS.clearRect(rect as CGRectMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 2.7 ✅ Yes ❌ No ❌ No ✅ Yes All
Clears the background.

Remeber that in CoreGraphics the position 0/0 is in the bottom left corner. In Xojo 0/0 is in the top left corner.

CGContextMBS.clip

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 2.7 ✅ Yes ❌ No ❌ No ✅ Yes All
Clips the current path.

Intersect the context's path with the current clip path and use the resulting path as the clip path for subsequent rendering operations. Use the winding-number fill rule for deciding what's inside the path.

CGContextMBS.ClipToMask(rect as CGRectMBS, mask as CGImageMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 11.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Maps a mask into the specified rectangle and intersects it with the current clipping area of the graphics context.

rect: The rectangle to map the mask parameter to.
mask: An image or an image mask. If mask is an image, then it must be in the DeviceGray color space, may not have an alpha component, and may not be masked by an image mask or masking color.

If the mask parameter is an image mask, then Quartz clips in a manner identical to the behavior seen with the function DrawImage—the mask indicates an area to be left unchanged when drawing. The source samples of the image mask determine which points of the clipping area are changed, acting as an "inverse alpha" value. If the value of a source sample in the image mask is S, then the corresponding point in the current clipping area is multiplied by an alpha value of (1–S). For example, if S is 1 then the point in the clipping area becomes transparent. If S is 0, the point in the clipping area is unchanged.

If the mask parameter is an image, then mask acts like an alpha mask and is blended with the current clipping area. The source samples of mask determine which points of the clipping area are changed. If the value of the source sample in mask is S, then the corresponding point in the current clipping area is multiplied by an alpha of S. For example, if S is 0, then the point in the clipping area becomes transparent. If S is 1, the point in the clipping area is unchanged.

Available in Mac OS X v10.4 and later.

CGContextMBS.clipToRect(rect as CGRectMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 2.7 ✅ Yes ❌ No ❌ No ✅ Yes All
Clips the current path.

Intersect the current clipping path with 'rect'. Note that this function resets the context's path to the empty path.

CGContextMBS.Close

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 15.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Closes the context.

Same as destructor later, but running now when you call method.

CGContextMBS.closePath

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 2.7 ✅ Yes ❌ No ❌ No ✅ Yes All
Close the current subpath of the context's path.

CGContextMBS.ConcatCTM(transform as CGAffineTransformMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 4.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Concatenate the current graphics state's transformation matrix (the CTM) with the affine transform 'transform'.

CGContextMBS.Constructor(g as graphics)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 20.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a new CGContextMBS object drawing to the existing graphics object.
Example
Var p As New Picture(200, 200)
Var g As Graphics = p.Graphics

// Clear image with white
g.ForeColor = &cFFFFFF
g.FillRect 0, 0, g.Width, g.Height

Var c As New CGContextMBS(g)

c.SetRGBFillColor(1, 0, 0)

// coordinates are swapped in CGContext, so y = 20 means 20 pixels from bottom of picture!

Const x = 10
Const y = 20
Const w = 120
Const h = 100

c.FillRect New CGRectMBS(x, y, w, h)

Self.Backdrop = p

Raises exception if we fail to get the CGContext from Xojo.
Works on macOS and iOS.

See also:

CGContextMBS.Constructor(handle as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 13.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a new CGContextMBS object based on a CGContextRef.

The CGContext is retained.

See also:

CGContextMBS.Constructor(pic as Picture)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 20.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a new CGContextMBS object drawing to the existing Picture object.
Example
Var p As New Picture(100,100)
Var pg As New CGContextMBS(p)
break // inspect in debugger

Raises exception, if the picture is not a bitmap picture.
Works on macOS and iOS.

See also:

CGContextMBS.CopyPath as CGPathMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 11.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a Quartz path object built from the current path information in a graphics context.

Available in Mac OS X v10.6 and later.

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


The biggest plugin in space...