Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

Previous items Next items

CGContextMBS.EOClip
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 even-odd fill rule for deciding what's inside the path.

Feedback, Comments & Corrections

CGContextMBS.EOFillPath
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: Fill the context's path using the even-odd fill rule. Any open subpath of the path is implicitly closed.

Feedback, Comments & Corrections

CGContextMBS.FillEllipseInRect(rect 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: Fill an ellipse (an oval) inside rect.
Example:
// a new picture in RB
dim pic as new Picture(500, 500)

// and create CGBitmapContextMBS pointing to it
dim b as CGBitmapContextMBS = CGBitmapContextMBS.CreateWithPicture(pic)

// color set to full red
b.SetRGBFillColor 1.0, 0.0, 0.0, 1.0

// draw ellipse
dim r as CGRectMBS = CGRectMBS.Make(0, 0, 500, 500)
b.FillEllipseInRect r

// flush drawings
b.Flush

// and show
Backdrop = pic
Notes: Requires Mac OS X 10.4.

Feedback, Comments & Corrections

CGContextMBS.FillPath
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: Fill the context's path using the winding-number fill rule. Any open subpath of the path is implicitly closed.

Feedback, Comments & Corrections

CGContextMBS.FillRect(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: Fills the background with current fill color.
Example:
// put in window.paint event
dim c as CGContextMBS

c=window1.CGContextMBS

c.RotateCTM 0.1
c.SetRGBFillColor 0,0,1,0.5
c.FillRect CGMakeRectMBS(0,0,100,100)

c.Flush
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.fillRoundedRect(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.4 Yes No No Yes, macOS only No
Function: Fills a round rectangle.
Example:
dim c as CGContextMBS

c=window1.CGContextMBS

// fill in red
c.SetRGBFillColor 1,0,0,1
c.fillRoundedRect 100,100,100,100,20,20

// draw in green
c.SetRGBStrokeColor 0,1,0,1
c.strokeRoundedRect 100,100,100,100,20,20

Feedback, Comments & Corrections

CGContextMBS.Flush
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: Updates the screen to show the current content.
Notes: Like UpdateNow in the RB window class.

Feedback, Comments & Corrections

CGContextMBS.frameArc(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.4 Yes No No Yes, macOS only No
Function: Draws an arc.
Example:
dim c as CGContextMBS

c=window1.CGContextMBS

// fill in red
c.SetRGBFillColor 1,0,0,1
c.paintArc 100,100,100,100,50,90

// draw in green
c.SetRGBStrokeColor 0,1,0,1
c.frameArc 100,100,100,100,50,90
Notes: angles are in degree.

Feedback, Comments & Corrections

CGContextMBS.frameOval(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.4 Yes No No Yes, macOS only No
Function: Draws an oval.
Example:
dim c as CGContextMBS

c=window1.CGContextMBS

// fill in red
c.SetRGBFillColor 1,0,0,1
c.paintOval 100,100,100,100

// draw in green
c.SetRGBStrokeColor 0,1,0,1
c.frameOval 100,100,100,100

Feedback, Comments & Corrections

CGContextMBS.frameRect(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.4 Yes No No Yes, macOS only No
Function: Draws the frame for the rectangle.
Example:
dim c as CGContextMBS

c=window1.CGContextMBS

// fill in red
c.SetRGBFillColor 1,0,0,1
c.paintRect 100,100,100,100

// draw in green
c.SetRGBStrokeColor 0,1,0,1
c.frameRect 100,100,100,100

Feedback, Comments & Corrections

CGContextMBS.GetClipBoundingBox 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: Returns the bounding box of a clipping path.
Notes:
Returns the bounding box of the clipping path, specified in user space.

The bounding box is the smallest rectangle completely enclosing all points in the clipping path, including control points for any Bezier curves in the path.

Available in Mac OS X v10.3 and later.

Feedback, Comments & Corrections

CGContextMBS.GetCTM 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: Return the current graphics state's transformation matrix.
Notes: Returns nil on any error.

Feedback, Comments & Corrections

CGContextMBS.GetPathBoundingBox 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: Return the bounding box of the context's path.
Notes: The bounding box is the smallest rectangle completely enclosing all points in the path, including control points for Bezier and quadratic curves.

Feedback, Comments & Corrections

CGContextMBS.GetPathCurrentPoint as CGPointMBS
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: Return the current point of the current subpath of the context's path.

Feedback, Comments & Corrections

CGContextMBS.GetTextPosition as CGPointMBS
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: Return the current user-space point at which text will be drawn to (x,y).
Notes: Returns nil on any problem.

Feedback, Comments & Corrections

CGContextMBS.IsPathEmpty as boolean
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: Returns true if the context's path contains no elements.

Feedback, Comments & Corrections

CGContextMBS.MoveToPoint(x as Double, y as Double)
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: Append a straight line segment from the current point to (x, y).

Feedback, Comments & Corrections

CGContextMBS.paintArc(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.4 Yes No No Yes, macOS only No
Function: Fills an arc.
Example:
dim c as CGContextMBS

c=window1.CGContextMBS

// fill in red
c.SetRGBFillColor 1,0,0,1
c.paintArc 100,100,100,100,50,90

// draw in green
c.SetRGBStrokeColor 0,1,0,1
c.frameArc 100,100,100,100,50,90
Notes: angles are in degree.

Feedback, Comments & Corrections

CGContextMBS.paintOval(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.4 Yes No No Yes, macOS only No
Function: Fills an oval.
Example:
dim c as CGContextMBS

c=window1.CGContextMBS

// fill in red
c.SetRGBFillColor 1,0,0,1
c.paintOval 100,100,100,100

// draw in green
c.SetRGBStrokeColor 0,1,0,1
c.frameOval 100,100,100,100

Feedback, Comments & Corrections

CGContextMBS.paintRect(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.4 Yes No No Yes, macOS only No
Function: Fills the rectangle.
Example:
dim c as CGContextMBS

c=window1.CGContextMBS

// fill in red
c.SetRGBFillColor 1,0,0,1
c.paintRect 100,100,100,100

// draw in green
c.SetRGBStrokeColor 0,1,0,1
c.frameRect 100,100,100,100

Feedback, Comments & Corrections

CGContextMBS.PathContainsPoint(point as CGPointMBS, mode as Integer) as boolean
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: Return true if point is contained in the current path of context.
Notes:
A point is contained within a contexts path if it is inside the painted region when the path is stroked or filled with opaque colors using the path drawing mode mode. point is specified is user space.

Requires Mac OS X 10.4.

Feedback, Comments & Corrections

CGContextMBS.ReplacePathWithStrokedPath
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: Replace the path in context with the stroked version of the path, using the parameters of context to calculate the stroked path.
Notes:
The resulting path is created such that filling it with the appropriate color will produce the same results as stroking the original path. You can use this path in the same way you can use the path of any context; for example, you can clip to the stroked version of a path by calling this function followed by a call to "ClipPath".
Requires Mac OS X 10.4.

Feedback, Comments & Corrections

CGContextMBS.RestoreGState
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: Restores the last saved graphics state.

Feedback, Comments & Corrections

CGContextMBS.RotateCTM(angle as Double)
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: Rotate the current graphics state's transformation matrix (the CTM) by 'angle' radians.
Example:
// Rotate a picture not on the edge of the context:

dim c as CGImageMBS
dim f as FolderItem
dim d as CGDataProviderMBS
dim cg as CGContextMBS
dim r as CGRectMBS

f=SpecialFolder.Desktop.Child("IMAG0001.JPG")

d=CGDataProviderMBS.CreateWithFile(f)
c=CGCreateImageFromJPEGDataProviderMBS(d,nil,true,0)

cg=window1.CGContextMBS

r=CGMakeRectMBS(-c.Width/2,-c.Height/2,c.Width,c.Height)
cg.TranslateCTM Width/2,Height/2
cg.RotateCTM Slider1.Value/180.0*3.14
cg.DrawPicture c,r

cg.Flush

Feedback, Comments & Corrections

CGContextMBS.SaveGState
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: Saves the current graphics state.

Feedback, Comments & Corrections

CGContextMBS.ScaleCTM(sx as Double, sy as Double)
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: Scale the current graphics state's transformation matrix (the CTM) by (sx, sy).

Feedback, Comments & Corrections

CGContextMBS.SelectFont(name as string, size as Double, fontencoding 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: Attempts to find the font named 'name'. If successful, scales it to 'size' units in user space.
Notes:
Name: string that contains the PostScript name of the font to set.

'textEncoding' specifies how to translate from bytes to glyphs.
kCGEncodingFontSpecific0
kCGEncodingMacRoman 1

As "Comic Sans MS" works, but not ""Comic Sans ms" this functions seems to be case sensitive.

Matthias Buercher notes that sometimes a font is not selected if the RGBFillColor was not set before.

You may need to reset the textmatrix with some code like c.TextMatrix = CGAffineTransformMBS.Identity. If the text matrix is different, your text may be rotated, skewed or resized.

Feedback, Comments & Corrections

CGContextMBS.SetAllowsAntialiasing(allowsAntialiasing as boolean)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 7.2 Yes No No Yes, macOS only No
Function: Whether to allow antialiasing.
Notes:
Allow antialiasing in context if allowsAntialiasing is true; don't allow it otherwise. This parameter is not part of the graphics state. A context will perform antialiasing if both allowsAntialiasing and the graphics state parameter shouldAntialias are true.
Requires Mac OS X 10.4 to work.

Feedback, Comments & Corrections

CGContextMBS.SetBlendMode(BlendMode as Integer)
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: Set the blend mode of context to mode.
Notes: Requires Mac OS X 10.4.

Feedback, Comments & Corrections

CGContextMBS.SetFillColor(color as CGColorMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 17.2 Yes No No Yes, macOS only No
Function: Sets the given color as fill color.

Feedback, Comments & Corrections

Previous items Next items

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




Links
MBS Xojo PDF Plugins