Undo/Redo Stacks & Flood Fill

Your file still says .txt. You will need to change the format back to svg.

It seems you're using a legacy version of my extension. Since creating that extension, I've created an even more powerful one called Canvas Layer: [FREE] CanvasLayers - a layer editor for Canvas


You absolutely must complete this initial setup.

Ty. Can you explain the purpose of the Vertical Scroll Arrangement, and how to get it to not interfere with the Pinwheel? (pic1) I tried to use the same settings that you had in your original aia, but I am sure I am missing something.

In your origianl aia (pic2), I added my Pinwheel as the Background Image on the Canvas, and it filled the entire canvas with no problem. So, I am not sure what I am doing wrong with the 1st pic.

UPDATE: I just realized that you made it invisible. So, I am ok with that question now.

Can you still explain the purpose of the Vertical Scroll Arrangement?


I used the Upload ImagePicker to upload the Pinwheel block, and it did fill the areas instead of the entire Canvas, but it still did not fill where I clicked, and it only filled the left side, because the right side houses the invisible Vertical Scroll Arrangement. So, I am a bit confused as to what to do next. I did want my Pinwheel to be a default Background Image in the app, and then, as a bonus, allow users to upload other quilt designs from their phone.

I really love the Scanline Flood Fill. The undo/redo are very clean. Is it possible to somehow use that Flood fill in the original Extended Canvas extension?

You need to be careful to select the layer you want to paint on. Your drawing is probably on one layer, and you painted on another. There's a command you can use to activate the layer you want to paint on, but before doing so, check which layer you're currently on.

Undo - Redo 3

No extensions required!

Here is a third iteration which overcomes most, if not all, artifacts that could be generating by drawing, undoing and redoing.

It uses two lists, the first is a list of all the pointlists for each polygon that can be drawn. The second is a list of undrawn "touch" circles that fit inside each of the polygon. These two lists have the same number of items, therefore their indexes match. The touch circles list could be generated by formula.

The user touches a polygon area on the canvas, if they touch anywhere inside the undrawn circle for that polygon, the polygon is drawn, filled and outlined with the set colour.

There is a formula in a procedure that checks if the "touch" is inside any of the undrawn circles. If true, then the respective polygon is selected.

The background quilt pattern image is displayed in the vertical arrangement which holds the canvas, so remains untouched by any drawing, undoing or redoing. The canvas has an empty background. The VA and the canvas have the same dimensions. These are set to 340 x 340 pixels. LineWidth is set to 1.0. An outline for each polygon is also drawn, to maintain the pattern layout.

AIA

floodUndo3.aia (18.3 KB)

BLOCKS

The downside of this approach, whilst good for drawing, undoing and redoing, is the need to generate the two lists for each quilt pattern, matching the canvas sizing.

1 Like

Ty for this aia. Does this mean that the user will not be allowed to import other Quilt Designs from their phone? That option is a big part of this app. There are over 1,000 traditional quilt designs in the history of quilting.

Is it possible to revisit your very first aia? Even though it was locking up, the undo/redo was very clean, similar to how clean Passos Scanline Flood Fill is. Also, I think your 1st method allowed user to import designs from their phone.

I remember reading about timing the undo/redo's, so that the phone's resources can catch up. Could that be a possible solution to your 1st method?

Note: I am still not able to figure out Passos newer extension, Canvas Layers. I don't see anything when I click SelectLayer, and I am still not clear as to the purpose of the Vertical Scrolling Arrangement.

At this point, I am using ABG's method, where the last redo will not generate. I feel like we are so close with all 3 methods.

They can, but would need, as a minimum to provide the polygons list for the design with the correct values to match the canvas size. As I said, it is possible to calculate the circle sizes and locations from the polygon x,y values. As you will have seen, my undo/redo method will work with any drawing method.

You are welcome to.

Only for you, no lockups here.

probably not necessary for the methods I have provided (probably the same for @ABG 's methods)

This issue is in your blocks. If you shared your entire aia project, @ABG may take a look and fix it.

You could help by sharing your svg file (just add a .txt to the filename) to upload here. We can then see if polygons are available for programming.

Maybe @Passos_0213 can provide an example floodfill project based on your pattern template?

1 Like

I sent Passos my aia using the Canvas Layers extension. Hopefully, he will be able to help me.

1 Like

Template Flood Fill with Canvas Layer Extension

FloodFillDemo.aia (78.1 KB)

With the same extension you can create Undo and Redo.

@Passos_0213

Not sure if that helps the OP.

Could you provide an example for floodfill of a background image, as provided by the OP here

I was hoping for an example where the User fills the background image, and then clicks to remove the Outlines, leaving the colored filled areas only.

1 Like

Which is why I have asked for such an example.

1 Like

Ok. I understood


FloodFillDemo.aia (210.6 KB)

Is there a method to clear the memory? There was in the legacy extension.

image

I have reworked/cleaned out your demo to focus on pattern filling. Works very well, no artifcats.

FloodFillDemo2.aia (217.6 KB)

1 Like

That's great! I thought I had shared the Java code here; I believe I did it in the Kodular community. I'll also post it in the App Inventor community.