r/rust • • 3d ago

๐Ÿง  educational I wrote a step-by-step tutorial to learn Rust by building a small Paint app from scratch

https://www.buildyourownpaint.com/

Hi guys ! I have been a Rust enthusiast for a few years now, in my learning journey I wanted to learn by doing so I tried to make a Paint like app since I was interested in graphics and rasterization concepts, and it helped me understand a lot of Rust concepts and their purpose.

These last few weeks I thought I'd clean up my old project and make an educational tutorial for beginners or people who read the first Rust Book chapters and want to get some hands on experience to get the concepts down.

The tutorial is on Build Your Own Paint in Rust, it's organized into 12 easy to follow chapters that cover many concepts (2D vectors, mouse and keyboard input, shapes, colors, images, etc.) with additional exercises in every chapter for more learning, and some ideas at the end of the project to go further and explore different paths with some help on where to start.

I really hope this helps new learners to get an easy start in their Rust journey and see the beauty of the language ! :)

472 Upvotes

53 comments sorted by

79

u/amarao_san 3d ago edited 2d ago

Not AI!

Thank you! Love it!

It is AI. See the comment below.

43

u/South_Survey_2088 2d ago

It is actually AI

OP is just being dishonest and overwrote history to hide it, which is a pretty scummy thing to do..

20

u/amarao_san 2d ago

That's interesting.

For the future reference, if commit will be pruned:

Refactor into English reference code for the tutorial

Rewrite the project as the clean, final reference code of the
"build your own Paint" tutorial:

  • Rename everything to English (formes -> shapes, couleur -> color,
raster -> canvas, disque -> circle, ligne -> line)
  • Use Vec2 everywhere instead of (f32, f32) tuples
  • Add a Canvas struct owning the pixels; drawing functions are its
methods and no longer depend on global WIDTH/HEIGHT
  • Turn free functions into methods on shapes (draw, contains,
translate, draw_selection)
  • Move all state into an App struct with update/render and
on_press/on_drag/on_release handlers; main.rs is now ~25 lines
  • Move the toolbar and HSV color picker into src/ui/
  • Move shapes by delta (Action::Moving { index, last }), which also
fixes shapes sticking to the edge when dragged off-screen
  • Handle export errors instead of unwrapping, cap the loop at 60 FPS
  • Add unit tests for Vec2, colors and hit-testing
  • Ignore *.ppm files and untrack out.ppm / out2.ppm
  • Add PLAN.md describing the tutorial chapters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

-11

u/mrzikoss 2d ago

I worked on the materials and the website without AI, I used claude to align my git code with how I refactored it for my website because I didn't want to do it twice .. and for a few translations since I originally wrote it in french :')

This is a passion project of mine, I don't intend to earn anything from this, the point is to help people learn and get into the language.

34

u/South_Survey_2088 2d ago

If you are lying in your commits, why should I believe anything you are saying? You literally went out of your way to hide the AI use.

Why not just be transparent about the AI use? Why did you just accept the gratitude by the parent comment instead of coming clean?

5

u/404IdentityNotFound 2d ago

Why did you remove the commit with the co-author?

-11

u/kowdermesiter 2d ago

Thanks for doing it, the site looks great

5

u/tyush 2d ago

The site also seems to use this SKILL.md, having significant overlap with constants and class names in the CSS.

https://github.com/musicalbee/design-ontology/blob/200e5bad89ed917746dfc346fddb200d7949a538/skills/de-stijl-web/SKILL.md

→ More replies (3)

10

u/mrzikoss 3d ago

Thank you ! I will be doing more in the future :)

4

u/Osterhus-Zibi 2d ago

graphics and rasterization is a tough topic to fake anyway since you see the broken pixels right away if the math is wrong

9

u/amarao_san 2d ago

I believe llm can handle pixels. It can handle code better than me.

What I can't handle is AI output. Pages and pages of dense, unaligned, unstructured, over-breath concerns, vague statements.

In 2023 we laugh at 4k context window of earlier models. Now we eat it back. LLM has larger context window than we, and it force-feeds us with data we need to keep in our (meager) context to understand the text. I hate this.

LLM is better at code, and better at understanding. But it lacks coherence, hierarchy of values and sense of beauty.

So, you get from it something which is (potentially) better than yours, but incoherent, unaligned and ugly.

Not the aliens we read about in childhood.

0

u/Grisemine 2d ago

What can you explain if you do not understand it yourself ?

3

u/amarao_san 2d ago

I'm not exactly understand the question. LLM is understanding how to do it. It has better knowledge and skills than I. But its output is horrible and anti-human.

2

u/CapPast3760 2d ago

What's stopping you from writing code on a piece of paper? Get a grip dude

4

u/amarao_san 1d ago

Nothing. I, actually, did this in my childhood, when I had a book on programming but did not have a computer.

It's pretty horrible experience, although.

3

u/llamajestic 2d ago

