Crowd drawing app

After getting frustrated on some aspects of integrating my static site with Anvil forms, I needed to clear my head to reset. I took a page from @david.wylie and wrote a totally unrelated Anvil app just for fun.

This is a crowd drawing app. When it comes up, you’ll see a small canvas, and one of the squares on the canvas will be blinking. There’s a timer at the top that tells you how long you have to select a color for the square. At the end of the timer the aggregate color from everyone who voted for a color gets put into that square. The more people who vote for red, for example, the higher the red value is.

The closer to 0 the timer is when you make your color selection, the greater the likelihood that your vote will go for the next square, since Anvil server calls aren’t instant.

Colors will tend to be darker when there aren’t at least 5 people voting, and will get brighter with 5 or more people voting.

New drawings start at the top of the hour, and take about 50 minutes to complete. Eventually I’d like to add a way to browse older drawings, but it served its purpose to be a fun technical challenge and clear my mind.

I learned through this that Anvil app tables calls that return no rows still take time (625 such calls eats up a lot of time!), which was a helpful reminder for optimizing my other apps. I’d been getting lazy due to how easy it is in Anvil to query data tables.

I also learned the value of not returning empty information from the server to the client. At one point I’d been generating squares without votes on the server and passing them back to the client, rather than just allowing the client to deal with those missing squares on its own.

I also totally sidestepped the issue of time synchronization between client and server, just relying on the local clocks on both. Vote times are set on the server, so even if a client changes its clock to the past it won’t affect previous squares or drawings.

3 Likes

What a cool idea!

This one’s definitely a work of Abstract Expressionism. I’m proud to have contributed to the green and red blobs at the bottom.

image

Yeah, that slightly brighter red in the middle was me testing the averaging by voting from two different browser windows. I expect most of the drawings will to end up pretty abstract, even with a lot of people voting.

It’s an odd mix of time pressure and patience to choose colors for every square in the drawing.