How to add gradient to canvas

When I tried to draw without a canvas in JavaScript, I tried to create a gradient on that "canvas". The 10x10 canvas I created used table cells as pixels. For this I had to calculate the color of each cell when trying to make a gradient. And now I implemented it in App Inventor.
Method i'm using:

It simply calculates the gradient color for every 5 px. For demonstration i created simple project.
gradient.aia (5.6 KB)

1 Like

sorry, mis-read

I have no idea what you apologize for, but it's ok

He asked whether the Pixel and BackgroundPixel blocks work the same or not. After that, he saw that he misread slightly, that's why.

Thanks for info.

1 Like

2 posts were split to a new topic: ColorPickerDialog Kodular

how to get multiple custom colors with extension of ColorPicker by Zhangzqs?

gradient (1).aia (24.9 KB)
Try this

1 Like

Exactly what I needed, Thank you so much

You're welcome.

1 Like

Another method to fill rectangle on canvas with gradient. Only 2 colors and very slow.

CanvasGradient.aia (6.2 KB)

And here is another method using a very little extension and much faster.

TestExtension.aia (83.2 KB)

NSDGradient.aix (7.6 KB)