B4X Booklets
B4X Graphics
Copyright: © 2022 Anywhere Software Edition 2.4
Last update: 2022.08.15
Table of content 2 B4X Graphics
1 B4X platforms .............................................................................................................................. 5
2 Graphics / Drawing ...................................................................................................................... 6
2.1 Overview .............................................................................................................................. 6
2.2 Tip ........................................................................................................................................ 6
2.3 Canvas object ....................................................................................................................... 6
2.3.1 Canvas initialization ......................................................................................................... 7
2.3.1.1 XUI ........................................................................................................................... 7
2.3.1.2 BC BitmapCreator .................................................................................................... 7
2.3.1.3 B4A .......................................................................................................................... 7
2.3.1.4 B4i ............................................................................................................................ 7
2.3.1.5 B4J ........................................................................................................................... 7
2.3.2 Invalidation for B4A and XUI / Refresh for B4i ........................................................... 8
2.3.2.1 XUI ........................................................................................................................... 8
2.3.2.2 B4A .......................................................................................................................... 8
2.3.2.3 B4i ............................................................................................................................ 9
2.3.2.4 B4J ........................................................................................................................... 9
2.4 Drawing methods ............................................................................................................... 10
2.4.1 XUI Drawing methods ................................................................................................... 11
2.4.2 B4A Drawing methods .................................................................................................. 13
2.4.3 B4i Drawing methods ................................................................................................... 16
2.4.4 B4J Drawing methods ................................................................................................... 18
2.5 BitmapCreator .................................................................................................................... 20
2.5.1 BC Drawing methods (BC = BitmapCreator) ................................................................ 22
2.5.2 BC Other methods or objects ......................................................................................... 25
2.5.3 BC Asynchronus Drawing methods ............................................................................... 26
2.5.4 BCBrush BitmapCreator brush .................................................................................... 27
2.5.5 BCPath BitmapCreator path ......................................................................................... 28
2.6 BitmapCreatorEffects b4xlib ............................................................................................ 29
2.7 Drawing program First steps .............................................................................................. 30
2.7.1 Initialization B4XMainPage module ............................................................................ 32
2.7.2 Initialization GraphicsFirstSteps module ...................................................................... 32
2.7.3 Draw a line ..................................................................................................................... 33
2.7.4 Draw a rectangle ............................................................................................................ 33
2.7.5 Draw a circle .................................................................................................................. 34
2.7.6 Draw a text ..................................................................................................................... 35
2.8 Drawing program SimpleDrawMethods ........................................................................... 36
2.9 BitmapCreator Example programs ..................................................................................... 41
2.9.1 BitmapCreatorDemo1 .................................................................................................... 42
2.9.1.1 Remove green......................................................................................................... 43
2.9.2 BitmapCreatorDemo2 .................................................................................................... 44
2.9.2.1 Drawing with B4XCanvas ..................................................................................... 45
2.9.2.2 Drawing with BitmapCreator methods .................................................................. 47
3 Graphs ........................................................................................................................................ 48
3.1 Definition of the Graph variables ....................................................................................... 50
3.2 Definition of the Grid variables ......................................................................................... 50
3.3 Source code ........................................................................................................................ 50
3.3.1 Platform specific code .................................................................................................... 51
3.3.2 Common code B4XMainPage module.......................................................................... 51
3.3.2.1 B4X objects declararions ....................................................................................... 51
3.3.2.2 Common variables ................................................................................................. 52
3.3.2.3 ClearGraph ............................................................................................................. 53
3.3.2.4 InitGraph ................................................................................................................ 53
3.3.2.5 InitGrid ................................................................................................................... 54