<?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: Manish</title>
    <description>The latest articles on DEV Community by Manish (@thehalfbloodprince).</description>
    <link>https://dev.to/thehalfbloodprince</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%2F393721%2Fe845c7bc-ed73-4fd0-aa08-775945827b82.jpg</url>
      <title>DEV Community: Manish</title>
      <link>https://dev.to/thehalfbloodprince</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thehalfbloodprince"/>
    <language>en</language>
    <item>
      <title>Inversion of Control and Frameworks v/s Libraries in Software Development</title>
      <dc:creator>Manish</dc:creator>
      <pubDate>Wed, 10 Jan 2024 16:27:55 +0000</pubDate>
      <link>https://dev.to/thehalfbloodprince/inversion-of-control-and-frameworks-vs-libraries-in-software-development-431o</link>
      <guid>https://dev.to/thehalfbloodprince/inversion-of-control-and-frameworks-vs-libraries-in-software-development-431o</guid>
      <description>&lt;p&gt;In the ever-evolving landscape of software development, the quest for efficient and maintainable code is a never ending journey. One of the concepts that has gained prominence in this landscape is the concept of Inversion of Control (IoC). IoC represents a paradigm shift from the traditional approach of writing code, where the developer has primary control over the execution flow, to a more modular and loosely coupled architecture.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Inversion of Control
&lt;/h2&gt;

&lt;p&gt;In a typical software development workflow, developers write code and incorporate external libraries to handle specific functionalities. In this conventional model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The control primarily rests in our code.&lt;/li&gt;
&lt;li&gt;Libraries are integrated to provide reusable components and functionalities.&lt;/li&gt;
&lt;li&gt;Our code delegates control to the library for executing specific tasks.&lt;/li&gt;
&lt;li&gt;Control returns to our code for further execution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, Inversion of Control flips this model on its head:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An external package or framework takes charge of the general workflow.&lt;/li&gt;
&lt;li&gt;It implements essential configurations and functionalities for fundamental aspects of the application.&lt;/li&gt;
&lt;li&gt;Control is then passed to our code for customization.&lt;/li&gt;
&lt;li&gt;Our code, once tailored to its requirements, hands back control to the external package for continued execution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In a practical context, consider the example of NextJS, a popular React framework. NextJS handles tasks such as parsing file structures, building routes, and managing static resources. Developers then contribute their code within individual page components, and the control seamlessly oscillates between the framework and the developer's code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frameworks vs. Libraries
&lt;/h2&gt;

&lt;p&gt;Understanding IoC facilitates a grasp of the broader concepts of frameworks and libraries. In the software development workflow, libraries are tools that we integrate into our code, providing additional and reusable functionalities or utilities. Frameworks, on the other hand, offer a pre-established, structured foundation for building applications. The relationship can be summarized as follows:&lt;/p&gt;

&lt;h3&gt;
  
  
  Libraries
&lt;/h3&gt;

&lt;p&gt;Libraries serve as invaluable supplements to our code, providing additional reusable tools and functionalities. When utilizing libraries:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We plug these libraries into our code, extending its capabilities.&lt;/li&gt;
&lt;li&gt;Developers craft the main logic and code, while libraries offer specific, reusable features.&lt;/li&gt;
&lt;li&gt;For example, libraries, such as React Spinners or mathematical utility packages, expose a set of methods and resources to attain desired functionalities.&lt;/li&gt;
&lt;li&gt;Typically, these entities are implemented by their authors and are intended to be non-modifiable or, at the very least, cautionary about modifications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Consider a React Spinner library – it comprises a set of components accepting properties like size and color to render loader animations. The beauty lies in the simplicity of usage. Developers leverage the same component across multiple instances without delving into the intricacies of its internal workings.&lt;/p&gt;

&lt;p&gt;Exported entities from libraries aren't limited to functions. They can include variables like &lt;code&gt;Math.PI&lt;/code&gt;, functions like &lt;code&gt;Math.round()&lt;/code&gt;, or even entire classes like &lt;code&gt;Serializable&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Frameworks
&lt;/h3&gt;

