<?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: Adhishreya P</title>
    <description>The latest articles on DEV Community by Adhishreya P (@adhishreyap).</description>
    <link>https://dev.to/adhishreyap</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%2F354990%2Fec3085cc-df43-450d-8a82-76afeb5fc2a4.png</url>
      <title>DEV Community: Adhishreya P</title>
      <link>https://dev.to/adhishreyap</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adhishreyap"/>
    <language>en</language>
    <item>
      <title>Create a simple paint app using react-canvas-draw</title>
      <dc:creator>Adhishreya P</dc:creator>
      <pubDate>Mon, 08 Mar 2021 13:05:45 +0000</pubDate>
      <link>https://dev.to/adhishreyap/create-a-simple-paint-app-using-react-canvas-draw-20bc</link>
      <guid>https://dev.to/adhishreyap/create-a-simple-paint-app-using-react-canvas-draw-20bc</guid>
      <description>&lt;p&gt;Create a react app and install react-canvas-draw dependency&lt;br&gt;
&lt;code&gt;npm install react-canvas-draw --save&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We shall use a functional component to include the CanvasDraw component&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffcluiu8sc41il9zsod5y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffcluiu8sc41il9zsod5y.png" alt="image" width="772" height="586"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This a basic setup where only few props are used. We now have a canvas component where the brush colour ,width has been set.The grid lines have been hidden.&lt;/p&gt;

&lt;p&gt;For more props refer &lt;a href="https://www.npmjs.com/package/react-canvas-draw"&gt;https://www.npmjs.com/package/react-canvas-draw&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Undo and clear features can be included using reference to the component&lt;br&gt;
Read more about it here &lt;a href="https://reactjs.org/docs/refs-and-the-dom.html"&gt;Refs and the DOM&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ref={(canvasDraw) =&amp;gt; (this.modify = canvasDraw)}&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;Next let's accept user brush size and colour selections.We shall be building a palette from scratch.&lt;br&gt;
You can also try &lt;a href="https://www.npmjs.com/package/react-color-palette"&gt;react-colour-palette&lt;/a&gt;. A color picker component for React.&lt;/p&gt;

&lt;p&gt;Since we are using react hooks in this app we shall begin by importing &lt;em&gt;&lt;code&gt;useState&lt;/code&gt;&lt;/em&gt; hook from react&lt;br&gt;
&lt;code&gt;import {useState} from 'react'&lt;/code&gt;&lt;br&gt;
Read more about hooks &lt;a href="https://reactjs.org/docs/hooks-intro.html"&gt;What is ReactHooks&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First we shall set the initial state of the colour and width of the brush.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;canvas is initialized to the value given as an argument to the useState &lt;/li&gt;
&lt;li&gt;setBrush is the function used to modify the value of canvas&lt;/li&gt;
&lt;li&gt;brush is initialized to value 50&lt;/li&gt;
&lt;li&gt;setThick is used to modify the value of brush thickness&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqo91v4lm4qru4bb6ol5x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqo91v4lm4qru4bb6ol5x.png" alt="image" width="800" height="423"&gt;&lt;/a&gt;&lt;br&gt;
The modified ReactCanvas component&lt;/p&gt;

&lt;p&gt;So we shall use input element of type &lt;em&gt;color&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe75h7o8xmzi8vlxj07yy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe75h7o8xmzi8vlxj07yy.png" alt="image" width="800" height="550"&gt;&lt;/a&gt;&lt;br&gt;
Whenever the input element changes our brush colour variable &lt;em&gt;canvas&lt;/em&gt; changes.As stated earlier we shall be making use of setBrush function to change the colour.&lt;/p&gt;

&lt;p&gt;To change the brush thickness &lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1vckgjjimoyukdjshm9d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1vckgjjimoyukdjshm9d.png" alt="image" width="800" height="550"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The thickness here shall vary between 2 and 50.&lt;br&gt;
One can further add more features.&lt;br&gt;
The complete code can be found &lt;a href="https://codesandbox.io/s/reverent-grass-0sh2f?file=/src/Diagram.js"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Let's write a fun CLI quiz</title>
      <dc:creator>Adhishreya P</dc:creator>
      <pubDate>Wed, 09 Dec 2020 06:51:44 +0000</pubDate>
      <link>https://dev.to/adhishreyap/let-s-write-a-fun-cli-quiz-4b4o</link>
      <guid>https://dev.to/adhishreyap/let-s-write-a-fun-cli-quiz-4b4o</guid>
      <description>&lt;p&gt;what is &lt;strong&gt;&lt;em&gt;require()&lt;/em&gt;&lt;/strong&gt;??&lt;/p&gt;

&lt;p&gt;require is a function that allows us to work with modules defined in separate files. If u are familiar with C then require is similar to &lt;strong&gt;&lt;em&gt;include&lt;/em&gt;&lt;/strong&gt;.&lt;br&gt;
So the functionality involves reading the specified JavaScript file and returning the export object of the file.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var code=require('readline-sync')&lt;/code&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;em&gt;readline-sync&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Basically, it allows to have interaction with the user via the console in a synchronous manner.&lt;/p&gt;

&lt;p&gt;To get the user input one can use 'question'&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var readInput=require('readline-sync');&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var input =readInput.question('Helooooo what's ur name?');&lt;br&gt;
//the user's response is stored in the variable 'input'&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What is chalk??
&lt;/h2&gt;

&lt;p&gt;It basically a styling library for your terminal. You can also chain multiple styles!!&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var chalk=require('chalk')&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(chalk.red.italic("we are trying out chalk"))&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8IqdNXVT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://user-images.githubusercontent.com/42477290/101345947-d214ac80-38ad-11eb-9079-094dcd8fd1c8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8IqdNXVT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://user-images.githubusercontent.com/42477290/101345947-d214ac80-38ad-11eb-9079-094dcd8fd1c8.png" alt="image" width="589" height="39"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;read more about it here.... &lt;a href="https://www.npmjs.com/package/chalk"&gt;Chalk js Documentation&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;code&gt;forEach()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A method that allows a function to be executed on every element of the list just as any regular for loop does.&lt;/p&gt;

&lt;h6&gt;
  
  
  A basic syntax.
&lt;/h6&gt;

&lt;p&gt;&lt;code&gt;array.forEach(function(currentValue, index, arr))&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;currentValue= the current element being worked on&lt;/li&gt;
&lt;li&gt;index = index of the current element&lt;/li&gt;
&lt;li&gt;arr=array object the current object belongs to&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;example&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;list=[1,2,3,4]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;list.forEach((element,index)=&amp;gt;{console.log(index,element)});&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6mK77COK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://user-images.githubusercontent.com/42477290/101589413-5d0cb880-3a0e-11eb-8ecd-dd371fd5e9a3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6mK77COK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://user-images.githubusercontent.com/42477290/101589413-5d0cb880-3a0e-11eb-8ecd-dd371fd5e9a3.png" alt="image" width="89" height="105"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;/blockquote&gt;


&lt;/blockquote&gt;




&lt;p&gt;The complete code can be found &lt;strong&gt;&lt;a href="https://repl.it/@Androng/CLI-quiz#index.js"&gt;here&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>chalkjs</category>
    </item>
  </channel>
</rss>
