<?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: prakasha</title>
    <description>The latest articles on DEV Community by prakasha (@gprakasha).</description>
    <link>https://dev.to/gprakasha</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%2F2696213%2F0eb21cb2-b3ef-480e-8209-836589ad1998.jpeg</url>
      <title>DEV Community: prakasha</title>
      <link>https://dev.to/gprakasha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gprakasha"/>
    <language>en</language>
    <item>
      <title>Building a Spin Wheel in React</title>
      <dc:creator>prakasha</dc:creator>
      <pubDate>Sun, 09 Feb 2025 20:51:54 +0000</pubDate>
      <link>https://dev.to/gprakasha/building-a-spin-wheel-in-react-c78</link>
      <guid>https://dev.to/gprakasha/building-a-spin-wheel-in-react-c78</guid>
      <description>&lt;p&gt;Building a spin Wheel was in my to-do list for a very long time; finally, finally i was able to spend time on 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%2F3x9n4xk69gr1p0b7sp5r.gif" 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%2F3x9n4xk69gr1p0b7sp5r.gif" alt="Let's do this" width="480" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Calculate segmentAngle
&lt;/h2&gt;

&lt;p&gt;Let's assume we want to show 6 items in the wheel. &lt;code&gt;const itemsCount = 6;&lt;/code&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%2Fri77sv58arrhfavos3nc.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%2Fri77sv58arrhfavos3nc.png" alt="segment angle" width="800" height="348"&gt;&lt;/a&gt;&lt;br&gt;
Divide the size of the wheel by the number of items =&amp;gt; &lt;code&gt;360/6&lt;/code&gt;.&lt;br&gt;
&lt;code&gt;const segmentAngle = 360 / itemsCount;&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 2: Identifying Radian &amp;amp; width from segmentAngle
&lt;/h2&gt;

&lt;p&gt;You might be thinking, why do we need to identify radians 🧐?&lt;br&gt;
I too had the same question. To find the exact width, we had to identify Radian.&lt;br&gt;
Before even looking into this solution, i had used a random value as 45% 😂&lt;/p&gt;

&lt;p&gt;Formula 1: &lt;code&gt;radians = degrees * (π/180);&lt;/code&gt;&lt;br&gt;
Formula 1: &lt;code&gt;SegmentWidth = 2*radiusOfWheel*sin(segmentAngle)/2)&lt;/code&gt;;&lt;/p&gt;

&lt;p&gt;ref: &lt;a href="https://www.omnicalculator.com/math/chord-length#:~:text=Formula%20based%20on%20the%20central%20angle%3A" rel="noopener noreferrer"&gt;Formula based on the central angle&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;// Assume circle diameter is 300px
const radians = segmentAngle * (3.14 / 180); // 1.0466666666666669
const segmentWidth = 2 * 150 * Math.sin(1.0466666666666669 / 2); // 149.93103079293073
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3: Set Height for segment&lt;br&gt;
Wondering why it cannot be 100%, because if you do, then the UI breaks. 😹&lt;/p&gt;

&lt;p&gt;We had to adjust the height of each segment to fit correctly inside the circle.&lt;br&gt;
To make it look like a pizza slice, adjust &lt;code&gt;height = 50%&lt;/code&gt; and transformY to 50%&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%2F1bjh96vbmqltg9ulvgqp.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%2F1bjh96vbmqltg9ulvgqp.png" alt="partial implementation" width="758" height="806"&gt;&lt;/a&gt;&lt;br&gt;
This is how it will look like now.&lt;/p&gt;

&lt;p&gt;Step 4: Implementing random rotation&lt;br&gt;
Take a random number and multiply it by the segmentAngle to get a random rotation.&lt;br&gt;
And add 5 spins to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const randomSpin = Math.floor(Math.random() * itemsCount) * segmentAngle;
const totalRotation = rotation + (360 * 5) + randomSpin; // 5 full rotations

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