&lt;p&gt;Frameworks, in contrast, provide a comprehensive, pre-implemented codebase that forms the backbone of an application. Here's how frameworks fit into the development landscape:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Developers plug their code and additional libraries into a framework.&lt;/li&gt;
&lt;li&gt;Frameworks handle the heavy lifting by offering a structured foundation with essential features.&lt;/li&gt;
&lt;li&gt;NextJS, for instance, functions as a framework, providing routing, static resource serving, optimizations, server-side rendering, static site generation, and more out of the box.
Let's dissect the components of NextJS to understand the intricate dance between frameworks and other elements:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Routing&lt;/strong&gt;: Navigation within the application is seamlessly handled.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Static Resources Serving&lt;/strong&gt;: Efficient delivery of static assets is a built-in feature.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optimizations&lt;/strong&gt;: Performance optimizations are taken care of by the framework.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server-Side Rendering (SSR)&lt;/strong&gt;: Dynamic content generation on the server side is seamlessly integrated.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Static Site Generation (SSG)&lt;/strong&gt;: Pre-rendering of pages at build time for enhanced performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Incremental Static Regeneration (ISR)&lt;/strong&gt;: Periodic regeneration of static pages for dynamic data updates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Environment Files Handling&lt;/strong&gt;: Management of environment files, including loading and security.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Loading&lt;/strong&gt;: Reading and incorporating environmental variables to be accessible throughout the application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security&lt;/strong&gt;: Ensuring secure handling of sensitive information, such as env variables being inaccessible by default in client side code, unless being prefixed by &lt;code&gt;NEXT_PUBLIC_&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server-Side Code Generation&lt;/strong&gt;: Dynamically generating server-side code for enhanced flexibility.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, frameworks often rely on additional components, and NextJS is no exception:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Styling&lt;/strong&gt;: Developers choose their preferred styling method – be it CSS Modules, Tailwind, or SASS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UI Library&lt;/strong&gt;: While tightly coupled in many frameworks like NextJS (using React), some frameworks like Astro offer flexibility by allowing the combination of multiple UI libraries (React, Preact, Svelte, Vue, etc.).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linting and Formatting&lt;/strong&gt;: Developers can plug in their preferred tools for code linting and formatting.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Embracing Inversion of Control, along with an understanding of frameworks and libraries, empowers developers to create scalable, maintainable, and adaptable software architectures. By relinquishing control to external packages for fundamental functionalities, developers can focus on crafting code that aligns with specific project requirements, fostering a more modular and collaborative approach to software development. As the landscape continues to evolve, embracing these concepts becomes integral to staying ahead in the dynamic world of software engineering.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note/Credits&lt;/strong&gt;: This article is based off my notes. I'm still learning these concepts and I keep noting down what I understand and think is pivotal. The content is then stitched together and filled into blog paragraphs using AI. It hasn't just been lousily copied from ChatGPT using my notes, it has undergone multiple readings and modifications and multiple prompts. But I've just kept it transparent for your judgement and knowledge. Thanks!&lt;/p&gt;
&lt;/blockquote&gt;

</description>
    </item>
    <item>
      <title>Day 2 | Xhopie - Starting up</title>
      <dc:creator>Manish</dc:creator>
      <pubDate>Wed, 03 Jan 2024 00:40:53 +0000</pubDate>
      <link>https://dev.to/thehalfbloodprince/day-2-xhopie-starting-up-cfp</link>
      <guid>https://dev.to/thehalfbloodprince/day-2-xhopie-starting-up-cfp</guid>
      <description>&lt;blockquote&gt;
&lt;h4&gt;
  
  
  Context
&lt;/h4&gt;

&lt;p&gt;This is a blog series where I document my progress on Xhopie, a self project I'm starting to learn about general concepts regarding software development by implementing an e-commerce application with different tools and technologies to learn how to do important and common things in different languages.&lt;br&gt;
Here's the main repo link: &lt;a href="https://github.com/the-halfbloodprince/xhopie-main"&gt;https://github.com/the-halfbloodprince/xhopie-main&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Work Overview
&lt;/h3&gt;

&lt;p&gt;So here is a brief overview of the work&lt;/p&gt;

&lt;h3&gt;
  
  
  on &lt;code&gt;xhopie-server-node&lt;/code&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Environment Variables
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;added env file support (used dotenv, considered also using the native &lt;code&gt;--env-file&lt;/code&gt; flag of NodeJS, but fell back on dotenv to make it work asap with nodemon and ts-node)

