At the moment I’ve got a line graph drawing fine. However, I was thinking that it would look nicer filled with a colour.
I’ve read about “RGBSurface.FloodFill” and that could work but there are other program dependent issues that would make this approach unworkable (I think).
I understand that Graphic.DrawPolygon will “auto-fill” with reference to the x,y origin. Unfortunately “PolyLine” is not available where one can “close” the path ie. Adobe Illustrator etc.
Here’s an image of a typical graph where I’d like everything under the red line filled with a colour:
Here’s the code that creates it:
[code]
GraphPicture.Graphics.ForeColor = kGraphBase // Colour for the background
GraphPicture.Graphics.FillRect 0,0,me.Width,me.Height
Dim totalSamples as Integer
totalSamples = recordedGramsArray.Ubound
Dim forceY as integer
Dim X1,Y1,X2,Y2 as Double
GraphPicture.Graphics.ForeColor=kRedDark //Colour for the Graph itself
GraphPicture.Graphics.PenWidth=2 //thicker
GraphPicture.Graphics.PenHeight=2 //thicker
'-------graphing
For timeX as Integer = 0 to totalSamples-1
forceY = timeX
X1 = timeX * standardGridX * graphScaleFactorX
Y1 = kGraphHeight - recordedGramsArray(forceY) * standardGridY * graphScaleFactorY
X2 = (timeX+1) * standardGridX * graphScaleFactorX
Y2 = kGraphHeight - recordedGramsArray(forceY+1) * standardGridY * graphScaleFactorY
//Draw the final graph
GraphPicture.Graphics.DrawLine(X1, Y1, X2, Y2)
Next timeX
//Show the X/Y (Time/Grams) Value Labels
EvaluateAndShowXYlabels
//Update the Canvas
cnvGRAPH.Backdrop = GraphPicture[/code]
This is pretty much a “thought-fart”, as in it has nothing to do with the final calculations, but just makes it look nicer.
Nevertheless, it’s something that’s annoying and distracts me from finishing the main parts of my code. Perhaps an excuse for procrastination?