Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.
Platforms to show: All Mac Windows Linux Cross-Platform
CGContextMBS.SetFillColorSpace(colorspace as CGColorSpaceMBS)
Function:
Sets the colorspace used for the fill color of the graphics context.
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 4.3 | Yes | No | No | Yes, macOS only | No |
CGContextMBS.SetFont(font as CGFontMBS)
Function:
Sets the current font.
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 14.2 | Yes | No | No | Yes, macOS only | No |
CGContextMBS.SetLineDash(phase as Double, lengths as memoryblock, count as Integer)
Function:
Sets the pattern for dashed lines in a graphics context.
Notes:
phase:
A value that specifies how far into the dash pattern the line starts, in units of the user space. For example, passing a value of 3 means the line is drawn with the dash pattern starting at three units from its beginning. Passing a value of 0 draws a line starting with the beginning of a dash pattern.
lengths:
A memoryblock of float values that specify the lengths of the painted segments and unpainted segments, respectively, of the dash pattern—or nil for no dash pattern.
For example, passing a memoryblock with the values [2,3] sets a dash pattern that alternates between a 2-user-space-unit-long painted segment and a 3-user-space-unit-long unpainted segment. Passing the values [1,3,4,2] sets the pattern to a 1-unit painted segment, a 3-unit unpainted segment, a 4-unit painted segment, and a 2-unit unpainted segment.
count
If the lengths parameter specifies a memorybloc, pass the number of elements in the memoryblock. Otherwise, pass 0.
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 7.7 | Yes | No | No | Yes, macOS only | No |
Notes:
phase:
A value that specifies how far into the dash pattern the line starts, in units of the user space. For example, passing a value of 3 means the line is drawn with the dash pattern starting at three units from its beginning. Passing a value of 0 draws a line starting with the beginning of a dash pattern.
lengths:
A memoryblock of float values that specify the lengths of the painted segments and unpainted segments, respectively, of the dash pattern—or nil for no dash pattern.
For example, passing a memoryblock with the values [2,3] sets a dash pattern that alternates between a 2-user-space-unit-long painted segment and a 3-user-space-unit-long unpainted segment. Passing the values [1,3,4,2] sets the pattern to a 1-unit painted segment, a 3-unit unpainted segment, a 4-unit painted segment, and a 2-unit unpainted segment.
count
If the lengths parameter specifies a memorybloc, pass the number of elements in the memoryblock. Otherwise, pass 0.
CGContextMBS.SetShadow(x as Double, y as Double, blur as Double)
Function:
Enables shadowing in a graphics context.
Example:
Notes:
x/y: Specifies a translation of the context's coordinate system, to establish an offset for the shadow ({0,0} specifies a light source immediately above the screen).
blur: A non-negative number specifying the amount of blur.
Shadow parameters are part of the graphics state in a context. After shadowing is set, all objects drawn are shadowed using a black color with 1/3 alpha (i.e., RGBA = {0, 0, 0, 1.0/3.0}) in the DeviceRGB color space.
To turn off shadowing:
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 8.5 | Yes | No | No | Yes, macOS only | No |
Example:
Sub Paint(g As Graphics)
dim c as CGContextMBS
c=window1.CGContextMBS
c.SetShadow 5,5,0.5
c.SetRGBFillColor 1,0,0,1
c.FillRect CGMakeRectMBS(100,100,100,100)
c.Flush
End Sub
x/y: Specifies a translation of the context's coordinate system, to establish an offset for the shadow ({0,0} specifies a light source immediately above the screen).
blur: A non-negative number specifying the amount of blur.
Shadow parameters are part of the graphics state in a context. After shadowing is set, all objects drawn are shadowed using a black color with 1/3 alpha (i.e., RGBA = {0, 0, 0, 1.0/3.0}) in the DeviceRGB color space.
To turn off shadowing:
- Use the standard save/restore mechanism for the graphics state.
- Use CGContextSetShadowWithColor to set the shadow color to a fully transparent color (or pass nil as the color).
CGContextMBS.SetShadowWithColor(x as Double, y as Double, blur as Double, colorvalue as CGColorMBS)
Function:
Enables shadowing with color a graphics context.
Notes:
x/y: Specifies a translation in base-space.
blur: A non-negative number specifying the amount of blur.
colorvalue: Specifies the color of the shadow, which may contain a non-opaque alpha value. If nil, then shadowing is disabled.
See also SetShadow.
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 8.5 | Yes | No | No | Yes, macOS only | No |
Notes:
x/y: Specifies a translation in base-space.
blur: A non-negative number specifying the amount of blur.
colorvalue: Specifies the color of the shadow, which may contain a non-opaque alpha value. If nil, then shadowing is disabled.
See also SetShadow.
CGContextMBS.SetShouldSmoothFonts(shouldSmoothFonts as boolean)
Function:
Whether font smoothing is enabled.
Notes:
Turn on font smoothing if shouldSmoothFonts is true; turn it off otherwise. This parameter is part of the graphics state. Note that this doesn't guarantee that font smoothing will occur: not all destination contexts support font smoothing.
Requires Mac OS X 10.2.
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 7.2 | Yes | No | No | Yes, macOS only | No |
Notes:
Turn on font smoothing if shouldSmoothFonts is true; turn it off otherwise. This parameter is part of the graphics state. Note that this doesn't guarantee that font smoothing will occur: not all destination contexts support font smoothing.
Requires Mac OS X 10.2.
CGContextMBS.SetStrokeColor(color as CGColorMBS)
Function:
Sets the given color as stroke color.
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 17.2 | Yes | No | No | Yes, macOS only | No |
CGContextMBS.SetStrokeColorSpace(colorspace as CGColorSpaceMBS)
Function:
Sets the colorspace used for the stroke color of the graphics context.
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 4.3 | Yes | No | No | Yes, macOS only | No |
CGContextMBS.ShowText(text as string)
Function:
Draw 'string' at the point specified by the current text matrix.
Notes:
Each byte of the string is mapped through the encoding vector of the current font to obtain the glyph to display.
This function is more for quick and dirty text output, but not for serious drawing as it does not do most unicode strings correctly. Use ATS for better drawing.
Some RB 5.x versions show a bug that the text is not displayed on a CGContext in while running the application in debug mode.
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 2.7 | Yes | No | No | Yes, macOS only | No |
Notes:
Each byte of the string is mapped through the encoding vector of the current font to obtain the glyph to display.
This function is more for quick and dirty text output, but not for serious drawing as it does not do most unicode strings correctly. Use ATS for better drawing.
Some RB 5.x versions show a bug that the text is not displayed on a CGContext in while running the application in debug mode.
CGContextMBS.ShowTextAtPoint(text as string, x as Double, y as Double)
Function:
Draw 'string' at the point '(x, y)', specified in user space.
Notes:
Each byte of the string is mapped through the encoding vector of the current font to obtain the glyph to display.
This function is more for quick and dirty text output, but not for serious drawing as it does not do most unicode strings correctly. Use ATS for better drawing.
Some RB 5.x versions show a bug that the text is not displayed on a CGContext in while running the application in debug mode.
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 2.7 | Yes | No | No | Yes, macOS only | No |
Notes:
Each byte of the string is mapped through the encoding vector of the current font to obtain the glyph to display.
This function is more for quick and dirty text output, but not for serious drawing as it does not do most unicode strings correctly. Use ATS for better drawing.
Some RB 5.x versions show a bug that the text is not displayed on a CGContext in while running the application in debug mode.
CGContextMBS.StrokeEllipseInRect(rect as CGRectMBS)
Function:
Stroke an ellipse (an oval) inside rect.
Notes: Requires Mac OS X 10.4.
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 8.0 | Yes | No | No | Yes, macOS only | No |
Notes: Requires Mac OS X 10.4.
CGContextMBS.StrokePath
Function:
Stroke the context's path.
Example:
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 2.7 | Yes | No | No | Yes, macOS only | No |
Example:
dim c as CGContextMBS
c=window1.CGContextMBS
c.SetRGBStrokeColor 1,0,0,1
c.BeginPath
c.MoveToPoint 0,0
c.AddLineToPoint 100,100
c.StrokePath
c.Flush
CGContextMBS.StrokeRect(rect as CGRectMBS)
Function:
Stroke 'rect' with the current stroke color and the current linewidth.
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 2.7 | Yes | No | No | Yes, macOS only | No |
CGContextMBS.StrokeRectWithWidth(rect as CGRectMBS, width as Double)
Function:
Stroke 'rect' with the current stroke color, using 'width' as the the line width.
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 2.7 | Yes | No | No | Yes, macOS only | No |
CGContextMBS.strokeRoundedRect(x as Double, y as Double, w as Double, h as Double, arcWidth as Double, arcHeight as Double)
Function:
Draws the frame for the round rectangle.
Example:
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 8.4 | Yes | No | No | Yes, macOS only | No |
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
CGContextMBS.Synchronize
Function:
Synchronizes the context with the device.
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 2.7 | Yes | No | No | Yes, macOS only | No |
CGContextMBS.TextMatrix as CGAffineTransformMBS
Function:
Return the text matrix.
Notes:
Returns nil on any error.
(Read and Write computed property)
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
property | CoreGraphics | MBS MacCG Plugin | 4.3 | Yes | No | No | Yes, macOS only | No |
Notes:
Returns nil on any error.
(Read and Write computed property)
CGContextMBS.TextPosition as CGPointMBS
Function:
User-space point at which text will be drawn to (x,y).
Notes: (Read and Write computed property)
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
property | CoreGraphics | MBS MacCG Plugin | 2.7 | Yes | No | No | Yes, macOS only | No |
Notes: (Read and Write computed property)
CGContextMBS.TranslateCTM(tx as Double, ty as Double)
Function:
Translate the current graphics state's transformation matrix (the CTM) by (tx,ty).
Example:
Type | Topic | Plugin | Version | macOS | Windows | Linux | Console & Web | iOS |
method | CoreGraphics | MBS MacCG Plugin | 2.7 | Yes | No | No | Yes, macOS only | No |
Example:
// Rotate a PDF page
// our files
dim sourcefile as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
dim destfile as FolderItem = SpecialFolder.Desktop.Child("rotated.pdf")
// open PDF
dim pdf as CGPDFDocumentMBS = sourcefile.OpenAsCGPDFDocumentMBS
// query media size of first page
dim r as CGRectMBS = pdf.MediaBox(1)
// create new PDF
dim c as CGContextMBS = destfile.NewCGPDFDocumentMBS(r,"title","Author","Creator")
// create rotated rectangle
dim nr as new CGRectMBS(0,0,r.Height,r.Width)
// create new page
c.BeginPage nr
c.SaveGState
const pi = 3.14159265
// rotate by 90°
c.RotateCTM pi*1.5
// fix origin
c.TranslateCTM -r.width,0
// draw PDF
c.DrawCGPDFDocument pdf,r,1
// cleanup
c.RestoreGState
c.EndPage
c = nil
// show in PDF viewer
destfile.Launch
The items on this page are in the following plugins: MBS MacCG Plugin.
Links
MBS FileMaker blog