The first thing you'll want to do is request a blank canvas of your own. You can do this by clicking the lightning icon in Slack (
), finding the "Omnata SQL Draw Bot", and clicking the "Free Draw" action.
There are a couple of defaults we want to change for this tutorial.
First, we want width and height values of 4
, just to keep things nice and simple.
We also want a more adventurous starting colour of purple: #5b1647
Hit Submit, and a short while later you should receive your new little purple canvas.
When you requested the canvas, the Omnata SQL Draw bot created a table named bitmap_pixels
in your very own schema inside a central Postgres database. This table looks just like the one over on the right ➡
As you can see, it has 16 records; one for each coordinate on a 4x4 grid. Each has its own colour value.
The bot then rendered an image and posted it in a Slack message, it should look like this:
The bot will update the table at your command. All you need to do is reply to its message in the thread, with a SQL update statement surrounded by backticks (`
). Each time it will execute the SQL, re-render the image and update the one in Slack.
Let's give it a try!
# | x | y | colour |
---|---|---|---|
1 | 1 | 1 | #5b1647 |
2 | 1 | 2 | #5b1647 |
3 | 1 | 3 | #5b1647 |
4 | 1 | 4 | #5b1647 |
5 | 2 | 1 | #5b1647 |
6 | 2 | 2 | #5b1647 |
7 | 2 | 3 | #5b1647 |
8 | 2 | 4 | #5b1647 |
9 | 3 | 1 | #5b1647 |
10 | 3 | 2 | #5b1647 |
11 | 3 | 3 | #5b1647 |
12 | 3 | 4 | #5b1647 |
13 | 4 | 1 | #5b1647 |
14 | 4 | 2 | #5b1647 |
15 | 4 | 3 | #5b1647 |
16 | 4 | 4 | #5b1647 |
First, let's update the single pixel on the top left to a yellow colour:
```
update bitmap_pixels set colour='#ffc431' where x=1 and y=4
```
Now we see our update
statement has changed the colour value of a single record, due to the where
clause we provided.
Our helpful Slack bot re-renders the image and replaces the existing image with the new one:
Well done! You've put brush to canvas and taken your first step as a budding SQL artist. 👊
# | x | y | colour |
---|---|---|---|
1 | 1 | 1 | #5b1647 |
2 | 1 | 2 | #5b1647 |
3 | 1 | 3 | #5b1647 |
4 | 1 | 4 | #ffc431 |
5 | 2 | 1 | #5b1647 |
6 | 2 | 2 | #5b1647 |
7 | 2 | 3 | #5b1647 |
8 | 2 | 4 | #5b1647 |
9 | 3 | 1 | #5b1647 |
10 | 3 | 2 | #5b1647 |
11 | 3 | 3 | #5b1647 |
12 | 3 | 4 | #5b1647 |
13 | 4 | 1 | #5b1647 |
14 | 4 | 2 | #5b1647 |
15 | 4 | 3 | #5b1647 |
16 | 4 | 4 | #5b1647 |
Now let's update several pixels at once, and colour the whole top left quarter the same shade of yellow:
update bitmap_pixels set colour='#ffc431' where x<3 and y>2
This time, our update
statement has had a bit more impact.
When the image re-draws, we see four yellow pixels:
So now we've gotten the hang of targeting individual coordinates and ranges by their x or y positions. How else might we do this?
# | x | y | colour |
---|---|---|---|
1 | 1 | 1 | #5b1647 |
2 | 1 | 2 | #5b1647 |
3 | 1 | 3 | #ffc431 |
4 | 1 | 4 | #ffc431 |
5 | 2 | 1 | #5b1647 |
6 | 2 | 2 | #5b1647 |
7 | 2 | 3 | #ffc431 |
8 | 2 | 4 | #ffc431 |
9 | 3 | 1 | #5b1647 |
10 | 3 | 2 | #5b1647 |
11 | 3 | 3 | #5b1647 |
12 | 3 | 4 | #5b1647 |
13 | 4 | 1 | #5b1647 |
14 | 4 | 2 | #5b1647 |
15 | 4 | 3 | #5b1647 |
16 | 4 | 4 | #5b1647 |
Let's try something different, and compare x and y to each other instead of their grid position:
update bitmap_pixels set colour='#c90035' where x = y
Now we have red pixels appearing wherever x and y match:
Naturally, this would work on a canvas of any size.
OK, one more query before we wrap up the basics.
# | x | y | colour |
---|---|---|---|
1 | 1 | 1 | #c90035 |
2 | 1 | 2 | #5b1647 |
3 | 1 | 3 | #ffc431 |
4 | 1 | 4 | #ffc431 |
5 | 2 | 1 | #5b1647 |
6 | 2 | 2 | #c90035 |
7 | 2 | 3 | #ffc431 |
8 | 2 | 4 | #ffc431 |
9 | 3 | 1 | #5b1647 |
10 | 3 | 2 | #5b1647 |
11 | 3 | 3 | #c90035 |
12 | 3 | 4 | #5b1647 |
13 | 4 | 1 | #5b1647 |
14 | 4 | 2 | #5b1647 |
15 | 4 | 3 | #5b1647 |
16 | 4 | 4 | #c90035 |
So far we've used the x and y columns to aim our brush. But let's not forget about the colour column!
Let's change all of the purple pixels on the right hand side, to orange:
update bitmap_pixels set colour='#ff5627' where x > 2 and colour = '#5b1647'
Just look at how far we've come!
Time to put this artwork on display!
There are a couple of handy ways we can help boost the visual appeal.
# | x | y | colour |
---|---|---|---|
1 | 1 | 1 | #c90035 |
2 | 1 | 2 | #5b1647 |
3 | 1 | 3 | #ffc431 |
4 | 1 | 4 | #ffc431 |
5 | 2 | 1 | #5b1647 |
6 | 2 | 2 | #c90035 |
7 | 2 | 3 | #ffc431 |
8 | 2 | 4 | #ffc431 |
9 | 3 | 1 | #ff5627 |
10 | 3 | 2 | #ff5627 |
11 | 3 | 3 | #c90035 |
12 | 3 | 4 | #ff5627 |
13 | 4 | 1 | #ff5627 |
14 | 4 | 2 | #ff5627 |
15 | 4 | 3 | #ff5627 |
16 | 4 | 4 | #c90035 |
The grid is helpful while drawing, but ugly for viewing. Luckily, we can toggle it on and off at any time.
On the Slack message containing the canvas image, click the "More actions" triple dots (
), then click "More message shortcuts..."
Then find the "Toggle image grid" shortcut and click it. The result:
Any any time, you can request an animated gif that shows the artwork being drawn frame by frame.
To do this, use the "Request GIF" shortcut. You'll find it next to the "Toggle image grid" shortcut you found above.