In this chapter, the explanations on the topic of 'Drawing with methods of the Paint class' are implemented in two specific projects. Almost all drawings are based on script-like Paint command sequences, as the methods of the Paint class are designed more for use as a construction description for lines, shapes and text than for free drawing on a suitable drawing area such as a DrawingArea.
The presentation of the projects is supplemented by comments on the specified project source text and numerous images.
Figure 23.3.4.0.1: Tangent array
Source code excerpt:
Public Sub PaintScriptBezierApproximation() Dim PS, P1, P2, P3, PE As New PointF Dim i, k As Integer Dim dx1, dx2, t As Float GenerateNewPicture() SetPictureBorder() Paint.Begin(hPicture) Paint.Translate(xTranslate, yTranslate) Paint.Scale(xScale, yScale) '-- +y ▲ DrawCoordinateSystem() P1.x = 30 P1.y = 240 P2.x = 150 P2.y = 30 P3.x = 500 P3.y = 270 k = 30 '-- Number of tangents dx1 = (P2.x - P1.x) / k dx2 = (P3.x - P2.x) / k ... Paint.LineWidth = 1 For i = 1 To k + 1 Paint.MoveTo(P1.x + (i - 1) * dx1, a(P1.x + (i - 1) * dx1)) Paint.LineTo(P2.x + (i - 1) * dx2, b(P2.x + (i - 1) * dx2)) Next Paint.Stroke() '-- TEXT Paint.NewPath Paint.Scale(1, -1) '-- ATTENTION: y-axis now with *positive* values downwards! Paint.Font = Font["Monospace, 10, bold"] Paint.Brush = Paint.Color(Color.Red) Paint.DrawText("P1(30|240)", 10, -250) Paint.DrawText("P2(150|30)", 120, -10) Paint.DrawText("P3(500|270)", 455, -285) Paint.Scale(1, -1) Paint.End() End