&lt;ul&gt;
&lt;li&gt;currently just added &lt;code&gt;PORT&lt;/code&gt;, &lt;code&gt;HOST&lt;/code&gt; and &lt;code&gt;EXAMPLE_VARIABLE&lt;/code&gt; to the list&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;EXAMPLE_VARIABLE&lt;/code&gt; is just a variable used to be available to confirm the proper loading of env variables. This can be done in other more robust ways probably, or just by checking any other variable, so it is safe to be removed in a future commit.&lt;/li&gt;
&lt;li&gt;added all of them in an &lt;code&gt;.env.example&lt;/code&gt; file as well.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;added env file type declaration support

&lt;ul&gt;
&lt;li&gt;added a &lt;code&gt;ENV_Variables&lt;/code&gt; interface in the config folder for declarations of the variables&lt;/li&gt;
&lt;li&gt;added a overwrite of &lt;code&gt;ProcessEnv&lt;/code&gt; interface which declares the interface of &lt;code&gt;process.env&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;used inheritance to automatically extend from the &lt;code&gt;ENV_Variables&lt;/code&gt; interface.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;defined a separate &lt;code&gt;APP_CONFIG&lt;/code&gt; variable in &lt;code&gt;config&lt;/code&gt; folder to hold important app wide accessible variables in one place

&lt;ul&gt;
&lt;li&gt;added the env variables present at the moment to &lt;code&gt;APP_CONFIG&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;also throwing an error if there was any error in loading env variables.&lt;/li&gt;
&lt;li&gt;TODO: This should be properly handled later instead of blatantly just throwing an error&lt;/li&gt;
&lt;li&gt;also this makes the purpose of &lt;code&gt;EXAMPLE_HANDLING&lt;/code&gt; obsolete, so it's been removed&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Refactoring The Project's Folder Structure
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;added the &lt;code&gt;src&lt;/code&gt; folder.

&lt;ul&gt;
&lt;li&gt;made corresponding updates in the &lt;code&gt;package.json&lt;/code&gt; as well as &lt;code&gt;tsconfig.json&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It was a short day, mostly just configuring stuff up, recalling the good architectural/folder patterns etc, and just brushing up some of my old concepts and memories.&lt;/p&gt;

&lt;p&gt;Hope you hadn't given up on your new year resolutions yet. Keep the work up.&lt;/p&gt;

&lt;p&gt;See you on the next day.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Day 1 | Xhopie - Starting up</title>
      <dc:creator>Manish</dc:creator>
      <pubDate>Mon, 01 Jan 2024 01:26:04 +0000</pubDate>
      <link>https://dev.to/thehalfbloodprince/day-1-xhopie-starting-up-4h75</link>
      <guid>https://dev.to/thehalfbloodprince/day-1-xhopie-starting-up-4h75</guid>
      <description>&lt;p&gt;This will be a blog series where I document my progress on Xhopie, a self project I'm starting to learn about general concepts regarding software development by implementing an e-commerce application with different tools and technologies to learn how to do important and common things in different languages.&lt;/p&gt;

&lt;p&gt;Here's the main repo link: &lt;a href="https://github.com/the-halfbloodprince/xhopie-main"&gt;https://github.com/the-halfbloodprince/xhopie-main&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Starting this out today, on the 1st of Jan, 2024. (Please don't judge me)&lt;/p&gt;

&lt;p&gt;I'll not be going into in-depth summarization today, as I don't have much to say at this point, and it's already 6:20am, I really need to go to sleep.&lt;/p&gt;

&lt;h2&gt;
  
  
  Work Overview
&lt;/h2&gt;

