Can not compile project 'FB Plot Lib ' (
-
- Posts: 2
- Joined: Mar 25, 2021 10:55
Can not compile project 'FB Plot Lib ' (
Hello all! I'm beginner here) Thats why I can ask some strange questions)
Ok. I download project Plot_Lib_source.zip from here: https://www.sites.google.com/site/freeb ... b-examples. Library 'FB_GUI_V1.20.5.zip' is used in my project too (https://www.sites.google.com/site/freeb ... -downloads). Is it correct version?.. I donnt know.
Exe-file (for windows) presents in archive too. But I cannot recompile sources to make the same exe-file (
Where is my mistake? Who can help me? What is the way for compile it?
Now I see errors (strings 178, 180 in file "FB_Plot_Lib.bas")
Thanks in advance for any answer!
Ok. I download project Plot_Lib_source.zip from here: https://www.sites.google.com/site/freeb ... b-examples. Library 'FB_GUI_V1.20.5.zip' is used in my project too (https://www.sites.google.com/site/freeb ... -downloads). Is it correct version?.. I donnt know.
Exe-file (for windows) presents in archive too. But I cannot recompile sources to make the same exe-file (
Where is my mistake? Who can help me? What is the way for compile it?
Now I see errors (strings 178, 180 in file "FB_Plot_Lib.bas")
Thanks in advance for any answer!
Re: Can not compile project 'FB Plot Lib ' (
I gave 'Plot_Lib_Test.bas' a quick try, but the code seems like a collection of bits and pieces (that you have to collect and assemble first) and it seems for Windows only, so I pass.
-
- Posts: 862
- Joined: May 05, 2015 5:35
- Location: Germany
Re: Can not compile project 'FB Plot Lib ' (
This project seems to have a lot of dependencies. The more I download the more errors I get, including "Duplicated definition". To me it seems to be quite chaotic.
-
- Posts: 2
- Joined: Mar 25, 2021 10:55
Re: Can not compile project 'FB Plot Lib ' (
Thanks all for answers!
Ok. Where can I find any project example for draw (or plot) graphic in realtime? With grids, markers...
Any project is good for me )
Thanks!
Ok. Where can I find any project example for draw (or plot) graphic in realtime? With grids, markers...
Any project is good for me )
Thanks!
Re: Can not compile project 'FB Plot Lib ' (
Not a project, only a few lines of code for roots by bisection I did some years ago.
The main theme was to get roots, only barebones graphs of functions
The main theme was to get roots, only barebones graphs of functions
Code: Select all
#include "crt.bi"
Namespace globals
Dim Shared As Integer xres,yres
Dim Shared As Double minx,maxx,miny,maxy,PLOT_GRADE=5000
Dim Shared As Double MinimumY,MaximumY
Dim Shared As Double MinimumX,MaximumX
Type fun As Function(x As Double) As Double
Dim Shared f As fun
End Namespace
Sub sketch(fn As Any Ptr,colour As Ulong,axiscolour As Ulong=Rgb(150,150,150))
Using globals
f=fn
Dim As Double last=f(minx)
For x As Double=minx To maxx Step (maxx-minx)/PLOT_GRADE
Dim As Double x1=(xres)*(x-minx)/(maxx-minx)
Dim As Double d=f(x)
Dim As Double y1=(yres)*(d-maxy)/(miny-maxy)
If Sgn(last)<> Sgn(d) Then Circle(x1,y1),2,0,,,,f
If x=minx Then Pset(x1,y1),colour Else Line -(x1,y1),colour
last=d
Next x
'axis
Dim As Long f1,f2
If Sgn(minx)<>Sgn(maxx) Then
Line(((minx/(minx-maxx))*xres),0)-(((minx/(minx-maxx))*xres),yres),(axiscolour) 'y axis
f1=1
If Sgn(minx)=0 Or Sgn(maxx)=0 Then f1=0
End If
If Sgn(miny)<>Sgn(maxy) Then
Line(0,(yres-(miny/(miny-maxy))*yres))-(xres,(yres-(miny/(miny-maxy))*yres)),(axiscolour) 'x axis
f2=1
If Sgn(miny)=0 Or Sgn(maxy)=0 Then f2=0
End If
If f2 Then
Draw String(0,(yres-(miny/(miny-maxy))*yres)),Str(minx),(axiscolour)
Draw String(xres-8-8*(Len(Str(maxx))),(yres-(miny/(miny-maxy))*yres)),Str(maxx),(axiscolour)
Else
Draw String(0,yres/2),Str(minx),(axiscolour)
Draw String(xres-8-8*(Len(Str(maxx))),yres/2),Str(maxx),(axiscolour)
End If
If f1 Then
Draw String(((minx/(minx-maxx))*xres),0),Str(maxy),(axiscolour)
Draw String(((minx/(minx-maxx))*xres),yres-16),Str(miny),(axiscolour)
Else
Draw String(xres/2,0),Str(maxy),(axiscolour)
Draw String(xres/2,yres-16),Str(miny),(axiscolour)
End If
End Sub
Sub getyrange(fn As Any Ptr,sx As Double,lx As Double,Byref by As Double,Byref sy As Double)
Using globals
f=fn
#macro _window(topleftX,topleftY,bottomrightX,bottomrightY)
minx=(topleftX)
maxx=(bottomrightX)
miny=(bottomrightY)
maxy=(topleftY)
#endmacro
MinimumY=1e50:MaximumY=-1e50
For n As Double=MinimumX To lx Step(lx-MinimumX)/10000
Dim As Double v=f(n)
If MinimumY>V Then MinimumY=v
If MaximumY<V Then MaximumY=V
Next
_window(MinimumX,MaximumY,MaximumX,MinimumY)
End Sub
Sub bisect( fn As Any Ptr,min As Double,max As Double,Byref O As Double)
Dim As globals.fun f=fn
Dim As Double last,st=(max-min)/100000,v
For n As Double=min To max Step st
v=f(n)
If Sgn(v)<>Sgn(last) Then
puts(Str(n) + " "+Str(f(n)))
O=n+st:Exit Sub
End If
last=v
Next
End Sub
Sub roots( fn As Any Ptr,min As Double,max As Double)
Using globals
Dim As fun f=fn
MinimumX=min
MaximumX=max
Dim As Double last,O,v,st=(max-min)/10000000
For n As Double=min To max Step st
v=f(n)
If Sgn(v)<>Sgn(last) And n>min Then bisect(f,n-st,n,O):n=O
last=v
Next
puts "----------------"
getyrange(f,MinimumX,MaximumX,MinimumY,MaximumY)
Screen 19,32
Color ,Rgb(255,255,255)
Screeninfo globals.xres,globals.yres
Cls
sketch(f,Rgb(0,100,255))
End Sub
Function f(x As Double) As Double
Return -x*5+4*x^4-x^3 -5*x^2-x +2
End Function
Print "root";Tab(27);"error"
puts "custom function"
roots(@f,-2,2)
puts "Press a key . . ."
Sleep
puts "sin"
roots(@sin_,-5,5)
puts "Press a key . . ."
Sleep
puts"cos"
roots(@cos_,-2,2)
puts "done"
Sleep
Re: Can not compile project 'FB Plot Lib ' (
Simple graph.
Code: Select all
'variables needed
dim as long xres,yres
dim as double minx,maxx,miny,maxy,PLOT_GRADE=5000
dim as long mx,my
dim as double pi=4*atn(1)
screen 20,32
screeninfo xres,yres
#define map(a,b,x,c,d) ((d)-(c))*((x)-(a))/((b)-(a))+(c)
#macro axis(colour)
line(0,(yres-(miny/(miny-maxy))*yres))-(xres,(yres-(miny/(miny-maxy))*yres)),(colour) 'x axis
line(((minx/(minx-maxx))*xres),0)-(((minx/(minx-maxx))*xres),yres),(colour) 'y axis
draw string(xres-8-8*(len(str(maxx))),yres\2),str(maxx),(colour)
draw string (0,yres\2),str(minx),(colour)
draw string (xres\2,0),str(maxy),(colour)
draw string (xres\2,yres-16),str(miny),(colour)
#endmacro
#macro sketch(_function,colour)
locate 2,2
print "sketch of: ";#_function
For x As Double=minx To maxx Step (maxx-minx)/PLOT_GRADE
dim as double x1=(xres)*(x-minx)/(maxx-minx)
dim as double y1=(yres)*((_function)-maxy)/(miny-maxy)
if x=minx then Pset(x1,y1),colour else line -(x1,y1),colour
Next x
#endmacro
#macro graph(fn,colour,axiscolour)
do
screenlock
cls
locate 8
print "press esc to exit"
getmouse(mx,my)
dim as single xpos=map(0,xres,mx,minx,maxx)
dim as single ypos=map(0,yres,my,maxy,miny)
locate 5
print "(";xpos;",";ypos;")"
sketch(fn,colour)
axis(axiscolour)
screenunlock
sleep 1,1
loop until inkey=chr(27)
#endmacro
minX=-2
maxX=2
minY=-2
maxY=2
graph(2*x^3-x^2-1,rgb(0,0,255),rgb(100,100,100))
color ,rgb(0,100,255)
cls
minx=-2*pi
maxx=4*pi
miny=-4
maxy=5
graph(sin(x)+cos(x)-x+x^2/7,rgb(255,255,255),rgb(200,200,0))
sleep
Re: Can not compile project 'FB Plot Lib ' (
I have no experience with it, but I would try Dislin. See: Dislin 10 (official pack for FreeBasic) and Official Dislin.Eugen_pcad_ru wrote:Ok. Where can I find any project example for draw (or plot) graphic in realtime? With grids, markers...
I did experiments with gnuplot. Using it as an external program, probably not suitable for realtime plots.
If it does not need to be fancy, then making you own plotter tool is also an option.
-
- Posts: 789
- Joined: Jul 26, 2018 18:28
Re: Can not compile project 'FB Plot Lib ' (
I offer my own Chart control:
Re: Can not compile project 'FB Plot Lib ' (
Check out GooData.Eugen_pcad_ru wrote:Ok. Where can I find any project example for draw (or plot) graphic in realtime? With grids, markers...
Re: Can not compile project 'FB Plot Lib ' (
That just tells us, that your version of FBC is outdated. In the 1.08.n versions of FBC, dodicat's code works flawlessly ...bfuller wrote:I had to change line 4Code: Select all
dim as integer xres,yres
Therefore: download/install the current FBC version 1.08.1 (for your system)
Re: Can not compile project 'FB Plot Lib ' (
Ah, yes---I am on 1.07
That is why I am on the Beginners page I suppose.
Mind you, doesn't say much for backwards compatibility---unless the old way was wrong all along I guess.
A day is not wasted if you learn something.
That is why I am on the Beginners page I suppose.
Mind you, doesn't say much for backwards compatibility---unless the old way was wrong all along I guess.
A day is not wasted if you learn something.