I would like to make an application same to this in video, could you please tell me how to code it step by step
Thank you in advance
If all you need is rectangular coloring, you can draw a fat line.
Change your line width and color as you go.
Flood fill algorithms are complex and slow in comparison.
Here a flood fill extension in Canvas.
If you want an example of representation of a grid based puzzle, see
For your puzzle, you would assign numbers 1-6 for your colors and represent each puzzle as a 9 by 9 table (list of lists) of color numbers both as a target state and as a current board state.
You could keep a list of your 6 color buttons to match them against your list of colors by index.