&lt;p&gt;So here are a few basic overviews&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Decided to use git submodules as I'll be creating various repositories in future to try the same things out in other technologies such as Angular and Spring Boot.&lt;/li&gt;
&lt;li&gt;Decided to start using a set of flags on my commit messages which will make it easier to navigate and read. I believe this kind of organization technique must already be used elsewhere as well, but I haven't seen much of it from the projects I have encountered or the organizations I have worked for. So, yeah it's simple and obvious but I'm glad I came up with it myself and started using it from the start of the project.
Here are the flags at the moment:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DIARY&lt;/strong&gt;
just updating the diary.md&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SYNC&lt;/strong&gt;
just syncing/updating submodules&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CONFIG&lt;/strong&gt;
makes configurational changes
like,&lt;/li&gt;
&lt;li&gt;adding dependencies&lt;/li&gt;
&lt;li&gt;making global file structure changes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FEATURE&lt;/strong&gt;
adding features like:&lt;/li&gt;
&lt;li&gt;adding a new client component&lt;/li&gt;
&lt;li&gt;adding a new REST endpoint functionalities&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;REFACTOR&lt;/strong&gt;
refactors like:&lt;/li&gt;
&lt;li&gt;refactoring a react component to multiple individual components&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OOPS&lt;/strong&gt;
made a mistake somewhere down the line, this commit is a part of an effort to fix it&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Decided to keep a &lt;code&gt;diary.md&lt;/code&gt; file explaining the work for that day. But now that I'm writing this blog, I'm starting to wonder if that's useless, but nonetheless, let's keep it for now.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Work (repo wise)
&lt;/h2&gt;

&lt;p&gt;Here's an overview of the work in the respective repositories. The same can also be found in their corresponding &lt;code&gt;diary.md&lt;/code&gt; files&lt;/p&gt;

&lt;h3&gt;
  
  
  xhopie (Main)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;started the project structure&lt;/li&gt;
&lt;li&gt;decided to use git submodules&lt;/li&gt;
&lt;li&gt;learnt how to use and work with submodules&lt;/li&gt;
&lt;li&gt;accidentally made blunders with submodules (happens everytime I try out a new git feature)&lt;/li&gt;
&lt;li&gt;made respective changes in the next client and node server repositories&lt;/li&gt;
&lt;li&gt;set up my VS-Code workspace config&lt;/li&gt;
&lt;li&gt;added flags to be used in commit messages for better readability and navigation through commit history&lt;/li&gt;
&lt;li&gt;regretted not recording this session (would have been fun to start documenting it on YouTube)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  xhopie-client-next
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;decided the project structure&lt;/li&gt;
&lt;li&gt;made 3 categories for the app

&lt;ul&gt;
&lt;li&gt;marketing (all the landing pages / marketing pages)&lt;/li&gt;
&lt;li&gt;store (main store app)&lt;/li&gt;
&lt;li&gt;seller (seller interface)&lt;/li&gt;
&lt;li&gt;admin (admin dashboard)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;gave each of these their own &lt;code&gt;layout.tsx&lt;/code&gt; file as they can have drastically separate layouts later.&lt;/li&gt;
&lt;li&gt;made all of them to by-default reference the &lt;code&gt;globals.css&lt;/code&gt; in the &lt;code&gt;app&lt;/code&gt; folder. As they would progressively need different styles, we may point to different &lt;code&gt;globals.css&lt;/code&gt; in their respective folders/groups.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  xhopie-server-node
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;just did a bare initialization of the app&lt;/li&gt;
&lt;li&gt;added typescript, express and nodemon&lt;/li&gt;
&lt;li&gt;nothing much for today in this app&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Today's 1st of Jan 2024, and this is my first new year resolution. Starting out the project with hopes of atleast staying consistent and building something that can teach a lot.&lt;/p&gt;

&lt;p&gt;Bye.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>nextjs</category>
      <category>node</category>
    </item>
    <item>
      <title>Stripes in Shaders</title>
      <dc:creator>Manish</dc:creator>
      <pubDate>Fri, 11 Nov 2022 21:30:57 +0000</pubDate>
      <link>https://dev.to/thehalfbloodprince/stripes-in-shaders-3n5n</link>
      <guid>https://dev.to/thehalfbloodprince/stripes-in-shaders-3n5n</guid>
      <description>&lt;h3&gt;
  
  
  Arguments to the frag fn
&lt;/h3&gt;

&lt;p&gt;the frag fn takes 4 arguments: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;red&lt;/strong&gt; value, &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;green&lt;/strong&gt; value, &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;blue&lt;/strong&gt; value, and &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;opacity&lt;/strong&gt; value. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All these values lie in the range [0.0, 1.0]. &lt;br&gt;
Any value above 1.0 is treated the same as 1.0&lt;br&gt;
and any value below 0.0 is treated the same as 0.0.&lt;/p&gt;

