<?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: Linas Kapočius</title>
    <description>The latest articles on DEV Community by Linas Kapočius (@dataaichemist).</description>
    <link>https://dev.to/dataaichemist</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%2F1035086%2F56fbe12b-bad7-44e9-b159-547cbf0ff867.jpeg</url>
      <title>DEV Community: Linas Kapočius</title>
      <link>https://dev.to/dataaichemist</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dataaichemist"/>
    <language>en</language>
    <item>
      <title>How can I create a Kivy app with a mouse shader like in p5.js?</title>
      <dc:creator>Linas Kapočius</dc:creator>
      <pubDate>Mon, 27 Feb 2023 20:26:23 +0000</pubDate>
      <link>https://dev.to/dataaichemist/how-can-i-create-a-kivy-app-with-a-mouse-shader-like-in-p5js-4i15</link>
      <guid>https://dev.to/dataaichemist/how-can-i-create-a-kivy-app-with-a-mouse-shader-like-in-p5js-4i15</guid>
      <description>&lt;p&gt;I want to create a Kivy app that displays a real-time mouse shader effect, similar to the one on this OpenProcessing website: &lt;a href="https://openprocessing.org/sketch/835887" rel="noopener noreferrer"&gt;https://openprocessing.org/sketch/835887&lt;/a&gt;. In the p5.js code, the shader uses the position of the mouse.&lt;/p&gt;

&lt;p&gt;So far, I have created mouse cursor trail which changes color every 3 seconds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from kivy.app import App
from kivy.graphics import Color, Line
from kivy.uix.widget import Widget
from kivy.uix.label import Label
from kivy.core.window import Window
from kivy.clock import Clock
from kivy import Config

Config.read("config.ini")

class MyGrid(Widget):
def __init__(self, \*\*kwargs):
super(MyGrid, self).__init__(\*\*kwargs)
self.trail = \[\]
self.color = (1, 0, 0, 0.3)  # set the trail color to red by default
self.label = Label()
self.add_widget(self.label)
Window.bind(mouse_pos=self.mouse_pos)
self.line = Line(points=self.trail, width=20, mode='mesh', blur=10)
self.canvas.add(Color(\*self.color))
self.canvas.add(self.line)
self.color_index = 0
Clock.schedule_interval(self.change_color, 3)

    def on_touch_up(self, touch):
        self.canvas.remove(self.line)
        self.trail = []
        self.line = Line(points=self.trail, width=20, mode='mesh', blur=10)
        self.canvas.add(Color(*self.color))
        self.canvas.add(self.line)

    def mouse_pos(self, window, pos):
        self.trail.append(pos)
        if len(self.trail) &amp;gt; 10:
            self.trail.pop(0)
        self.line.points = self.trail

    def change_color(self, dt):
        self.canvas.remove(self.line)
        colors = [(1, 0, 1, 0.3), (0, 1, 0, 0.3), (1, 1, 0, 0.3), (1, 0.3, 0, 0.3)]
        self.color_index = (self.color_index + 1) % len(colors)
        self.color = colors[self.color_index]
        self.canvas.add(Color(*self.color))
        self.canvas.add(self.line)

class CursorApp(App):
def build(self):

        return MyGrid()

if __name__ == "__main__":
CursorApp().run()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Can someone please provide some guidance on how to implement this effect in Kivy, or suggest some resources that might help me get started?&lt;/p&gt;

</description>
      <category>productivity</category>
    </item>
  </channel>
</rss>
