Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

Next items

CGContextMBS.addArcToPath(x as Double, y as Double, w as Double, h as Double, startAngle as Integer, arcAngle as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 8.5 Yes No No Yes, macOS only No
Function: Adds an arc to the current path.

Feedback, Comments & Corrections

CGContextMBS.AddEllipseInRect(r as CGRectMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 8.0 Yes No No Yes, macOS only No
Function: Add an ellipse inside rect to the current path of context.
Notes:
See the function CGPathMBS.AddEllipseInRect for more information on how the path for the ellipse is constructed.
Requires Mac OS X 10.4.

Feedback, Comments & Corrections

CGContextMBS.addOvalToPath(x as Double, y as Double, w as Double, h as Double)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 8.5 Yes No No Yes, macOS only No
Function: Adds an oval to the current path.

Feedback, Comments & Corrections

CGContextMBS.AddPath(path as CGPathMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 8.0 Yes No No Yes, macOS only No
Function: Add path to the path of context.
Notes:
The points in path are transformed by the CTM of context before they are added.
Requires Mac OS X 10.2.

Feedback, Comments & Corrections

CGContextMBS.addRoundedRectToPath(x as Double, y as Double, w as Double, h as Double, arcWidth as Double, arcHeight as Double)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 8.5 Yes No No Yes, macOS only No
Function: Adds a round rectangle to the current path.

Feedback, Comments & Corrections

CGContextMBS.BeginPage(mediabox as CGRectMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 2.7 Yes No No Yes, macOS only No
Function: Begin a new page.

Feedback, Comments & Corrections

CGContextMBS.BeginPath
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 2.7 Yes No No Yes, macOS only No
Function: Begin a new path. The old path is discarded.
Example:
dim c as CGContextMBS = CGContextMBS.contextWithCGContext(g.Handle(g.HandleTypeCGContextRef))

c.SetGrayStrokeColor(0,1)
c.SetGrayFillColor(0,1)
c.BeginPath
c.SetLineWidth 0.5
c.MoveToPoint 50, 550
c.AddLineToPoint 100, 600
c.StrokePath
c.Flush
c = nil
Notes: Note that a context has a double path in use at any time: a path is not part of the graphics state.

Feedback, Comments & Corrections

CGContextMBS.BeginTransparencyLayer(auxiliaryInfo as Dictionary = nil)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 12.1 Yes No No Yes, macOS only No
Function: Begin a transparency layer in context.
Notes:
All subsequent drawing operations until a corresponding EndTransparencyLayer are composited into a fully transparent backdrop (which is treated as a separate destination buffer from the context). After the transparency layer is ended, the result is composited into the context using the global alpha and shadow state of the context. This operation respects the clipping region of the context. After a call to this function, all of the parameters in the graphics state remain unchanged with the exception of the following:

- The global alpha is set to 1.
- The shadow is turned off.
- The blend mode is set to 'kCGBlendModeNormal'.

Ending the transparency layer restores these parameters to the values they had before BeginTransparencyLayer was called. Transparency layers may be nested.

Feedback, Comments & Corrections

CGContextMBS.BeginTransparencyLayerWithRect(r as CGRectMBS, auxiliaryInfo as Dictionary = nil)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 12.1 Yes No No Yes, macOS only No
Function: Begin a transparency layer in context.
Notes: This function is identical to BeginTransparencyLayer except that the content of the transparency layer will be bounded by rect (specified in user space).

Feedback, Comments & Corrections

CGContextMBS.clearRect(rect as CGRectMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 2.7 Yes No No Yes, macOS only No
Function: Clears the background.
Notes: Remeber that in CoreGraphics the position 0/0 is in the bottom left corner. In Realbasic 0/0 is in the top left corner.

Feedback, Comments & Corrections

CGContextMBS.clip
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 2.7 Yes No No Yes, macOS only No
Function: Clips the current path.
Notes: 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.

Feedback, Comments & Corrections

CGContextMBS.ClipToMask(rect as CGRectMBS, mask as CGImageMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.2 Yes No No Yes, macOS only No
Function: Maps a mask into the specified rectangle and intersects it with the current clipping area of the graphics context.
Notes:
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.

Feedback, Comments & Corrections

CGContextMBS.clipToRect(rect as CGRectMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 2.7 Yes No No Yes, macOS only No
Function: Clips the current path.
Notes: Intersect the current clipping path with 'rect'. Note that this function resets the context's path to the empty path.

Feedback, Comments & Corrections

CGContextMBS.Close
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 15.2 Yes No No Yes, macOS only No
Function: Closes the context.
Notes: Same as destructor later, but running now when you call method.

Feedback, Comments & Corrections

CGContextMBS.closePath
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 2.7 Yes No No Yes, macOS only No
Function: Close the current subpath of the context's path.

Feedback, Comments & Corrections

CGContextMBS.ConcatCTM(transform as CGAffineTransformMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 4.3 Yes No No Yes, macOS only No
Function: Concatenate the current graphics state's transformation matrix (the CTM) with the affine transform 'transform'.

Feedback, Comments & Corrections

CGContextMBS.Constructor(handle as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 13.1 Yes No No Yes, macOS only No
Function: Creates a new CGContextMBS object based on a CGContextRef.
Notes: The CGContext is retained.

Feedback, Comments & Corrections

CGContextMBS.CopyPath as CGPathMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.2 Yes No No Yes, macOS only No
Function: Returns a Quartz path object built from the current path information in a graphics context.
Notes: Available in Mac OS X v10.6 and later.

Feedback, Comments & Corrections

CGContextMBS.DrawCGPDFDocument(pdf as Variant, rect as CGRectMBS, page as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 2.7 Yes No No Yes, macOS only No
Function: Draw 'page' in 'document' in the rectangular area specified by 'rect'.
Example:
'get a print session

// print this PDF
dim pathPrinted as FolderItem=GetFolderItem("test.pdf")

dim thePrintSession as CPMPrintSessionMBS = NewCPMPrintSessionMBS
if thePrintSession = nil then Return

'get default page format and print settings and attach it to the print settings
dim thePageFormat as CPMPageFormatMBS = NewCPMPageFormatMBS
dim thePrintSettings as CPMPrintSettingsMBS = NewCPMPrintSettingsMBS
thePrintSession.DefaultPageFormat thePageFormat
thePrintSession.DefaultPrintSettings thePrintSettings

'show the print dialog
if not thePrintSession.PrintDialog(thePrintSettings,thePageFormat) then return

'open the file which will be printed
dim thePdfDocument as CGPDFDocumentMBS = pathPrinted.OpenAsCGPDFDocumentMBS

' limit page counts to the one we have
dim LastPage as Integer = thePdfDocument.PageCount
if thePrintSettings.LastPage<lastpage then
lastpage=thePrintSettings.LastPage
end if

' you get better progress bar if you tell how many pages will come
thePrintSettings.LastPage=lastpage

'begin the printing
thePrintSession.BeginDocument(thePrintSettings, thePageFormat)

'loop over the number of copies
for currentCopy as Integer = 1 to thePrintSettings.Copies

'loop over the pages
for currentPage as Integer = thePrintSettings.FirstPage to LastPage

'prepage the page
dim PrintRect as CPMRectMBS =thePageFormat.AdjustedPageSize
dim CGRect as CGRectMBS =CGMakeRectMBS(PrintRect.left, PrintRect.top, PrintRect.Width, PrintRect.Height)
thePrintSession.BeginPage(thePageFormat, nil)
dim thePrintContext as CGContextMBS = thePrintSession.PageContext
if thePrintContext = Nil then return

'print the page
thePrintContext.DrawCGPDFDocument thePdfDocument, CGRect, currentPage

'end the page
thePrintContext = nil
thePrintSession.EndPage
next

next

'end the printing
thePrintSession.EndDocument
Notes:
Pass a CGPDFDocumentMBS object for the pdf argument.
The media box of the page is scaled, if necessary, to fit into 'rect'.

Feedback, Comments & Corrections

CGContextMBS.DrawLayerAtPoint(Point as CGPointMBS, layer as CGLayerMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 12.2 No Yes Yes Yes No
Function: Draws the contents of a CGLayer object at the specified point.
Notes:
context: The graphics context associated with the layer.
point: The location, in current user space coordinates, to use as the origin for the drawing.
layer: The layer whose contents you want to draw.

Calling the function DrawLayerAtPoint is equivalent to calling the function DrawLayerInRect with a rectangle that has its origin at point and its size equal to the size of the layer.

Available in Mac OS X version 10.4 and later.

Feedback, Comments & Corrections

CGContextMBS.DrawLayerInRect(rect as CGRectMBS, layer as CGLayerMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 12.2 No Yes Yes Yes No
Function: Draws the contents of a CGLayer object into the specified rectangle.
Notes:
context: The graphics context associated with the layer.
rect: The rectangle, in current user space coordinates, to draw to.
layer: The layer whose contents you want to draw.

The contents are scaled, if necessary, to fit into the rectangle.
Available in Mac OS X version 10.4 and later.

Feedback, Comments & Corrections

CGContextMBS.DrawLinearGradient(gradient as CGGradientMBS, startPoint as CGPointMBS, endPoint as CGPointMBS, options as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.2 Yes No No Yes, macOS only No
Function: Paints a gradient fill that varies along the line defined by the provided starting and ending points.
Notes:
gradient: A CGGradient object.
startPoint: The coordinate that defines the starting point of the gradient.
endPoint: The coordinate that defines the ending point of the gradient.
options: Option flags (kCGGradientDrawsBeforeStartLocation or kCGGradientDrawsAfterEndLocation) that control whether the fill is extended beyond the starting or ending point.

The color at location 0 in the CGGradient object is mapped to the starting point. The color at location 1 in the CGGradient object is mapped to the ending point. Colors are linearly interpolated between these two points based on the location values of the gradient. The option flags control whether the gradient is drawn before the start point or after the end point.

Available in Mac OS X v10.5 and later.

Feedback, Comments & Corrections

CGContextMBS.DrawPath(mode as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 2.7 Yes No No Yes, macOS only No
Function: Draw the context's path using drawing mode 'mode'.

Feedback, Comments & Corrections

CGContextMBS.DrawPicture(pic as CGImageMBS, rect as CGRectMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 2.7 Yes No No Yes, macOS only No
Function: Draws a CGImageMBS at the given position.
Example:
// put inside window paint event

dim c as CGContextMBS
if TargetCocoa then
c = GetCurrentCGContextMBS
else
c = window1.CGContextMBS
end if

dim logo as Picture = logoMBS(500)
dim image as CGImageMBS = CGCreateImageMBS(logo)

dim r as CGRectMBS = CGMakeRectMBS(0,0,g.Width,g.Height)

c.DrawPicture image, r
Notes: Remeber that in CoreGraphics the position 0/0 is in the bottom left corner. In Realbasic 0/0 is in the top left corner.

Feedback, Comments & Corrections

CGContextMBS.DrawRadialGradient(gradient as CGGradientMBS, startCenter as CGPointMBS, startRadius as Double, endCenter as CGPointMBS, endRadius as Double, options as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.2 Yes No No Yes, macOS only No
Function: Paints a gradient fill that varies along the area defined by the provided starting and ending circles.
Notes:
gradient: A CGGradient object.
startCenter: The coordinate that defines the center of the starting circle.
startRadius: The radius of the starting circle.
endCenter: The coordinate that defines the center of the ending circle.
endRadius: The radius of the ending circle.
options: Option flags (kCGGradientDrawsBeforeStartLocation or kCGGradientDrawsAfterEndLocation) that control whether the gradient is drawn before the starting circle or after the ending circle.

The color at location 0 in the CGGradient object is mapped to the circle defined by startCenter and startRadius. The color at location 1 in the CGGradient object is mapped to the circle defined by endCenter and endRadius. Colors are linearly interpolated between the starting and ending circles based on the location values of the gradient. The option flags control whether the gradient is drawn before the start point or after the end point.

Available in Mac OS X v10.5 and later.

Feedback, Comments & Corrections

CGContextMBS.DrawShading(shading as CGShadingMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 6.2 Yes No No Yes, macOS only No
Function: Fills the clipping path of a context with the specified shading.
Notes:
shading: A Quartz shading. Quartz retains this object; upon return, you may safely release it.
Available in Mac OS X version 10.2 and later.

Feedback, Comments & Corrections

CGContextMBS.DrawTiledImage(pic as CGImageMBS, rect as CGRectMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.2 Yes No No Yes, macOS only No
Function: Repeatedly draws an image, scaled to the provided rectangle, to fill the current clip region.
Example:
// put inside window paint event

dim c as CGContextMBS
if TargetCocoa then
c = GetCurrentCGContextMBS
else
c = window1.CGContextMBS
end if

dim logo as Picture = logoMBS(50)
dim image as CGImageMBS = CGCreateImageMBS(logo)

dim r as CGRectMBS = CGMakeRectMBS(0,0,50,50)

c.DrawTiledImage image, r
Notes:
rect: A rectangle that specifies the origin and size of the destination tile. Quartz scales the image—disproportionately, if necessary—to fit the bounds specified by the rect parameter.

image: The image to draw.

Quartz draws the scaled image starting at the origin of the rectangle in user space, then moves to a new point (horizontally by the width of the tile and/or vertically by the height of the tile), draws the scaled image, moves again, draws again, and so on, until the current clip region is tiled with copies of the image. Unlike patterns, the image is tiled in user space, so transformations applied to the CTM affect the final result.

Available in Mac OS X v10.5 and later.

Feedback, Comments & Corrections

CGContextMBS.EndPage
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 2.7 Yes No No Yes, macOS only No
Function: End the current page.

Feedback, Comments & Corrections

CGContextMBS.EndTransparencyLayer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.1 Yes No No Yes, macOS only No
Function: End a tranparency layer.

Feedback, Comments & Corrections

Next items

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





Links
MBS Xojo Chart Plugins