&lt;p&gt;eg:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fragColor = vec4(1.0, 0.0, 0.0 ,1.0);&lt;/code&gt;&lt;br&gt;
will produce the following result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--turXj6m---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qz5p1cjziaatdgxn7b4e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--turXj6m---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qz5p1cjziaatdgxn7b4e.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fragColor = vec4(0.0, 1.0, 0.0 , 1.0);&lt;/code&gt;&lt;br&gt;
will produce the following result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RmmB2Z5y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yzajvv9lq7a8ljosjfky.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RmmB2Z5y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yzajvv9lq7a8ljosjfky.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fragColor = vec4(0.0, 0.0, 1.0 , 1.0);&lt;/code&gt;&lt;br&gt;
will produce the following result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xAZsBa4A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ctbtl5nii3ee3hlqo4ko.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xAZsBa4A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ctbtl5nii3ee3hlqo4ko.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can mix the 4 fields with different values to generate any other colour or effect.&lt;/p&gt;
&lt;h3&gt;
  
  
  Normalizing the coordinates to screen coordinates (uv)
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight glsl"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Normalized pixel coordinates (from 0 to 1)&lt;/span&gt;
&lt;span class="kt"&gt;vec2&lt;/span&gt; &lt;span class="n"&gt;uv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fragCoord&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;iResolution&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;now &lt;code&gt;uv&lt;/code&gt; will store a vec2 with values from 0 to 1 with the leftmost coordinate value 0 and rightmost value with value 1.&lt;/p&gt;
&lt;h3&gt;
  
  
  Simple X-Gradient
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight glsl"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Normalized pixel coordinates (from 0 to 1)&lt;/span&gt;
&lt;span class="kt"&gt;vec2&lt;/span&gt; &lt;span class="n"&gt;uv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fragCoord&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;iResolution&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;span class="c1"&gt;// Output to screen&lt;/span&gt;
&lt;span class="n"&gt;fragColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;vec4&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;this will give the following result&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_eTr3pmi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t2z8ps0m5awo4ssehbai.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_eTr3pmi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t2z8ps0m5awo4ssehbai.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Simple Y-Gradient
&lt;/h3&gt;

&lt;p&gt;doing the same but with &lt;code&gt;uv.y&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight glsl"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Normalized pixel coordinates (from 0 to 1)&lt;/span&gt;
&lt;span class="kt"&gt;vec2&lt;/span&gt; &lt;span class="n"&gt;uv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fragCoord&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;iResolution&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;span class="c1"&gt;// Output to screen&lt;/span&gt;
&lt;span class="n"&gt;fragColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;vec4&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1KODDL7r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kdgvh5aasm0jykz52sc3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1KODDL7r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kdgvh5aasm0jykz52sc3.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Combining colors
&lt;/h3&gt;

&lt;p&gt;We can combine the 3 fields to get different colours such as:&lt;br&gt;
&lt;code&gt;fragColor = vec4(0.3, 0.0, 0.5 , 1.0);&lt;/code&gt;&lt;br&gt;
output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DKZJkc4K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qejzsfz2bg581gsdf5lq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DKZJkc4K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qejzsfz2bg581gsdf5lq.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Stripes
&lt;/h3&gt;

&lt;p&gt;to create stripes,&lt;br&gt;
we start from a basic gradient:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight glsl"&gt;&lt;code&gt;&lt;span class="n"&gt;fragColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;vec4&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kmK-dUyR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w35tu4zayz53mhc7e19c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kmK-dUyR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w35tu4zayz53mhc7e19c.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;right now the red value is varying linearly along the x-direction.&lt;/p&gt;

&lt;p&gt;Lets start by choosing a function which oscillates unlike a linear function.&lt;/p&gt;

&lt;p&gt;eg: sine function&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fragColor = vec4(sin(uv.x), 0.0, 0.5 , 1.0);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---GQC-lrc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7c6xnpmkbu6rwuis7k09.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---GQC-lrc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7c6xnpmkbu6rwuis7k09.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;you may not be able to tell a lot of difference, but wait until we scale the input to the function:&lt;/p&gt;

&lt;p&gt;for a linear func: &lt;code&gt;fragColor = vec4(uv.x * 20.0, 0.0, 0.5 , 1.0);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z1V9B-wv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9rmpw02lzrb25l3uy9yj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z1V9B-wv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9rmpw02lzrb25l3uy9yj.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;but for the sine func: fragColor = vec4(sin(uv.x * 20.0), 0.0, 0.5 , 1.0);&lt;/p&gt;

