<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mark Damics</title>
    <description>The latest articles on DEV Community by Mark Damics (@admin1299).</description>
    <link>https://dev.to/admin1299</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2363328%2F91665665-9746-4a10-9865-f57a790047e6.jpeg</url>
      <title>DEV Community: Mark Damics</title>
      <link>https://dev.to/admin1299</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/admin1299"/>
    <language>en</language>
    <item>
      <title>Matrix code rain - in Rust</title>
      <dc:creator>Mark Damics</dc:creator>
      <pubDate>Sun, 29 Dec 2024 12:49:11 +0000</pubDate>
      <link>https://dev.to/admin1299/matrix-code-rain-in-rust-1fad</link>
      <guid>https://dev.to/admin1299/matrix-code-rain-in-rust-1fad</guid>
      <description>&lt;p&gt;Not long ago I started to work with Rust and for me it is amazing. The speed, the type safety, the number of use cases are just amazing in Rust.&lt;/p&gt;

&lt;p&gt;As practice, I wanted to implement the Matrix code rain, which I always wanted to implement but never got there. It turned out to be a good little project. It includes algorithms and terminal manipulation.&lt;/p&gt;

&lt;p&gt;My github repo: &lt;a href="https://github.com/markdamics/Matrix_rainfall" rel="noopener noreferrer"&gt;Matrix Rainfall&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are 3 different structs which represent each element:&lt;/p&gt;

&lt;p&gt;Symbol: Here we store and edit each character of the matrix. The function of setting a random symbol is implemented here (it will be called in the Column). The fading function is also implemented here. For the color manipulation, I used a third-party crate.&lt;/p&gt;

&lt;p&gt;Column: Here we initialize each symbol, and most of the algorithm (starting raindrops, space between raindrops, calling random characters, calling fade function) happens here. We store here each vector (raindrop) start point and end point.&lt;/p&gt;

&lt;p&gt;Matrix: Practically, it represents a table where you have the terminal width and height. The setting of the background color, moving the cursor, and the initialization of the columns happen here.&lt;/p&gt;

&lt;p&gt;With parameters, we can set the speed, the color of the background, and the color of the characters.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F856agwc8b5b3q24asmyr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F856agwc8b5b3q24asmyr.png" alt="Green Matrix" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F54x86jkdnk5tlrgsn7b0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F54x86jkdnk5tlrgsn7b0.png" alt="Yellow on bluw Matrix" width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcloyzf80ux9xlo2p9czy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcloyzf80ux9xlo2p9czy.png" alt="Blue Matrix" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So far it works well with '1' and '0' characters but if I want to add more then the columns don't hold themselfs, like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9vlfv3qksu7urx8yqmt4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9vlfv3qksu7urx8yqmt4.png" alt="error with multiple symbols" width="800" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;:&lt;br&gt;
Now it works with multiple characters. The problem was this '日' character and the reason was that this character takes 2x of regular size on the terminal.&lt;/p&gt;

&lt;p&gt;Reference:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/SeTSL0JYVVk"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;a href="https://github.com/jakobwesthoff/green_rust/tree/main" rel="noopener noreferrer"&gt;repo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rust</category>
      <category>cli</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
