Private Sub DrawLayer2
'draw background color
Log("draw background color")
cvsLayer(2).DrawRect(xbckRect, xui.Color_ARGB(255, 240, 240, 240), True, 1dip)
Log("draw the four lines on layer(2)")
' draw the four lines on layer(2)
x1 = 10dip
y1 = 10dip
x2 = 150dip
y2 = 40dip
cvsLayer(2).DrawLine(x1, y1, x2, y2, xui.Color_Red, 1dip)
y1 = 50dip
y2 = 50dip
cvsLayer(2).DrawLine(x1, y1, x2, y2, xui.Color_Green, 3dip)
y1 = 60dip
y2 = 90dip
cvsLayer(2).DrawLine(x1, y1, x2, y2, xui.Color_Yellow, 5dip)
y1 = 80dip
y2 = 110dip
cvsLayer(2).DrawLine(x1, y1, x2, y2, xui.Color_RGB(0, 128, 255), 8dip)
Log("draw the three horizontal texts")
' draw the three horizontal texts
x1 = 220dip
y1 = 40dip
cvsLayer(2).DrawText("Rose", x1, y1, xFont, xui.Color_Blue, "LEFT")
DrawCross(x1, y1, xui.Color_Red)
y1 = 70dip
cvsLayer(2).DrawText("Rose", x1, y1, xFont, xui.Color_Blue, "CENTER")
DrawCross(x1, y1, xui.Color_Red)
y1 = 100dip
cvsLayer(2).DrawText("Rose", x1, y1, xFont, xui.Color_Blue, "RIGHT")
DrawCross(x1, y1, xui.Color_Red)
Log("draw the three rotated texts")
' draw the three rotated texts
x1 = 300dip
y1 = 40dip
cvsLayer(2).DrawTextRotated("Rose", x1, y1, xFont, xui.Color_Blue, "LEFT", -30)
DrawCross(x1, y1, xui.Color_Red)
y1 = 70dip
cvsLayer(2).DrawTextRotated("Rose", x1, y1, xFont, xui.Color_Blue, "CENTER", -30)
DrawCross(x1, y1, xui.Color_Red)
y1 = 100dip
cvsLayer(2).DrawTextRotated("Rose", x1, y1, xFont, xui.Color_Blue, "RIGHT", -30)
DrawCross(x1, y1, xui.Color_Red)
Log("draw an empty circle")
'draw an empty circle
xc = 100dip
yc = 180dip
Radius = 50dip
cvsLayer(2).DrawCircle(xc, yc, Radius, xui.Color_Red, False, 5dip)
Log("draw a clipped arc")
'draw a clipped arc
Private mPath As B4XPath
xc = 10dip
yc = 320dip
Radius = 80dip
mPath.InitializeArc(xc, yc, Radius, -30, 60)
cvsLayer(2).ClipPath(mPath)
cvsLayer(2).DrawRect(cvsLayer(2).TargetRect, xui.Color_Magenta, True, 1dip)
cvsLayer(2).RemoveClip
Log("draw a clipped triangle")
'draw a clipped triangle
mPath.Initialize(100dip, 280dip)
mPath.LineTo(180dip, 280dip)
mPath.LineTo(140dip, 360dip)
cvsLayer(2).ClipPath(mPath)
cvsLayer(2).DrawRect(cvsLayer(2).TargetRect, xui.Color_Blue, True, 1dip)
cvsLayer(2).RemoveClip
Log("draw an arc Path")
'draw an arc Path
Private mPath As B4XPath
xc = 10dip
yc = 420dip
Radius = 80dip
mPath.InitializeArc(xc, yc, Radius, -30, 60)
cvsLayer(2).DrawPath(mPath, xui.Color_Green, True, 1dip)
cvsLayer(2).RemoveClip
Log("draw a triangle path")
'draw a triangle path
Private mPath As B4XPath
mPath.Initialize(90dip, 380dip)
mPath.LineTo(170dip, 380dip)
mPath.LineTo(130dip, 460dip)
cvsLayer(2).DrawPath(mPath, xui.Color_Green, True, 1dip)
cvsLayer(2).RemoveClip
Log("draw a rotated triangle path with the center")
'draw a rotated triangle path with the center
Private mPath As B4XPath
mPath.Initialize(180dip, 380dip)
mPath.LineTo(260dip, 380dip)
mPath.LineTo(220dip, 460dip)
cvsLayer(2).DrawPathRotated(mPath, xui.Color_Green, True, 1dip, 15, 180dip, 380dip)
cvsLayer(2).RemoveClip
DrawCross(180dip, 380dip, xui.Color_Red)
Log("draw a rotated triangle path with the center")
'draw a rotated triangle path with the center
Private mPath As B4XPath
mPath.Initialize(260dip, 380dip)
mPath.LineTo(340dip, 380dip)
mPath.LineTo(300dip, 460dip)
cvsLayer(2).DrawPathRotated(mPath, xui.Color_Green, True, 1dip, 15, 300dip, 405dip)
cvsLayer(2).RemoveClip
DrawCross(300dip, 405dip, xui.Color_Red)
cvsLayer(2).Invalidate
Log("saves the bitmap of layer(2)")
'saves the bitmap of layer(2)
Dim Out As OutputStream
xui.SetDataFolder("SimpleDrawMethods")
Out = File.OpenOutput(xui.DefaultFolder, "Test.png", False)
cvsLayer(2).CreateBitmap.WriteToStream(Out, 100, "PNG")
Out.Close
cvsLayer(2).Release
End Sub