&lt;p&gt;output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FiLTzvOt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0k72v01lnxikxuup0pws.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FiLTzvOt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0k72v01lnxikxuup0pws.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;as we see the red value for linear fn reaches 1 faster and then above 1 it behaves as 1, but for the oscillatory fn reaches 1 very fast and then again goes to -1, which is why we see the darker region more as values &amp;lt; 0 are treated as 0.&lt;/p&gt;

&lt;p&gt;to get a more equal width strip pattern, we need to oscillate the values from 0 to 1 not -1 to 1.&lt;/p&gt;

&lt;p&gt;for this lets try using the following trick&lt;br&gt;
remove the -1 part by adding 1 to the func , ie, &lt;code&gt;sin(uv.x) + 1.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;but this will get us the answer from 0 to 2.&lt;/p&gt;

&lt;p&gt;to manage this, we can halve this, ie, 0.5 * (sin(uv.x * 20.) + 1.)&lt;/p&gt;

&lt;p&gt;output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--750Rep4F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dd6vjd2nofeb0tcqoq19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--750Rep4F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dd6vjd2nofeb0tcqoq19.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;increasing the argument to sine func increases the frequency of the stripes and reduces the width:&lt;/p&gt;

&lt;p&gt;eg: changing the scale from 20. to 40.&lt;br&gt;
&lt;code&gt;fragColor = vec4(0.5 * (sin(uv.x * 40.) + 1.), 0.0, 0.5 , 1.0)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1Xu1iKiH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uu6u7msik0udl0f5m9a4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1Xu1iKiH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uu6u7msik0udl0f5m9a4.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;to make the strips sharp and not dissolving naturally, we can ceil the sine func which will give us values in sharp 0 and 1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fragColor = vec4(ceil(sin(uv.x * 40.)), 0.0, 0.5 , 1.0);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--a-_q0tNV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5pvbpaii0clxzh8ke3yo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--a-_q0tNV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5pvbpaii0clxzh8ke3yo.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Y-stripes
&lt;/h4&gt;

&lt;p&gt;replacing &lt;code&gt;uv.x&lt;/code&gt; in the above expression with &lt;code&gt;uv.y&lt;/code&gt; gives us stripes along the y-direction&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fragColor = vec4(0.5 * (sin(uv.y * 40.) + 1.), 0.0, 0.5 , 1.0);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--t2YRAQZ3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/770nkzigjir3mo1ia61a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--t2YRAQZ3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/770nkzigjir3mo1ia61a.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fragColor = vec4(ceil(sin(uv.x * 40.)), 0.0, 0.5 , 1.0);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--u23jd9dB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4mi181w2fkip45imrygg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u23jd9dB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4mi181w2fkip45imrygg.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;combining the x and y expressions:&lt;br&gt;
&lt;code&gt;fragColor = vec4(0.5 * (sin(uv.y * 40.) + 1.) + 0.5 * (sin(uv.x * 40.) + 1.), 0.0, 0.5 , 1.0);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U5g4x8Ou--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s0vpkvk7k1q01wdc00yq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U5g4x8Ou--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s0vpkvk7k1q01wdc00yq.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;sharpening the values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight glsl"&gt;&lt;code&gt;&lt;span class="n"&gt;fragColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;vec4&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ceil&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;.))&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;ceil&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;.)),&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MuUP5K7Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hi6r7wa1ako08nkxkbvv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MuUP5K7Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hi6r7wa1ako08nkxkbvv.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;keeping the red stripes in x and blue stripes in y, we get:&lt;br&gt;
&lt;code&gt;fragColor = vec4(0.5 * (sin(uv.x * 40.) + 1.), 0.0, 0.5 * (sin(uv.y * 40.) + 1.) , 1.0);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vE_3veTS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1o59g4gov2socznjb963.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vE_3veTS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1o59g4gov2socznjb963.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fragColor = vec4(ceil(sin(uv.x * 40.)), 0.0, ceil(sin(uv.y * 40.)) , 1.0);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Tum1C7Hp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1z818fdhn3tfyx7myt6q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tum1C7Hp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1z818fdhn3tfyx7myt6q.png" alt="Image description" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>shader</category>
      <category>glsl</category>
      <category>webgl</category>
      <category>3d</category>
    </item>
  </channel>
</rss>