&lt;/div&gt;



&lt;p&gt;Below is my final result!&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/d7ttv9?view=preview&amp;amp;module=%2Fsrc%2FspinWheel.tsx"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>gamechallenge</category>
      <category>gamify</category>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>prakasha</dc:creator>
      <pubDate>Thu, 16 Jan 2025 19:13:54 +0000</pubDate>
      <link>https://dev.to/gprakasha/-39g1</link>
      <guid>https://dev.to/gprakasha/-39g1</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/gprakasha" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F2696213%2F0eb21cb2-b3ef-480e-8209-836589ad1998.jpeg" alt="gprakasha"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/gprakasha/exploring-the-power-of-visualization-from-dependency-graphs-to-molecular-structures-4hkd" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;🚀 Exploring the Power of Visualization: From Dependency Graphs to Molecular Structures 🧬&lt;/h2&gt;
      &lt;h3&gt;prakasha ・ Jan 12&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#rag&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#softwareengineering&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#datascience&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>visualization</category>
      <category>data</category>
      <category>datascience</category>
    </item>
    <item>
      <title>🚀 Exploring the Power of Visualization: From Dependency Graphs to Molecular Structures 🧬</title>
      <dc:creator>prakasha</dc:creator>
      <pubDate>Sun, 12 Jan 2025 15:54:58 +0000</pubDate>
      <link>https://dev.to/gprakasha/exploring-the-power-of-visualization-from-dependency-graphs-to-molecular-structures-4hkd</link>
      <guid>https://dev.to/gprakasha/exploring-the-power-of-visualization-from-dependency-graphs-to-molecular-structures-4hkd</guid>
      <description>&lt;p&gt;Over the past few weeks/months, i have been exploring &lt;a href="https://github.com/rx-angular/import-graph-visualizer" rel="noopener noreferrer"&gt;import-graph-visualizer&lt;/a&gt; for visualizing modules and their dependencies in angular projects, which made me think and fascinated to build something similar but the same concept, like chemical compounds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💡 Why Chemical Compounds and Not Dependencies?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When i was searching for data to render something with cytoscape and render a structure, i came across PubChem.&lt;br&gt;
PubChem provides an amazing API to fetch detailed molecular data, so I thought: Why not visualize molecules first? 🤯&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%2Fobj9y61al374dfqdkux2.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%2Fobj9y61al374dfqdkux2.png" alt="Rendering C17H14O4S structure" width="614" height="873"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🚀 Real Vision ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Started to imagine, software architects or Developers using augmented reality (like Apple Vision) to visually map out their system architecture, wherever they are 🌍. They could easily spot and understand dependencies in their system with a more engaging, almost gamified experience that reduces the learning curve for newer developers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🌟 Current Implementation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Interactive Molecule Visualization: Molecules and their bonds come to life, giving a clear picture of how components are connected.&lt;/li&gt;
&lt;li&gt;Dynamic Data Fetching from PubChem API: Molecule data pulled in real-time.&lt;/li&gt;
&lt;li&gt;Molecular Properties: Displaying key chemical properties like molecular formula, molecular weight, and IUPAC name.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🌟 Next Steps:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Animated Atoms: floating atoms making it more engaging and provide gamified effect.&lt;/li&gt;
&lt;li&gt;Might add on later, (thinking something around 3D visualizations).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🌟 Technologies Used:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React for UI components&lt;/li&gt;
&lt;li&gt;Cytoscape.js for graph-based molecular visualization&lt;/li&gt;
&lt;li&gt;PubChem API for chemical data&lt;/li&gt;
&lt;li&gt;Motion/Threejs for animations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/gprakasha/react-cytoscape-molecules" rel="noopener noreferrer"&gt;https://github.com/gprakasha/react-cytoscape-molecules&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rag</category>
      <category>softwareengineering</category>
      <category>webdev</category>
      <category>datascience</category>
    </item>
  </channel>
</rss>
