Ver 2 : VectorDrawing Chart
- VB6_to_PBx
- Enthusiast
- Posts: 625
- Joined: Mon May 09, 2011 9:36 am
Re: VectorDrawing Chart
RASHAD , thanks for this awesome Chart example !!!
PureBasic .... making tiny electrons do what you want !
"With every mistake we must surely be learning" - George Harrison
- Andre
- PureBasic Team
- Posts: 2071
- Joined: Fri Apr 25, 2003 6:14 pm
- Location: Germany (Saxony, Deutscheinsiedel)
- Contact:
Re: VectorDrawing Chart
Excellent piece of code, thank you very much, RASHAD!
While I successfully tried the BarChart (after uncommenting the related code in the current stage of the posted example), the PieChart didn't work: I got a read/memory error, it seems because of a missing Data block... (see the calling code: "Read StartAngle : Read EndAngle")
While I successfully tried the BarChart (after uncommenting the related code in the current stage of the posted example), the PieChart didn't work: I got a read/memory error, it seems because of a missing Data block... (see the calling code: "Read StartAngle : Read EndAngle")
Re: VectorDrawing Chart
Hi Andre
I did not finish it yet
Just coding the basics routines
A lot of work to code in 2D & 3D(visually )
Replace :
I did not finish it yet
Just coding the basics routines
A lot of work to code in 2D & 3D(visually )
Replace :
Code: Select all
Restore PieData
myInitPie(150, 250,100,75)
Read StartAngle : Read EndAngle
myPie(150, 250,100,75 , StartAngle, EndAngle,RGBA(0, 255, 255, 255))
Read StartAngle : Read EndAngle
myPie(150, 250,100,75 , StartAngle, EndAngle,RGBA(0, 0, 255, 255))
Read StartAngle : Read EndAngle
myPie(150, 250,100,75 , StartAngle, EndAngle,RGBA(255, 0, 0, 255))
Read StartAngle : Read EndAngle
myPie(150, 250,100,75 , StartAngle, EndAngle,$FF53FDF3)
Restore BarData
Read.l dta
myBlockbar(dta,50,RGBA(255,0, 0, 255))
Read.l dta
myBlockbar(dta,100,RGBA(0, 255, 0, 255))
Read.l dta
myBlockbar(dta,150,RGBA(0, 0, 255, 255))
Read.l dta
myBlockbar(dta,200,RGBA(255, 255, 10, 255))
VectorFont(FontID(0),12)
VectorSourceColor($FFFFFFFF)
Restore BarData
For x = 60 To 210 Step 50
Read.l a
ResetPath()
ResetCoordinates()
MovePathCursor(x, 370)
RotateCoordinates(0,0, 45)
DrawVectorText(Str(a))
Next
StopVectorDrawing()
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
DataSection
BarData:
Data.l 160, 260, 210, 190
PieData:
Data.l 0,70,70,130,120,219,220,360
EndDataSection
Egypt my love
Re: Ver 2 : VectorDrawing Chart
Hi
- Resize the chart
- Cleaned and Compacted code
- Easy to Understand
- Easy to use
Remember to load your own Image
Edit :Modified for better performance
Edit #2
- Resize the chart
- Cleaned and Compacted code
- Easy to Understand
- Easy to use
Remember to load your own Image
Code: Select all
UseJPEG2000ImageDecoder()
UseJPEG2000ImageEncoder()
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UsePNGImageDecoder()
UsePNGImageEncoder()
UseTGAImageDecoder()
UseTIFFImageDecoder()
Global Scaleh.d,Scalev.d,orgw,orgh
LoadFont(0,"Consalos",10)
;LoadImage(0, "e:\image12.bmp") ;Use your own image
If Not LoadImage(0, "e:\image12.bmp") ;Use your own image
; Create an own image and do simply drawing on it, if there isn't loaded any image yet
CreateImage(0, 800,600)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Gradient)
BackColor($00FFFF)
FrontColor($FF0000)
BoxedGradient(0, 0, 800,600)
DrawText(200, 100, "Dummy Image")
StopDrawing()
EndIf
CreateImage(1,200,200,32)
StartVectorDrawing(ImageVectorOutput(1))
VectorSourceLinearGradient(0, 0, 200, 200)
VectorSourceGradientColor(RGBA(255, 255, 255, 128), 0.0)
VectorSourceGradientColor(RGBA(0, 0, 0, 128), 1.0)
AddPathBox(0, 0, 200, 200)
FillPath()
StopVectorDrawing()
CreateImage(2,200,200,32)
StartVectorDrawing(ImageVectorOutput(2))
VectorSourceCircularGradient(200, 100, 150, -50, -50)
VectorSourceGradientColor(RGBA(255, 255, 255, 255), 0.0)
VectorSourceGradientColor(RGBA(0, 0, 0, 255), 1.0)
FillVectorOutput()
StopVectorDrawing()
Procedure myBKG(image,ialpha,effect,ealpha)
ResetPath()
ResetCoordinates()
MovePathCursor(0,0)
DrawVectorImage(ImageID(image),ialpha,WindowWidth(0),WindowHeight(0))
MovePathCursor(4,4)
If effect <> image And effect > 0
DrawVectorImage(ImageID(effect),ealpha,WindowWidth(0)-8,WindowHeight(0)-8)
EndIf
EndProcedure
Procedure myTitle(Text$,left,top,Color)
VectorFont(FontID(0),32)
VectorSourceColor($FFFFFFFF)
ResetPath()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
MovePathCursor(left+2,top)
;RotateCoordinates(0,0, 10)
DrawVectorText(Text$)
VectorSourceColor($FF0000FF)
ResetPath()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
MovePathCursor(left,top-2)
;RotateCoordinates(0,0, 10)
DrawVectorText(Text$)
ResetCoordinates()
ScaleCoordinates(Scaleh,Scalev)
MovePathCursor(500,382)
VectorFont(FontID(0),16)
VectorSourceColor($FFFFFFFF)
DrawVectorText("RASHAD "+Chr(169))
ResetPath()
ResetCoordinates()
EndProcedure
Procedure myAxis()
Restore AxisData
Read gridColor:Read xStep: Read xtextColor:Read yStep: Read ytextColor
ResetPath()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
MovePathCursor(20,25)
Repeat
x + xStep
VectorSourceColor(gridColor)
MovePathCursor(x,20)
AddPathLine(x, 370)
StrokePath(0.2)
MovePathCursor(x-4,375)
VectorFont(FontID(0),7)
VectorSourceColor(-xtextColor)
DrawVectorText(Str(x-25))
Until x >= 680
ResetCoordinates()
ScaleCoordinates(Scaleh,Scalev)
Repeat
y + yStep
VectorSourceColor(gridColor)
MovePathCursor(22,y-5)
AddPathLine(580, y)
StrokePath(0.2)
VectorFont(FontID(0),7)
VectorSourceColor(-ytextColor)
MovePathCursor(5,y-10)
DrawVectorText(Str(375 - y))
Until y >= 370
ResetPath()
ResetCoordinates()
EndProcedure
Procedure my3DLine()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
ResetPath()
VectorFont(FontID(0),12)
MovePathCursor(30,375-y)
VectorSourceColor($FF0000FF)
xx = 0
Restore LineData
Read n
Read x :Read y
MovePathCursor(x,375-y)
For dot = 1 To n
Read x :Read y
xx + x
VectorSourceColor($BC16FD14)
VectorSourceLinearGradient(20, 0, 45, 0)
VectorSourceGradientColor($BC16FD14, 0.5)
AddPathLine(xx,375-y)
StrokePath(4,#PB_Path_RoundEnd)
MovePathCursor(xx-10,360 - y)
VectorSourceColor($FFFFFF00)
DrawVectorText(Str(y))
MovePathCursor(xx,375-y)
Next
ResetPath()
ResetCoordinates()
EndProcedure
Procedure my3DCyl()
Restore CylData
Read n
VectorFont(FontID(0),12)
For i = 1 To n
Read x: Read y :Read Color
ResetPath()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
VectorSourceColor(-Color)
VectorSourceLinearGradient(20, 0, 45, 0)
VectorSourceGradientColor(-Color, 0.5)
AddPathBox(x,360-y, 20, y)
FillPath()
VectorSourceColor($FFFFFFFF)
MovePathCursor(x+10, 370)
RotateCoordinates(0,0, 45)
DrawVectorText(Str(y))
Next
ResetPath()
ResetCoordinates()
EndProcedure
Procedure my3DBar()
Restore Bar3Data
Read n
VectorFont(FontID(0),12)
For i = 1 To n
Read x: Read y :Read Color
ResetPath()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
VectorSourceColor(-Color)
MovePathCursor(x,360-y)
AddPathLine(20, 0, #PB_Path_Relative)
AddPathLine(0,y, #PB_Path_Relative)
AddPathLine(10,-10, #PB_Path_Relative)
AddPathLine(0,-y, #PB_Path_Relative)
AddPathLine(-20,0, #PB_Path_Relative)
ClosePath()
FillPath()
StrokePath(1)
AddPathBox(x,360-y, 20, y)
FillPath()
VectorSourceColor(2147483648)
AddPathBox(x,360-y, 20, y)
FillPath()
VectorSourceColor($FFFFFFFF)
MovePathCursor(x+15, 370)
RotateCoordinates(0,0, 45)
DrawVectorText(Str(y))
Next
ResetPath()
ResetCoordinates()
EndProcedure
Procedure my3DPie()
Restore PieData
Read n : Read x : Read y :Read RadiusX : Read RadiusY :Read iColor
ResetPath()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
VectorFont(FontID(0),12)
VectorSourceCircularGradient(x, y, 160, 0, 0)
VectorSourceGradientColor(-iColor, 0.0)
MovePathCursor(x, y+12)
AddPathEllipse(x, y+14,100,70,0,360,#PB_Path_Connected)
FillPath()
For i = 1 To n
Read StartAngle: Read EndAngle :Read Color
VectorSourceCircularGradient(200, 150, 400, 10, 10)
VectorSourceGradientColor(-Color, 0.0)
MovePathCursor(x, y)
AddPathEllipse(x, y, RadiusX, RadiusY , StartAngle, EndAngle,#PB_Path_Connected)
FillPath()
xx + 25
MovePathCursor(x+120, y-50 + xx)
VectorFont(FontID(0),24)
VectorSourceColor(-Color|$FF000000)
DrawVectorText(Str((EndAngle-StartAngle)*100/360)+" %")
Next
ResetPath()
ResetCoordinates()
EndProcedure
Procedure my2DLine()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
ResetPath()
VectorFont(FontID(0),12)
MovePathCursor(30,400-y)
VectorSourceColor($FF0000FF)
xx = 0
Restore LineData
Read n
Read x :Read y
MovePathCursor(x,375-y)
For dot = 1 To n
Read x :Read y
xx + x
VectorSourceColor($FFFFFFFF)
AddPathLine(xx,375-y)
StrokePath(1)
MovePathCursor(xx-10,360 - y)
VectorSourceColor($FFFFFF00)
DrawVectorText(Str(y))
MovePathCursor(xx,375-y)
Next
ResetPath()
ResetCoordinates()
EndProcedure
Procedure my2DPie()
Restore PieData2
Read n : Read x : Read y :Read RadiusX : Read iColor
ResetPath()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
VectorFont(FontID(0),12)
For i = 1 To n
Read StartAngle: Read EndAngle :Read Color
VectorSourceCircularGradient(200, 150, 400, 10, 10)
VectorSourceGradientColor(-Color, 0.0)
MovePathCursor(x, y)
AddPathCircle(x, y, RadiusX, StartAngle, EndAngle,#PB_Path_Connected)
FillPath()
xx + 25
MovePathCursor(x+120, y-50 + xx)
VectorFont(FontID(0),24)
VectorSourceColor(-Color|$FF000000)
DrawVectorText(Str((EndAngle-StartAngle)*100/360)+" %")
Next
ResetPath()
ResetCoordinates()
EndProcedure
Procedure my2DBar()
Restore BarData
Read n :Read w
VectorFont(FontID(0),12)
For i = 1 To n
Read x: Read y :Read Color
ResetPath()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
VectorSourceColor(-Color)
MovePathCursor(x,360-y)
AddPathBox(x,360-y, w, y)
FillPath()
VectorSourceColor($FFFFFFFF)
MovePathCursor(x+15, 370)
RotateCoordinates(0,0, 45)
DrawVectorText(Str(y))
Next
ResetPath()
ResetCoordinates()
EndProcedure
Procedure myResize()
ResizeImage(image,WindowWidth(0),WindowHeight(0)-35,#PB_Image_Smooth)
ResizeImage(effect,WindowWidth(0),WindowHeight(0)-35,#PB_Image_Smooth)
ResizeGadget(0,0,0,WindowWidth(0),WindowHeight(0)-30)
EndProcedure
Scaleh = 1.0
Scalev = 1.0
CatchImage(10,?Bar3d)
CatchImage(11,?Pie3d)
CatchImage(12,?Line2d)
CatchImage(13,?Bar2d)
CatchImage(14,?Pie2d)
If OpenWindow(0, 0, 0, 600, 430, "Chart Drawing", #PB_Window_MaximizeGadget| #PB_Window_SizeGadget| #PB_Window_ScreenCentered )
If CreateImageMenu(0, WindowID(0))
CanvasGadget(0,0,0,WindowWidth(0),WindowHeight(0))
MenuTitle("3D Chart")
MenuItem( 1, "3D Line")
MenuItem( 2, "3D Bar",ImageID(10))
MenuItem( 3, "3D Cylinder")
MenuItem( 4, "3D Pie",ImageID(11))
MenuItem( 5, "&Quit")
MenuTitle("2D Chart")
MenuItem( 6, "2D Line",ImageID(12))
MenuItem( 7, "2D Bar",ImageID(13))
MenuItem( 8, "2D Pie",ImageID(14))
MenuTitle("?")
MenuItem(9, "About")
EndIf
orgw = WindowWidth(0)
orgh = WindowHeight(0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Menu
Select EventMenu()
Case 1
Chart = 1
Case 2
Chart = 2
Case 3
Chart = 3
Case 4
Chart = 4
Case 5
Quit = 1
Case 6
Chart = 6
Case 7
Chart = 7
Case 8
Chart = 8
Case 9
Case 10
EndSelect
PostEvent(#PB_Event_SizeWindow,0,0)
Case #PB_Event_Gadget
Select EventGadget()
Case 1
EndSelect
Case #PB_Event_SizeWindow
Scaleh = WindowWidth(0)/orgw
Scalev = WindowHeight(0)/orgh
myResize()
StartVectorDrawing(CanvasVectorOutput(0))
myBKG(0,200,2,200) ;bkground(image,ialpha,effect,ealpha)
myAxis()
myTitle("RASHAD",30,25,$FF0000FF)
If Chart = 1
my3DLine()
ElseIf Chart = 2
my3DBar()
ElseIf Chart = 3
my3DCyl()
ElseIf Chart = 4
my3DPie()
ElseIf Chart = 6
my2DLine()
ElseIf Chart = 7
my2DBar()
ElseIf Chart = 8
my2DPie()
EndIf
StopVectorDrawing()
EndSelect
Until Quit = 1
EndIf
DataSection
AxisData:
Data.i 3163196042,25,15925727,25,15664900
BarData: ;No of Bars,width,x,y(Data),Color,x,y(Data),Color,...
Data.i 6,10,50,160,16776961,70,110,16056321,100,260,16711936,120,290,16776961, 150,210,65536,200,190,16056321
Bar3Data: ;No of Bars,x,y(Data),Color,x,y(Data),Color,...
Data.i 4,50,160,16776961,100,260,16711936,150,210,65536,200,190,16056321
CylData: ;No of Bars,x,y(Data),Color,x,y(Data),Color,...
Data.i 4,50,160,16776961,100,260,16711936,150,210,65536,200,190,16056321
PieData: ;No of Segments,x, y, RadiusX, RadiusY,Initial Color,StartAngle, EndAngle,Color,StartAngle, EndAngle,Color,...
Data.i 4,150,250,100,75,16711681,0,70,16776961,70,130,16711936,120,219,65536,220,360,16056321
PieData2: ;No of Segments,x, y, Radius, Initial Color,StartAngle, EndAngle,Color,StartAngle, EndAngle,Color,...
Data.i 4,150,250,75,16711681,0,70,16776961,70,130,16711936,120,219,65536,220,360,16056321
LineData: ;No of Nodes,from,to,Color,from,to,Color,etc.
Data.i 10,30,30,50,70,50,120,60,90,70,110,50,70,50,120,60,80,50,70,60,200,70,130
EndDataSection
DataSection
Bar3d:
IncludeBinary "Bar3D.ico"
Pie3d:
IncludeBinary "Pie3D.ico"
Line2d:
IncludeBinary "Line2D.ico"
Bar2D:
IncludeBinary "Bar2D.ico"
Pie2D:
IncludeBinary "Pie2D.ico"
EndDataSection
Edit #2
Last edited by RASHAD on Tue Feb 16, 2016 7:33 pm, edited 2 times in total.
Egypt my love
Re: Ver 2 : VectorDrawing Chart
@RASHAD,
Very nice.
Two minor issues:
1. 3D Show on 2D menu
2. Only line chart works on 2D, which is under the 3D menu!
Very nice.
Two minor issues:
1. 3D Show on 2D menu
2. Only line chart works on 2D, which is under the 3D menu!
DE AA EB
- Andre
- PureBasic Team
- Posts: 2071
- Joined: Fri Apr 25, 2003 6:14 pm
- Location: Germany (Saxony, Deutscheinsiedel)
- Contact:
Re: Ver 2 : VectorDrawing Chart
Very nice, RASHAD. It's getting better and better!
Unfortunately I haven't the needed time at the moment, to help with further improvement. But this piece of code is definately worth extending and improving it!
Some things I had implemented in an older Chart code template for my project:
- Chart types: Line, Point, Line&Point (combined), Column, Bar, Stacked Column (all in 2D and 3D)
- support for up-to 5 data blocks (e.g. population data for up to 5 countries for each year to display)
- axis labels (for x any y axis)
- legend (describing the displayed chart elements, with name)
(couldn't post the created Chart include here, as it's deeply implemented in my project with a lot of dependancies etc. - so it's unable to compile/run standalone unfortunately)
A complete rewrite using the VectorDrawing provides a lot more possibilites: easing resizing, it seems a lot less code than (manually calculating and) drawing pixel-based chart forms,...
Just because I was too lazy to search for and load an image I have added this code for creating a dummy image instead (so the code can be run out-of-the-box )
Unfortunately I haven't the needed time at the moment, to help with further improvement. But this piece of code is definately worth extending and improving it!
Some things I had implemented in an older Chart code template for my project:
- Chart types: Line, Point, Line&Point (combined), Column, Bar, Stacked Column (all in 2D and 3D)
- support for up-to 5 data blocks (e.g. population data for up to 5 countries for each year to display)
- axis labels (for x any y axis)
- legend (describing the displayed chart elements, with name)
(couldn't post the created Chart include here, as it's deeply implemented in my project with a lot of dependancies etc. - so it's unable to compile/run standalone unfortunately)
A complete rewrite using the VectorDrawing provides a lot more possibilites: easing resizing, it seems a lot less code than (manually calculating and) drawing pixel-based chart forms,...
Just because I was too lazy to search for and load an image I have added this code for creating a dummy image instead (so the code can be run out-of-the-box )
Code: Select all
If Not LoadImage(0, "e:\image12.bmp") ;Use your own image
; Create an own image and do simply drawing on it, if there isn't loaded any image yet
CreateImage(0, 440, 230)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Gradient)
Circle(110, 105, 100, $0000FF)
Circle(310, 105, 100, $000000)
DrawingMode(#PB_2DDrawing_Outlined)
DrawText(200, 100, "Dummy Image")
StopDrawing()
EndIf
Re: Ver 2 : VectorDrawing Chart
Previous post updated
Hi davido
Fixed a lot of Bugs
Check
Hi Andre
Most of your suggestions and more are planned to do(Needed time)
To do first:
- Read data from file
- Enter data dynamic
- Print the Chart
- Add More Chart styles (as per your post plus Grouped and Floating ones)
Be tuned
Hi davido
Fixed a lot of Bugs
Check
Hi Andre
Most of your suggestions and more are planned to do(Needed time)
To do first:
- Read data from file
- Enter data dynamic
- Print the Chart
- Add More Chart styles (as per your post plus Grouped and Floating ones)
Be tuned
Egypt my love
- Andre
- PureBasic Team
- Posts: 2071
- Joined: Fri Apr 25, 2003 6:14 pm
- Location: Germany (Saxony, Deutscheinsiedel)
- Contact:
Re: Ver 2 : VectorDrawing Chart
Sounds absolutely great, RASHAD!
Re: Ver 2 : VectorDrawing Chart
impressive update! just a minor bug youre probably already aware of, you can resize the window and the background image is stretched but the chart doesn't change proportions
Re: Ver 2 : VectorDrawing Chart
@RASHAD,
I have searched but cannot find the .ico files.
Where can I find them, please.
I have searched but cannot find the .ico files.
Where can I find them, please.
DE AA EB
Re: Ver 2 : VectorDrawing Chart
Previous post updated
Fixed some bugs
Added some features
Hi Keya
Fixed
Check
Hi davido
Use any icon file right now to run the code
I just downloaded all from the free icons sites
Fixed some bugs
Added some features
Hi Keya
Fixed
Check
Hi davido
Use any icon file right now to run the code
I just downloaded all from the free icons sites
Egypt my love
- Andre
- PureBasic Team
- Posts: 2071
- Joined: Fri Apr 25, 2003 6:14 pm
- Location: Germany (Saxony, Deutscheinsiedel)
- Contact:
Re: Ver 2 : VectorDrawing Chart
Again, a very welcome step forward. Nice work, RASHAD!
I think it would be good (if not already planned), to have something like an "interface": e.g. for
I think it would be good (if not already planned), to have something like an "interface": e.g. for
- a) filling a predefined linked list with structured Chart data ('values', 'axis description' - e.g. 'years' on x-axis while the y-axis is automatically calculated from the values, optional 'dimension' value - e.g. for yearly values of more than one element, example: displaying the population figures of 2 or 3 countries over the last 20 years in a bar-chart).
b) giving pre-defined color values for coloring the chart elements in a requested way
Re: Ver 2 : VectorDrawing Chart
Really great and useful code, Rashad, thank you.
Only my3DCyl()-content appears on Linux as flat 2D bars, not as tubes.
Since I've never worked with VectorLibrary a little question:
Are the my3DCyl()-routines more a random working code on Windows or code I don't understand (more likely ) and it should work on Linux too?
I've tried a replacement code for my3DCyl() on Linux as I would make it for 3D and it also works on Windows - similar appearance to your method.But where is the problem now since it does not work compatible?
Best Regards, Charly
Only my3DCyl()-content appears on Linux as flat 2D bars, not as tubes.
Since I've never worked with VectorLibrary a little question:
Are the my3DCyl()-routines more a random working code on Windows or code I don't understand (more likely ) and it should work on Linux too?
I've tried a replacement code for my3DCyl() on Linux as I would make it for 3D and it also works on Windows - similar appearance to your method.
Code: Select all
;Rashad ...
; VectorSourceLinearGradient(20, 0, 45, 0)
; VectorSourceGradientColor(-Color, 0.5)
;Windows & Linux (Omis trials) ...
VectorSourceLinearGradient(x, 0, x+25, 0)
VectorSourceGradientColor(RGBA(Red(0), Green(0), Blue(0), 255), 0.0)
VectorSourceGradientColor(RGBA(Red(-Color), Green(-Color), Blue(-Color), 255), 0.5)
VectorSourceGradientColor(RGBA(Red(0), Green(0), Blue(0), 255), 1.0)
Best Regards, Charly
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
Re: Ver 2 : VectorDrawing Chart
;This is not a statistical programe it is just a Chart Process
;The user is responsible for calculating the chart coordinates
;I tried to make as simple as possible and it should be cross platform as well
;1- The Chart type
;2- Thickness if req. , No. of nodes
;3- Style ,Visibilty status ,Specs of each node
;4- 3 Repeated as you wish
;- Load from file
;- Edit new file
;- Save as Image
;- Change the Data at any time
;- View many Styles at one sheet
;- And more
; Feel free To complete - modify or whatever as you like
Save the next As "PB_CHART.pbd" (Text File)
Run the code and open the saved file
Edit :Modified and bugs fixed
;The user is responsible for calculating the chart coordinates
;I tried to make as simple as possible and it should be cross platform as well
;1- The Chart type
;2- Thickness if req. , No. of nodes
;3- Style ,Visibilty status ,Specs of each node
;4- 3 Repeated as you wish
;- Load from file
;- Edit new file
;- Save as Image
;- Change the Data at any time
;- View many Styles at one sheet
;- And more
; Feel free To complete - modify or whatever as you like
Save the next As "PB_CHART.pbd" (Text File)
Run the code and open the saved file
Code: Select all
PB_DOT
4,12
1,1,30,30,4278915582
1,1,140,90,4278915582
1,1,200,60,4278915582
2,1,10,10,4281269514
2,1,100,210,4281269514
2,1,170,90,4281269514
3,1,50,50,4294782215
3,1,120,210,4294782215
3,1,300,300,4294782215
4,1,60,60,4278582779
4,1,200,190,4278582779
4,1,100,120,4278582779
PB_LINE
20,8
1,1,30,30,50,70,4278915582
1,1,50,70,100,210,4278915582
1,1,100,210,175,90,4278915582
1,1,175,90,310,230,4278915582
4,1,30,30,100,170,4281269514
4,1,100,170,150,210,4281269514
4,1,150,210,170,100,4281269514
4,1,170,100,410,210,4281269514
PB_BAR
10,4
1,1,30,30,10,300,4278915582,0,0,0
1,1,50,30,10,140,4281269514,0,0,0
2,0,30,30,150,10,4278915582,0,0,0
2,0,30,50,200,10,4281269514,0,0,0
Code: Select all
UseJPEG2000ImageDecoder()
UseJPEG2000ImageEncoder()
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UsePNGImageDecoder()
UsePNGImageEncoder()
UseTGAImageDecoder()
UseTIFFImageDecoder()
Structure DotData
st.i
vw.i
x0.d
y0.d
DColor.i
EndStructure
Structure LineData
st.i
vw.i
x0.d
y0.d
x1.d
y1.d
LColor.i
EndStructure
Structure BarData
st.i
vw.i
x0.d
y0.d
x1.d
y1.d
BColor.i
x2.d
y2.d
BColor2.i
EndStructure
Structure PieData ;No of Segments,x, y, Radius, Initial Color
st.i
vw.i
StartAngle.d
EndAngle.d
PColor.i
EndStructure
Global Dim ddba.Dotdata(0),Dim ldba.Linedata(0),Dim bdba.BarData(0) , Dim pdba.PieData(0),Dim dashes.d(7)
Global File$,Scaleh.d,Scalev.d,orgw,orgh ,Dthick,Lthick.f,bWidth,itemd,iteml,itemb,itemp
dashes(0) = 8
dashes(1) = 4
dashes(2) = 0 ; draw a dot
dashes(3) = 4
dashes(4) = 0
dashes(5) = 4
dashes(6) = 8
dashes(7) = 4
LoadFont(0,"Consalos",10)
;LoadImage(0, "e:\image12.bmp") ;Use your own image
If Not LoadImage(0, "e:\image12.bmp") ;Use your own image
; Create an own image and do simply drawing on it, if there isn't loaded any image yet
CreateImage(0, 800,600)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Gradient)
BackColor($00FFFF)
FrontColor($FF0000)
BoxedGradient(0, 0, 800,600)
DrawText(200, 100, "Dummy Image")
StopDrawing()
EndIf
CreateImage(1,200,200,32)
StartVectorDrawing(ImageVectorOutput(1))
VectorSourceLinearGradient(0, 0, 200, 200)
VectorSourceGradientColor(RGBA(255, 255, 255, 128), 0.0)
VectorSourceGradientColor(RGBA(0, 0, 0, 128), 1.0)
AddPathBox(0, 0, 200, 200)
FillPath()
StopVectorDrawing()
CreateImage(2,200,200,32)
StartVectorDrawing(ImageVectorOutput(2))
VectorSourceCircularGradient(200, 100, 150, -50, -50)
VectorSourceGradientColor(RGBA(255, 255, 255, 255), 0.0)
VectorSourceGradientColor(RGBA(0, 0, 0, 255), 1.0)
FillVectorOutput()
StopVectorDrawing()
Procedure myBKG(image,ialpha,effect,ealpha)
ResetPath()
ResetCoordinates()
MovePathCursor(0,0)
DrawVectorImage(ImageID(image),ialpha,WindowWidth(0),WindowHeight(0))
MovePathCursor(4,4)
If effect <> image And effect > 0
DrawVectorImage(ImageID(effect),ealpha,WindowWidth(0)-8,WindowHeight(0)-8)
EndIf
EndProcedure
Procedure myTitle(Text$,left,top,Color)
VectorFont(FontID(0),32)
VectorSourceColor($FFFFFFFF)
ResetPath()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
MovePathCursor(left+2,top)
;RotateCoordinates(0,0, 10)
DrawVectorText(Text$)
VectorSourceColor($FF0000FF)
ResetPath()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
MovePathCursor(left,top-2)
;RotateCoordinates(0,0, 10)
DrawVectorText(Text$)
ResetCoordinates()
ScaleCoordinates(Scaleh,Scalev)
MovePathCursor(500,382)
VectorFont(FontID(0),16)
VectorSourceColor($FFFFFFFF)
DrawVectorText("RASHAD "+Chr(169))
ResetPath()
ResetCoordinates()
EndProcedure
Procedure myAxis()
Restore AxisData
Read gridColor:Read xStep: Read xtextColor:Read yStep: Read ytextColor
ResetPath()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
MovePathCursor(20,25)
While x < 680
x + xStep
VectorSourceColor(gridColor)
MovePathCursor(x,20)
AddPathLine(x, 370)
StrokePath(0.2)
MovePathCursor(x-4,375)
VectorFont(FontID(0),7)
VectorSourceColor(-xtextColor)
DrawVectorText(Str(x-25))
Wend
ResetCoordinates()
ScaleCoordinates(Scaleh,Scalev)
While y < 370
y + yStep
VectorSourceColor(gridColor)
MovePathCursor(22,y-5)
AddPathLine(580, y)
StrokePath(0.2)
VectorFont(FontID(0),7)
VectorSourceColor(-ytextColor)
MovePathCursor(5,y-10)
DrawVectorText(Str(375 - y))
Wend
ResetPath()
ResetCoordinates()
EndProcedure
Procedure myDot()
ResetPath()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
For i = 0 To itemd - 1
If ddba(i)\st = 1 And ddba(i)\vw = 1
VectorSourceColor(ddba(i)\DColor)
MovePathCursor(ddba(i)\x0+25,370-ddba(i)\y0)
AddPathCircle(ddba(i)\x0+25,370-ddba(i)\y0,Dthick)
FillPath()
ElseIf ddba(i)\st = 2 And ddba(i)\vw = 1
VectorSourceColor(ddba(i)\DColor)
MovePathCursor(ddba(i)\x0+25,370-ddba(i)\y0)
AddPathBox(ddba(i)\x0+25,370-ddba(i)\y0,2*Dthick,2*Dthick)
FillPath()
ElseIf ddba(i)\st = 3 And ddba(i)\vw = 1
VectorSourceColor(ddba(i)\DColor)
MovePathCursor(ddba(i)\x0+25,370-ddba(i)\y0)
RotateCoordinates(ddba(i)\x0+25,370-ddba(i)\y0, 45)
AddPathBox(ddba(i)\x0+25,370-ddba(i)\y0,2*Dthick,2*Dthick)
FillPath()
RotateCoordinates(ddba(i)\x0+25,370-ddba(i)\y0, -45)
ElseIf ddba(i)\st = 4 And ddba(i)\vw = 1
VectorSourceColor(ddba(i)\DColor)
MovePathCursor(ddba(i)\x0+25,370-ddba(i)\y0)
AddPathCircle(ddba(i)\x0+25,370-ddba(i)\y0,Dthick)
FillPath()
VectorSourceColor($FF0000FF)
AddPathCircle(ddba(i)\x0+25,370-ddba(i)\y0,Dthick/2)
FillPath()
EndIf
Next
ResetPath()
ResetCoordinates()
EndProcedure
Procedure myLine()
ResetPath()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
For i = 0 To iteml - 1
If ldba(i)\st = 1 And ldba(i)\vw = 1
VectorSourceColor(ldba(i)\LColor)
MovePathCursor(ldba(i)\x0+25,370-ldba(i)\y0)
AddPathLine(ldba(i)\x1+25,370-ldba(i)\y1)
StrokePath(LThick,#PB_Path_RoundEnd)
ElseIf ldba(i)\st = 2 And ldba(i)\vw = 1
VectorSourceColor(ldba(i)\LColor)
MovePathCursor(ldba(i)\x0+25,370-ldba(i)\y0)
AddPathLine(ldba(i)\x1+25,370-ldba(i)\y1)
DashPath(Lthick, 5 ,#PB_Path_RoundEnd)
ElseIf ldba(i)\st = 3 And ldba(i)\vw = 1
VectorSourceColor(ldba(i)\LColor)
MovePathCursor(ldba(i)\x0+25,370-ldba(i)\y0)
AddPathLine(ldba(i)\x1+25,370-ldba(i)\y1)
DotPath(LThick, 5, #PB_Path_RoundEnd)
ElseIf ldba(i)\st = 4 And ldba(i)\vw = 1
VectorSourceColor(ldba(i)\LColor)
MovePathCursor(ldba(i)\x0+25,370-ldba(i)\y0)
AddPathLine(ldba(i)\x1+25,370-ldba(i)\y1)
CustomDashPath(LThick, dashes())
EndIf
Next
ResetPath()
ResetCoordinates()
EndProcedure
;***********************
Procedure myBar()
ResetPath()
ResetCoordinates()
If Scaleh > Scalev
ScaleCoordinates(Scalev,Scalev)
Else
ScaleCoordinates(Scaleh,Scaleh)
EndIf
For i = 0 To itemb - 1
If bdba(i)\st = 1 And bdba(i)\vw = 1
VectorSourceColor(bdba(i)\bcolor)
MovePathCursor(bdba(i)\x0+25 , 370 - bdba(i)\y0)
AddPathBox(bdba(i)\x0+25 ,370-bdba(i)\y0, bWidth,-bdba(i)\y1)
FillPath()
ElseIf bdba(i)\st = 2 And bdba(i)\vw = 1
VectorSourceColor(bdba(i)\bcolor)
MovePathCursor(bdba(i)\x0+25 , 370 - bdba(i)\y0)
AddPathBox(bdba(i)\x0+25 ,370-bdba(i)\y0,bdba(i)\x1+25,-bWidth)
FillPath()
EndIf
; ElseIf Style = 3
;
; ElseIf Style = 4
;
; EndIf
Next
ResetPath()
ResetCoordinates()
EndProcedure
Procedure myResize()
ResizeImage(image,WindowWidth(0),WindowHeight(0)-35,#PB_Image_Smooth)
ResizeImage(effect,WindowWidth(0),WindowHeight(0)-35,#PB_Image_Smooth)
ResizeGadget(0,0,0,WindowWidth(0),WindowHeight(0)-30)
EndProcedure
Scaleh = 1.0
Scalev = 1.0
If OpenWindow(0, 0, 0, 600, 430, "Chart Drawing", #PB_Window_MaximizeGadget| #PB_Window_SizeGadget| #PB_Window_ScreenCentered )
eWin = OpenWindow(#PB_Any,WindowX(0)+300,WindowY(0)+100,360,500,"Data Entry",#PB_Window_Invisible,WindowID(0))
eWinw = WindowWidth(eWin)-10
eWinh = WindowHeight(eWin)
UseGadgetList(WindowID(eWin))
cont1 = ContainerGadget(#PB_Any,5,5,eWinw,180,#PB_Container_Single)
SetGadgetColor(cont1,#PB_Gadget_BackColor,$F4F4F4)
op1 = OptionGadget(#PB_Any,10,10,40,20,"Dot")
op2 = OptionGadget(#PB_Any,70,10,40,20,"Line")
op3 = OptionGadget(#PB_Any,120,10,40,20,"Bar")
op4 = OptionGadget(#PB_Any,170,10,40,20,"Float")
op5 = OptionGadget(#PB_Any,220,10,60,20,"Stacked")
op6 = OptionGadget(#PB_Any,290,10,40,20,"Pie")
SetActiveGadget(op1)
SetGadgetState(op1,1)
iimg = CanvasGadget(#PB_Any,5,30,eWinw,160)
StartVectorDrawing(CanvasVectorOutput(iimg))
AddPathBox(0,0,WindowWidth(eWin)-10,160)
VectorSourceColor($FFEFEFEF)
FillPath()
VectorSourceColor($FF000000)
MovePathCursor(0,140)
AddPathLine(eWinw-20,140)
MovePathCursor(5,40)
AddPathLine(5,150)
StrokePath(0.4)
StopVectorDrawing()
CloseGadgetList()
ContainerGadget(#PB_Any,5,200,eWinw,eWinh-195)
edg = EditorGadget(#PB_Any,0,0,eWinw,250)
co = ButtonGadget(#PB_Any,0,270,50,22,"Color")
sv = ButtonGadget(#PB_Any,50,270,60,22,"Save")
sa = ButtonGadget(#PB_Any,110,270,60,22,"Save As")
ex = ButtonGadget(#PB_Any,eWinw-35,260,35,35,"EXIT")
CloseGadgetList()
UseGadgetList(WindowID(0))
CanvasGadget(0,0,0,WindowWidth(0),WindowHeight(0))
If CreateImageMenu(0, WindowID(0))
MenuTitle("Data Entry")
MenuItem(30,"From File");,ImageID(12))
MenuItem(31,"Enter Data" );,ImageID(13))
MenuItem(32, "Included ");,ImageID(14))
MenuItem(33, "&Quit")
MenuTitle("View")
MenuItem( 1, "PB_Dot",ImageID(chart1))
MenuItem( 2, "PB_Line",ImageID(chart2))
MenuItem( 3, "PB_Bar",ImageID(chart3))
MenuItem( 4, "PB_Pie",ImageID(chart4))
MenuTitle("Tools")
MenuItem(40, "Change Data");,ImageID(12))
MenuItem(41, "New File");,ImageID(12))
MenuItem(42, "Edit File");,ImageID(12))
MenuItem(43, "Add Legend");,ImageID(12))
MenuItem(44, "Edit Title");,ImageID(12))
MenuTitle("Save As")
MenuItem( 50, "JPG");,ImageID(12))
MenuItem( 51, "PNG");,ImageID(13))
MenuItem( 52, "BMP");,ImageID(14))
MenuTitle("Print")
MenuItem( 60, "Color");,ImageID(13))
MenuItem( 61, "Draft");,ImageID(12))
; MenuItem( 32, "2D Pie",ImageID(14))
MenuTitle("?")
MenuItem(9, "About")
EndIf
orgw = WindowWidth(0)
orgh = WindowHeight(0)
SetActiveWindow(0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case op1
StartVectorDrawing(CanvasVectorOutput(iimg))
AddPathBox(15,6,eWinw,130)
VectorSourceColor($FFEFEFEF)
FillPath()
VectorSourceColor($FF070DFE)
AddPathCircle(80,60,5)
FillPath()
VectorSourceColor($FFFB0A29)
AddPathCircle(90,90,5)
FillPath()
VectorSourceColor($FFF6FC09)
AddPathCircle(50,70,5)
FillPath()
VectorFont(FontID(0), 10)
VectorSourceColor($FF121BFF)
MovePathCursor(15,6)
DrawVectorText("PB_DOT")
MovePathCursor(15,18)
DrawVectorText("Radius,No.of Dots")
MovePathCursor(15,30)
DrawVectorText("Style,Visablity,x,y")
StopVectorDrawing()
Case op2
StartVectorDrawing(CanvasVectorOutput(iimg))
AddPathBox(15,6,eWinw,130)
VectorSourceColor($FFEFEFEF)
FillPath()
VectorSourceColor($FF0710FE)
MovePathCursor(20,70)
AddPathLine(50,-10,#PB_Path_Relative)
AddPathLine(80,55,#PB_Path_Relative)
AddPathLine(90,-20,#PB_Path_Relative)
StrokePath(0.2)
VectorFont(FontID(0), 10)
VectorSourceColor($FF121BFF)
MovePathCursor(15,6)
DrawVectorText("PB_LINE")
MovePathCursor(15,18)
DrawVectorText("Radius,No.of Dots")
MovePathCursor(15,30)
DrawVectorText("Style,Visablity,x,y")
StopVectorDrawing()
Case op3
StartVectorDrawing(CanvasVectorOutput(iimg))
AddPathBox(15,6,eWinw,130)
VectorSourceColor($FFEFEFEF)
FillPath()
VectorSourceColor($FF0610FE)
AddPathBox(60,60,10,50)
FillPath()
AddPathBox(70,60,10,50)
VectorSourceColor($FF1DFD00)
FillPath()
AddPathBox(80,70,10,40)
VectorSourceColor($FF01D0FB)
FillPath()
VectorFont(FontID(0), 10)
VectorSourceColor($FF121BFF)
MovePathCursor(15,6)
DrawVectorText("PB_BAR")
MovePathCursor(15,18)
DrawVectorText("Radius,No.of Dots")
MovePathCursor(15,30)
DrawVectorText("Style,Visablity,x,y")
StopVectorDrawing()
Case op4
StartVectorDrawing(CanvasVectorOutput(iimg))
AddPathBox(15,6,eWinw,130)
VectorSourceColor($FFEFEFEF)
FillPath()
VectorSourceColor($FF0610FE)
AddPathBox(30,70,180,10)
FillPath()
VectorSourceColor($FF05B5FE)
AddPathBox(50,85,100,10)
FillPath()
VectorSourceColor($FF23FB08)
AddPathBox(40,100,180,10)
FillPath()
VectorFont(FontID(0), 10)
VectorSourceColor($FF121BFF)
MovePathCursor(15,6)
DrawVectorText("PB_BAR")
MovePathCursor(15,18)
DrawVectorText("Radius,No.of Dots")
MovePathCursor(15,30)
DrawVectorText("Style,Visablity,x,y")
StopVectorDrawing()
Case op4
StartVectorDrawing(CanvasVectorOutput(iimg))
AddPathBox(15,6,eWinw,130)
VectorSourceColor($FFEFEFEF)
FillPath()
VectorSourceColor($FF05B5FE)
AddPathBox(30,120,80,10)
FillPath()
VectorSourceColor($FF23FB08)
AddPathBox(80,120,50,10)
FillPath()
VectorFont(FontID(0), 10)
VectorSourceColor($FF121BFF)
MovePathCursor(15,6)
DrawVectorText("PB_BAR")
MovePathCursor(15,18)
DrawVectorText("Radius,No.of Dots")
MovePathCursor(15,30)
DrawVectorText("Style,Visablity,x,y")
StopVectorDrawing()
Case op5
StartVectorDrawing(CanvasVectorOutput(iimg))
AddPathBox(15,6,eWinw,130)
VectorSourceColor($FFEFEFEF)
FillPath()
VectorSourceColor($FF0324FE)
AddPathBox(30,85,160,10)
FillPath()
VectorSourceColor($FF04E1FD)
AddPathBox(160,85,80,10)
FillPath()
VectorFont(FontID(0), 10)
VectorSourceColor($FF121BFF)
MovePathCursor(15,6)
DrawVectorText("PB_BAR")
MovePathCursor(15,18)
DrawVectorText("Radius,No.of Dots")
MovePathCursor(15,30)
DrawVectorText("Style,Visablity,x,y")
StopVectorDrawing()
Case op6
StartVectorDrawing(CanvasVectorOutput(iimg))
AddPathBox(15,6,eWinw,130)
VectorSourceColor($FFEFEFEF)
FillPath()
VectorSourceColor($FF04E1FD)
MovePathCursor(50,80)
AddPathCircle(50,80,30,0,60,#PB_Path_Connected)
MovePathCursor(150,80)
AddPathEllipse(150,80,40,30,0,60,#PB_Path_Connected)
FillPath()
VectorSourceColor($FF010AFE)
MovePathCursor(50,80)
AddPathCircle(50,80,30,60,90,#PB_Path_Connected)
MovePathCursor(150,80)
AddPathEllipse(150,80,40,30,60,90,#PB_Path_Connected)
FillPath()
VectorSourceColor($FF1DFD01)
MovePathCursor(50,80)
AddPathCircle(50,80,30,90,170,#PB_Path_Connected)
MovePathCursor(150,80)
AddPathEllipse(150,80,40,30,90,180,#PB_Path_Connected)
FillPath()
VectorSourceColor($FFFC1F03)
MovePathCursor(50,80)
AddPathCircle(50,80,30,170,360,#PB_Path_Connected)
MovePathCursor(150,80)
AddPathEllipse(150,80,40,30,170,360,#PB_Path_Connected)
FillPath()
VectorFont(FontID(0), 10)
VectorSourceColor($FF121BFF)
MovePathCursor(15,6)
DrawVectorText("PB_PIE")
MovePathCursor(15,18)
DrawVectorText("Radius,No.of Dots")
MovePathCursor(15,30)
DrawVectorText("Style,Visablity,x,y")
StopVectorDrawing()
Case sv
If File$
OpenFile(0,File$)
FileSeek(0, 0)
For r = 0 To CountGadgetItems(edg)-1
Result$ = GetGadgetItemText(edg,r)
WriteStringN(0,Result$)
Next
EndIf
If IsFile(0)
CloseFile(0)
EndIf
HideWindow(ewin,1)
ReadFile(0,File$)
While Eof(0) = 0
Text$ = ReadString(0)
If Text$ = "PB_DOT"
Text$ = ReadString(0)
Dthick = Val(StringField(Text$,1,","))
itemd = Val(StringField(Text$,2,","))
For item = 0 To itemd -1
Text$ = ReadString(0)
ddba(item)\st = Val(StringField(Text$, 1, ","))
ddba(item)\vw = Val(StringField(Text$, 2, ","))
ddba(item)\x0 = Val(StringField(Text$, 3, ","))
ddba(item)\y0 = Val(StringField(Text$, 4, ","))
ddba(item)\DColor = Val(StringField(Text$, 5, ","))
Next
ElseIf Text$ = "PB_LINE"
Text$ = ReadString(0)
Lthick = Val(StringField(Text$,1,","))/10
iteml = Val(StringField(Text$,2,","))
For item = 0 To iteml -1
Text$ = ReadString(0)
ldba(item)\st = Val(StringField(Text$, 1, ","))
ldba(item)\vw = Val(StringField(Text$, 2, ","))
ldba(item)\x0 = Val(StringField(Text$, 3, ","))
ldba(item)\y0 = Val(StringField(Text$, 4, ","))
ldba(item)\x1 = Val(StringField(Text$, 5, ","))
ldba(item)\y1 = Val(StringField(Text$, 6, ","))
ldba(item)\LColor = Val(StringField(Text$, 7, ","))
Next
ElseIf Text$ = "PB_BAR"
Text$ = ReadString(0)
bWidth = Val(StringField(Text$,1,","))
itemb = Val(StringField(Text$,2,","))
For item = 0 To itemb -1
Text$ = ReadString(0)
bdba(item)\st = Val(StringField(Text$, 1, ","))
bdba(item)\vw = Val(StringField(Text$, 2, ","))
bdba(item)\x0 = Val(StringField(Text$, 3, ","))
bdba(item)\y0 = Val(StringField(Text$, 4, ","))
bdba(item)\x1 = Val(StringField(Text$, 5, ","))
bdba(item)\y1 = Val(StringField(Text$, 6, ","))
bdba(item)\BColor = Val(StringField(Text$, 7, ","))
bdba(item)\x2 = Val(StringField(Text$, 8, ","))
bdba(item)\y2 = Val(StringField(Text$, 8, ","))
bdba(item)\BColor2 = Val(StringField(Text$, 10, ","))
Next
ElseIf Text$ = "PB_PIE"
EndIf
Wend
PostEvent(#PB_Event_SizeWindow,0,0)
Case sa
File$ = SaveFileRequester("Please choose file to save", GetHomeDirectory()+"PB_Chart.pbd", GetHomeDirectory()+"*.pbd", 0)
If File$
OpenFile(0,File$)
FileSeek(0, 0)
For r = 0 To CountGadgetItems(edg)-1
Result$ = GetGadgetItemText(edg,r)
WriteStringN(0,Result$)
Next
EndIf
If IsFile(0)
CloseFile(0)
EndIf
Case ex
HideWindow(ewin,1)
EndSelect
If GetGadgetState(op1) = 1 Or GetGadgetState(op6) = 1
DisableGadget(irx,0)
DisableGadget(irxd,0)
DisableGadget(iry,0)
DisableGadget(iryd,0)
Else
DisableGadget(irx,1)
DisableGadget(irxd,1)
DisableGadget(iry,1)
DisableGadget(iryd,1)
EndIf
Case #PB_Event_Menu
Select EventMenu()
Case 1 To 16
If GetMenuItemState(0,EventMenu()) = 1
SetMenuItemState(0,EventMenu(),0)
Else
SetMenuItemState(0,EventMenu(),1)
EndIf
Case 30
File$ = OpenFileRequester("Please choose file to load", GetHomeDirectory(), "*.pbd", 0)
If FileSize(File$) > 0
ReadFile(0,File$)
While Eof(0) = 0
Text$ = ReadString(0)
If Text$ = "PB_DOT"
Text$ = ReadString(0)
Dthick = Val(StringField(Text$,1,","))
itemd = Val(StringField(Text$,2,","))
For item = 0 To itemd -1
ReDim ddba.DotData(item)
Text$ = ReadString(0)
ddba(item)\st = Val(StringField(Text$, 1, ","))
ddba(item)\vw = Val(StringField(Text$, 2, ","))
ddba(item)\x0 = Val(StringField(Text$, 3, ","))
ddba(item)\y0 = Val(StringField(Text$, 4, ","))
ddba(item)\DColor = Val(StringField(Text$, 5, ","))
Next
ElseIf Text$ = "PB_LINE"
Text$ = ReadString(0)
Lthick = Val(StringField(Text$,1,","))/10
iteml = Val(StringField(Text$,2,","))
For item = 0 To iteml -1
ReDim ldba.LineData(item)
Text$ = ReadString(0)
ldba(item)\st = Val(StringField(Text$, 1, ","))
ldba(item)\vw = Val(StringField(Text$, 2, ","))
ldba(item)\x0 = Val(StringField(Text$, 3, ","))
ldba(item)\y0 = Val(StringField(Text$, 4, ","))
ldba(item)\x1 = Val(StringField(Text$, 5, ","))
ldba(item)\y1 = Val(StringField(Text$, 6, ","))
ldba(item)\LColor = Val(StringField(Text$, 7, ","))
Next
ElseIf Text$ = "PB_BAR"
Text$ = ReadString(0)
bWidth = Val(StringField(Text$,1,","))
itemb = Val(StringField(Text$,2,","))
For item = 0 To itemb -1
ReDim bdba.BarData(item)
Text$ = ReadString(0)
bdba(item)\st = Val(StringField(Text$, 1, ","))
bdba(item)\vw = Val(StringField(Text$, 2, ","))
bdba(item)\x0 = Val(StringField(Text$, 3, ","))
bdba(item)\y0 = Val(StringField(Text$, 4, ","))
bdba(item)\x1 = Val(StringField(Text$, 5, ","))
bdba(item)\y1 = Val(StringField(Text$, 6, ","))
bdba(item)\BColor = Val(StringField(Text$, 7, ","))
bdba(item)\x2 = Val(StringField(Text$, 8, ","))
bdba(item)\y2 = Val(StringField(Text$, 8, ","))
bdba(item)\BColor2 = Val(StringField(Text$, 10, ","))
Next
ElseIf Text$ = "PB_PIE"
EndIf
Wend
EndIf
If IsFile(0)
CloseFile(0)
EndIf
Case 31,41
HideWindow(eWin,0)
Case 33
Quit = 1
Case 40
HideWindow(eWin,0)
DisableGadget(sa,1)
DisableGadget(sv,0)
ClearGadgetItems(edg)
ReadFile(0,File$)
While Eof(0) = 0
Text$ = ReadString(0)
AddGadgetItem(edg,-1,Text$)
Wend
If IsFile(0)
CloseFile(0)
EndIf
Case 42
HideWindow(eWin,0)
DisableGadget(sa,0)
DisableGadget(sv,1)
File$ = OpenFileRequester("Please choose file to load", GetHomeDirectory(), "*.pbd", 0)
If FileSize(File$) > 0
ReadFile(0,File$)
FileSeek(0, 0)
While Eof(0) = 0
Text$ = ReadString(0)
AddGadgetItem(edg,-1,Text$)
Wend
If IsFile(0)
CloseFile(0)
EndIf
EndIf
Case 50
ImgId = GetGadgetAttribute(0, #PB_Canvas_Image)
CreateImage(20, GadgetWidth(0), GadgetHeight(0))
StartDrawing(ImageOutput(20))
DrawImage(ImgId,0,0)
StopDrawing()
SaveImage(20, GetHomeDirectory()+"PB_Chart.jpg", #PB_ImagePlugin_JPEG)
Case 51
ImgId = GetGadgetAttribute(0, #PB_Canvas_Image)
CreateImage(10, GadgetWidth(0), GadgetHeight(0))
StartDrawing(ImageOutput(10))
DrawImage(ImgId,0,0)
StopDrawing()
;*Buffer = EncodeImage(10,#PB_ImagePlugin_PNG,4|#PB_Image_FloydSteinberg)
;CatchImage(20,*Buffer)
SaveImage(10,GetHomeDirectory()+ "PB_Chart.png", #PB_ImagePlugin_PNG)
Case 52
ImgId = GetGadgetAttribute(0, #PB_Canvas_Image)
CreateImage(20, GadgetWidth(0), GadgetHeight(0))
StartDrawing(ImageOutput(20))
DrawImage(ImgId,0,0)
StopDrawing()
SaveImage(20,GetHomeDirectory()+ "PB_Chart.bmp" )
;Case 24
EndSelect
PostEvent(#PB_Event_SizeWindow,0,0)
Case #PB_Event_SizeWindow
Scaleh = WindowWidth(0)/orgw
Scalev = WindowHeight(0)/orgh
myResize()
StartVectorDrawing(CanvasVectorOutput(0))
myBKG(0,200,2,200) ;bkground(image,ialpha,effect,ealpha)
myAxis()
myTitle("RASHAD",30,25,$FF0000FF)
If GetMenuItemState(0,3) = 1
myBar()
EndIf
; If GetMenuItemState(0,4) = 1
; myPie()
; EndIf
If GetMenuItemState(0,2) = 1
myLine()
EndIf
If GetMenuItemState(0,1) = 1
myDot()
EndIf
StopVectorDrawing()
EndSelect
Until Quit = 1
EndIf
DataSection
AxisData:
Data.i 3163196042,25,15925727,25,15664900 ;Grid Color , x Step , x Text Color , y Step ,y Text Color
EndDataSection
Egypt my love