Yes, all is reset.
Set scaling after setting virtual.
Once I put a canvas into virtual mode with Canvas_SetVirtual(), it appears that Canvas_Scale() has no effect - everything is always plotted 1:1 in the virtual canvas, no matter what I set the scale to.
Is that by design? Is there any way to combine custom coordinate systems on a canvas with virtual mode?
*Brian
Yes, all is reset.
Set scaling after setting virtual.
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
I see.
There's no easy way to take a canvas with a bunch of lines drawn on it at one set of coordinates (say (0,0), (1000,500)) and then change the scaling (say to (0,0),(10,50)), and have all of the graphics on the canvas follow the scaling change, is there?
Here's what I'm really after, big picture. I've collected a lot of data points in a set of arrays. Let's say 100000 points. I can set up a virtual canvas that's 100000 pixels wide, and then draw my set of lines on the canvas. My viewport is only 1000 pixels wide, so the user can then scroll around the graph as much as they want, and it's lightning fast. It's really awesome.
However, I'm trying to implement horizontal scaling. I have two buttons that allow you to zoom in and zoom out, so that you can change how many points of data are displayed per pixel in the viewport. This lets you see much more of the graph at once.
But it's _so_ slow to completely redraw the whole canvas every time they change the horizontal scaling factor.
What I'd rather do is draw the whole graph, once, to the virtual canvas, and then re-scale the virtual canvas to compress or expand the image visible through the viewport.
Right now, it appears that when you set Canvas_Scale(), it applies to all graphic elements that you draw after that point, but it does not do anything to the existing canvas.
Can you think of any way I can do my 'rapid scaling'?
*Brian
Scaling is just a way to create a new coordinates system.
What you mean is a kind of zooming,
I suppose it can be done capturing your canvas into a bitmap, stretching the bitmap, changing the scale and then putting the stretched bitmap back to the canvas.
But this is just theory, I need to put together an example and see how it works.
Do not know if I will have time this week. Maybe next week-end
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Eros,
Nah, don't worry about it. If there isn't an easy way built into TB, it's not worth spending time on concocting a complex example. It's just a way to make something that's working properly now, work faster. That's all.
Thanks, as always for the awesome language. :-)
*Brian
hmmm anyway worth to investigate.
I will let your know if I will get something
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
I love Canvas and I use it for lot of monitoring gfx at AVG/Avast, but I would recommend you to take a peek at TBGL for this kinds of advanced wizardry, if I may
Let me know, if this is something interesting for you - I will be glad to give you hand when needed.
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Petr,
Yeah, I figured you'd say that. :-) And of course you're absolutely right - TBGL is clearly the way to get the best performance. My only reason for not diving into TBGL and learning how to use it for this application is time. Canvas is simpler and I already know it, where as TBGL will need time spent learning how to use it right.
*Brian
Brian,
I don't want to push you - but if you can paste here your rendering code for the data plot, I will convert it for you to TBGL.
I am pretty sure you will find it very canvasish
Not speaking of memory consumption. Let's presume your virtual canvas is 10 000 * 1 000. That means 10 000 000 pixels * 4 bytes per each = 40 MB in memory.
In TBGL it is all vector data + framebuffer.
Petr
Last edited by Petr Schreiber; 28-06-2017 at 23:00.
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Hi Petr
this is a very interesting subject, the subject of very wide graphics.
here is a wide plotting with a horizontal scroll bar, when the scroll bar reach the far right we can continue to scroll with right arrow keys if the canvas in focus.
i see your TBGL example here http://www.thinbasic.com/community/s...ll=1#post72282 may be it is a candidate, not sure, seems even we can move the Form with the mouse while plotting continue as if it is not affected, Eros may add this example to the official examples. but how we scroll to the right and allow continuous viewing of the heart pulses until 100000 on x. also is it possible with the same animated feature like in the hospital .Uses "UI" Dim x,y As Double Begin ControlID %ID_Canvas End ControlID Function TBMain() As Long Local hDlg As DWord '---Used to store window handle of main dialog hDlg = Dialog_New Pixels, 0, "very wide graphics ", -1, -1, 1200, 775, %WS_DLGFRAME | %DS_CENTER | %WS_CAPTION | %WS_SYSMENU | %WS_OVERLAPPEDWINDOW Dialog Show Modal hDlg, Call cbDialog End Function CallBack Function cbDialog() As Long Select Case CBMSG Case %WM_INITDIALOG Control Add Canvas, CBHNDL, %ID_Canvas, "", 50, 10,1000, 400, %WS_BORDER | %WS_CHILD | %WS_VISIBLE Canvas_Attach(CBHNDL, %ID_Canvas, %FALSE) Canvas_SetVirtual(100000, 380) Canvas_SetView(0,0) Canvas_Width(2) Canvas_Clear %BLACK Canvas_SetView(10000,0) 'Canvas_Scale(-20, -5, 20, 20) For x = 0 To 20000 Step 0.1 y = Sin(x)*20* Rndf(1, 2)*Cos(x/3)^2 Canvas_Width(3) Canvas_Line( (x*10, y +100), (x*10, y +100) , Rgb(255, 255, 0) ) Canvas_Redraw Next End Select End Function
i never thought before about wide canvas, so thanks for EmbeddedMan for casting light on this issue.
Bookmarks