Cableguy Expert Licensed User Longtime User Mar 8, 2016 #1 Hi guys... As noob as this could be, I just can't put my head around the B4J canvas usage... I use a lot of canvas in B4A, but the B4J version is somewhat different and I just can't get it to work... I'm trying to do such a basic thing as drawing a line onto a canvas... In B4A, canvas is just a place holder that takes the background of a view and copies it allowing to draw over this background, then returning it to the targeted view. In B4J all I can understand is that a canvas is a node on its own... I'm lost, not even the examples have helped me. So I ask... Please... I need the most basic example of drawing a line in a canvas in B4J
Hi guys... As noob as this could be, I just can't put my head around the B4J canvas usage... I use a lot of canvas in B4A, but the B4J version is somewhat different and I just can't get it to work... I'm trying to do such a basic thing as drawing a line onto a canvas... In B4A, canvas is just a place holder that takes the background of a view and copies it allowing to draw over this background, then returning it to the targeted view. In B4J all I can understand is that a canvas is a node on its own... I'm lost, not even the examples have helped me. So I ask... Please... I need the most basic example of drawing a line in a canvas in B4J
R Roycefer Well-Known Member Licensed User Longtime User Mar 8, 2016 #2 Code: Dim CVS As Canvas 'assume CVS is added with the Designer, otherwise, initialize it and add it to the Form CVS.DrawLine(0,0,100,100, fx.Colors.Red, 10) In many ways, this is much simpler than the B4A equivalent where you have to add it to a Panel and then Invalidate() the Panel to see your drawings updated. Upvote 0
Code: Dim CVS As Canvas 'assume CVS is added with the Designer, otherwise, initialize it and add it to the Form CVS.DrawLine(0,0,100,100, fx.Colors.Red, 10) In many ways, this is much simpler than the B4A equivalent where you have to add it to a Panel and then Invalidate() the Panel to see your drawings updated.
I inakigarm Well-Known Member Licensed User Longtime User Mar 8, 2016 #3 Have you seen this example ?? https://www.b4x.com/android/forum/threads/moving-smiley-example.34610/ Upvote 0
Cableguy Expert Licensed User Longtime User Mar 8, 2016 #4 I must be doing something wrong!!! I have tried that exact same approach but nothing had happened! I added my canvas by code, initialised it, and added it to a suitable parent, but nothing showed! I will take a better look into it. thanks @Roycefer Upvote 0
I must be doing something wrong!!! I have tried that exact same approach but nothing had happened! I added my canvas by code, initialised it, and added it to a suitable parent, but nothing showed! I will take a better look into it. thanks @Roycefer
Daestrum Expert Licensed User Longtime User Mar 8, 2016 #5 Did you give it a size when you added it, I seem to remember using -1,-1 gives a size of 0 x 0. Upvote 0
Cableguy Expert Licensed User Longtime User Mar 8, 2016 #6 I did... and weird enough, I just did a few try-outs using the examples, and I got it working... I thing it had something to do with some relative calculations... but even when I added absolute values, it didn't show Upvote 0
I did... and weird enough, I just did a few try-outs using the examples, and I got it working... I thing it had something to do with some relative calculations... but even when I added absolute values, it didn't show