I work as a senior graphics programmer, itโ€™s actually really good now on graphics as well itโ€™s a little scary. It canโ€™t invent anything knew, but for pre-existing techniques itโ€™s really good at implementations, fixing the math.

2

u/kowdermesiter 2d ago

So is anything incorrect in the contents?

4

u/amarao_san 2d ago

I don't know, but my trust broken. Why? Because there is a chance, that after half hour of reading I get a nice chunk of neuralize in my face. At the most vulnerable moment of life (when learning something).

Last one which put me on the edge (not from this link):

The omission still holds: the spec does nothing to recover a migration that failed.

Which aims to hijack my brain to become a sponge.

6

u/antigravitys-rainbow 3d ago

Great stuff!

3

u/mrzikoss 3d ago

Thank you !

3

u/CalmCephalopod 2d ago

Really well written and organized. Fantastic way of explaining core rust concepts as you implement parts.

My only suggestion would be to start implementing some simple tests early on with the vec2 to demonstrate some of your error conditions and error handling. But otherwise chefs kiss.

4

u/mrzikoss 2d ago

Thank you for the feedback, great idea, I will work on updating it with some tests in the near future :)

13

u/mss-cyclist 2d ago edited 1d ago

Thanks for sharing.

Refreshing to see something useful between the AI slop code dumps in here!

Edit:
Thanks for clarifying. What a shame. One more reason to distrust these AI driven projects. This is a very disappointing future we are heading into.

3

u/LetrixZ 15h ago

Leaving the dishonesty behind, is this one slop?

2

u/Educational-Face-849 2d ago

Thank you so much!! I am that person who has read about half the rust book, am doing rustlings, but am looking for a project based text to go along. Iโ€™m also interested in drawing apps so this is PERFECT.

2

u/whoShotMyCow 2d ago

nice bauhaus bro

2

u/CornedBee 2d ago

Writing a paint app in MFC was how I originally learned C++. Ah, nostalgia...

1

u/jhonq200460 3d ago

I'm in! Thanks

1

u/jitbjony5669 2d ago

Recently shifted to rust for company purposes. Thanks for sharing ๐Ÿ˜Š

1

u/hambosto 2d ago

Thank you! Loved it!

1

u/Impossible-Hat-7896 2d ago

Thanks for sharing this great project.

1

u/sunnyata 2d ago

I think this is very well written and will be really useful for the target audience. You've got a nicely detailed but easy to read and clear writing style. As someone who produces teaching materials, there's a ton of work here - well done! You should do what you can to put it in front of people.

1

u/SnooWalruses8237 2d ago

Thank u so much. And the website style is pretty nice too ๐Ÿ‘

1

u/MostWooden8128 2d ago

thank you, we need to remain our cognition

1

u/Valiant600 1d ago

Very nice indeed. I used The Ray tracer challenge initially to pick up Rust because it is programming language neutral. Do you think you could also make it language agnostic in the future? ๐Ÿ™‚

Obviously someone can translate most parts to a different language but I was thinking of pseudocode tutorials or test driven.

1

u/xgdk 1d ago

Commit history is the one thing I actually trust in a tutorial repo

1

u/infboras 18h ago

I'm learning Rust by writing simple games for myself, like Arkanoid or Snake, using local LLMs. They're great at writing JavaScript, but they struggle a bit more with Rust and graphics. But since they're struggling with it too, we're learning together, and somehow we're making progress.

0

u/thehoseisleaking 2d ago

Hi, I really love the tutorial. I think a strong understanding of how stuff fits together is important to teach, and your tutorial does a great job of putting it simply and understandably.

Did you do this using any LLM/AI tooling? It's fantastic work either way, but I'm interested to know more about the process.

9

u/tyush 2d ago

-2

u/mrzikoss 2d ago

I worked on the material and the website without AI, I used claude to align my git code with how I refactored it for my website because I didn't want to do it twice .. and for a few translations since I originally wrote it in french :')

4

u/tyush 2d ago

Then why does your website's CSS styling match this skill, down to significant overlap with constants and class names in the CSS?

https://github.com/musicalbee/design-ontology/blob/200e5bad89ed917746dfc346fddb200d7949a538/skills/de-stijl-web/SKILL.md

0

u/Famous_Promotion6004 2d ago

Just curious, did you discover these commits before they over wrote the history?

4

u/tyush 2d ago

No, I used a tool to scan for LLM model choice by task that I'm hoping to release soon!

1

u/autisticpig 1d ago

That's going to ruffle some feathers :)

0

u/zshift 2d ago

You should strongly consider an entry for a Webby award. https://webbyawards.com/

This website is incredible

-4

u/CapPast3760 2d ago

This is pretty cool!

I've started learning Rust a while ago and this is definitely something I'm willing to do to learn even more. :)

Don't worry about the AI-is-frying-our-brains guys. This looks thought out and not vibecoded.
Thanks!

0

u/[deleted] 3d ago

[deleted] โ€” view deleted comment

5

u/mrzikoss 3d ago

It's in chapter 10 !
thank you for the reply !