I'm not sure, what "techniques" you are referring to exactly, because the two main-requirements to achieve similar results as the demo above are only:
- you need Bezier- or BSpline-call support (e.g. already good old GDI supports Bezier-Curves)
- you need a 2D-lib that supports anti-aliased rendering + the definition of semi-transparent colors for "stroke or fill" (e.g. GDI+ allows that, whilst GDI does not)
In the concrete example above, the 2D-functionality is provided by cairo (a wellknown OpenSource-lib, which the RichClient-COMlib wraps in comfortable classes) -
and the Curves in question were generated with the wrappers Polygon-API-method (cairo natively doesn't offer a higher-level API for the rendering of Poly-Points).
So the wrappers PolygonAPI allows the comfortable passing of VBArrays of type Double or of Type Single - and aside from rendering such a Polygon
with the usual direct line-connections, it also supports a "rendering in-between those PolyPoints, using BSplines" - and that latter feature is, what the
demo above is using, to generate "curved paths".
If you want to see the just mentioned PolygonAPI-support of the RC5-wrapper in a more serious application
(e.g. here I have those recently encountered questions in mind, where the creation of Polynom-Coefficients was asked,
based on a few "incoming Sampling-Points", perhaps to be able to interpolate in-between those points - and perhaps
those interpolated Values were used finally, to "just render something between the original points").
Well, that usecase is needed often enough when you want to visualize curves from arbitrary incoming measurement-data.
Here's what's needed for this concrete task with the RC5-lib (it boils down to specifying one single optional parameter):
http://www.vbforums.com/images/ieimages/2013/07/1.png
Here the appropriate code in Text-format (paste it into a single VB-Form)
Code:
'needs a reference to the free vbRichClient5-lib, which is located and available on:
'http://www.vbRichClient.com/#/en/Downloads.htm
Option Explicit
Private Type PointDbl
x As Double
y As Double
End Type
Private Srf As cCairoSurface, Pts() As PointDbl
Private Sub Form_Load()
'Let's assume we have 5 x,y-Points of incoming measurement-data
'and those points are not even equidistant in x-direction...
ReDim Pts(0 To 4) 'reserve memory for those points, and fill with data
Pts(0).x = 100: Pts(0).y = 150
Pts(1).x = 180: Pts(1).y = 100
Pts(2).x = 330: Pts(2).y = 200
Pts(3).x = 450: Pts(3).y = 150
Pts(4).x = 650: Pts(4).y = 300
Move Left, Top, Screen.Width / 2, Screen.Height / 2
End Sub
Private Sub Form_Resize() 'here we ensure, that the Surface has the same size as the form ...
ScaleMode = vbPixels 'just take care, to ensure this size in Pixels (not in Twips ;-)
Set Srf = Cairo.CreateSurface(ScaleWidth, ScaleHeight)
Draw
End Sub
Private Sub Draw()
Dim i As Long
'Ok, onto the drawing:
With Srf.CreateContext 'we derive a drawing-context from our Surface
'and since we want to render within a Bottom-Up-Coord-System, ...
'we change from our top-down-default with the usual two lines of code:
.TranslateDrawings 0, Srf.Height 'the y-coord-point is shifted to the bottom
.ScaleDrawings 1, -1 'and the y-scale is negated (but otherwise not "stretched")
'now let's draw lines between our Poly-Points as any PolygonAPI-call allows
.SetSourceColor vbGreen 'define the color for the next operation
.PolygonPtr VarPtr(Pts(0)), UBound(Pts) + 1 'define the path per drawing-call
.Stroke 'stroke it with the current color
'now, what if we need to draw between our measure-points more smoothly?
.SetSourceColor vbRed '...easy as pie, since we use the same call on the same data...
.PolygonPtr VarPtr(Pts(0)), UBound(Pts) + 1, , splNormal, True '<-just two more params
.Stroke 'stroke it with the current color
'and just for good measure, we visualize, where the original Points were
.SetSourceColor vbYellow, 0.5 '<- an Alpha-Color-Def for the points-overlay
For i = 0 To UBound(Pts)
.ARC Pts(i).x, Pts(i).y, 7 'a fully closed circle with radius 7
.Fill 'fill the circular path
Next i
End With
Set Me.Picture = Srf.Picture 'this is just one of the different output-methods of a cairo-surface
End Sub
Private Sub Form_Terminate()
If Forms.Count = 0 Then New_c.CleanupRichClientDll
End Sub
If you're after more and deeper examples (not only for the Polygon-API-call above) then (by all means), please download the huge cairo-Drawing-Tutorial...
Here's a page which links to all the different Tutorials for the RC5-lib.
http://www.vbrichclient.com/#/en/Demos/GUI/
And here's a direct link to the Zip-File of the cairo-Tutorial (which contains in 20+ standalone Folders everything a VB-Dev possibly needs, to satisfy "modern 2D-grahics-desires" <g>).
http://www.vbrichclient.com/Download...roTutorial.zip (about 7MB, because it contains a lot of image-resources)
Since we talked about BSplines - here's another use-case, e.g. when you want to define the Baseline for "curved TextOutputs" (with draggable control-points):
http://www.vbforums.com/images/ieimages/2013/07/1.png
Or since you were interested in more "charting-like outputs" - here's dynamically and directly (per cairo-surface) created PDF:
(the small window to the right side shows only a visualizing of the cairo-created PDF-output, it's just a secondary screen which
doesn't have much to do with the Demo itself, because the OnScreen-Preview of the PDF is done per cairo-ImageSurface-type -
and then the same drawing-routines are applied against cairos PDF-surface-type, without changing a single line of drawing-code.
http://www.vbforums.com/images/ieimages/2013/07/1.jpg
Olaf