Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCG/CoreGraphics PDF/PDF Transparency
Required plugins for this example: MBS MacCG Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/CoreGraphics PDF/PDF Transparency
This example is the version from Sun, 17th Mar 2012.
Project "PDF Transparency.rbp"
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class Window1 Inherits Window
EventHandler Sub Open() // Original example can be found on Apple's Website. // Translation from C is quite easy ;-) dim c as CGContextMBS dim f as FolderItem dim r as CGRectMBS dim gradientRect as CGRectMBS dim positionLimit as Single dim positionIncrement as single dim currentPosition as single dim currentAlpha as single dim x,y as Integer dim delta as single currentAlpha=1 const size=200.0 const inStep=100 f=SpecialFolder.Desktop.Child("RB Transparency Demo.pdf") r=CGMakeRectMBS(0,0,size,size) // Create the context c=CGNewPDFDocumentMBS(f,r,"PDF from REALbasic","Christian Schmitz","MBS Plugin 2.7") if c<>nil then // We must begin a new page before drawing to a PDF context c.BeginPage(r) // Setup iteration for the horizontal plane positionIncrement = r.width / inStep positionLimit = r.Width+r.Left gradientRect = CGMakeRectMBS(r.Left,r.Top,positionIncrement,r.Height) // Each iteration of this loop draws one point // along the line from 0.0 to (inBounds.size.width / inStep // or inBounds.size.height / inStep) delta=size/10 c.SetGrayFillColor 0,1 for x=0 to 9 for y=0 to 9 if (x+y) mod 2=1 then c.FillRect CGMakeRectMBS(x*delta,y*delta,delta,delta) end if next next c.SetRGBFillColor 1,0,0,1 currentPosition = r.Left While currentPosition <= positionLimit gradientRect.Left = currentPosition c.SetAlpha currentAlpha c.FillRect gradientRect currentAlpha = currentAlpha - (1.0/inStep) currentPosition=currentPosition + positionIncrement wend // We've finished rendering the page c.EndPage c.Flush c=nil // to force the file to be written as we want to launch it f.Launch else MsgBox "Failed to creator file!" end if quit End EventHandler
End Class
Class App Inherits Application
End Class
End Project

See also:

Feedback, Comments & Corrections

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

MBS Xojo PDF Plugins