#Region Project Attributes
#MainFormWidth: 620
#MainFormHeight: 630
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.Title="This demo show how to remove aliasing on Canvas horizontal and vertical lines"
Dim sharpCanvas As Canvas = createCanvasGrid(MainForm, 10, 10, 601, 301, True)
Dim blurryCanvas As Canvas = createCanvasGrid(MainForm, 10, 320, 600, 300, False)
sharpCanvas.DrawLine(0, 0, sharpCanvas.Width, sharpCanvas.Height, fx.Colors.Black, .7)
sharpCanvas.DrawLine(0, sharpCanvas.Height, sharpCanvas.Width, 0, fx.Colors.Black, .7)
blurryCanvas.DrawLine(0, 0, blurryCanvas.Width, blurryCanvas.Height, fx.Colors.Black, .7)
blurryCanvas.DrawLine(0, blurryCanvas.Height, blurryCanvas.Width, 0, fx.Colors.Black, .7)
MainForm.Show
End Sub
Sub createCanvasGrid(form As Form, x As Int, y As Int, width As Int, height As Int, sharp As Boolean) As Canvas
Dim cvs As Canvas
cvs.Initialize("")
form.RootPane.AddNode(cvs, x, y, width, height)
For x = 0 To width Step 10
Dim x1 As Double
If sharp Then x1 = x + 0.5 Else x1 = x
cvs.DrawLine(x1, 0, x1, height, fx.Colors.Black, 1.0)
Next
For y = 0 To height Step 10
Dim y1 As Double
If sharp Then y1 = y + 0.5 Else y1 = y
cvs.DrawLine(0, y1, width, y1, fx.Colors.Black, 1.0)
Next
Return cvs
End Sub