Reputation: 852
How can I change line color in the kivy Paint app that I have made. I am able to change width of line, but I couldn't find anything for changing color of line.
My code:
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics import Line
class DrawRandom(Widget):
def on_touch_down(self, touch):
with self.canvas:
touch.ud["line"]=Line(points=(touch.x,touch.y),width=5)
def on_touch_move(self, touch):
touch.ud["line"].points += (touch.x, touch.y)
class PaintApp(App):
def build(self):
return DrawRandom()
if __name__ == "__main__":
PaintApp().run()
Upvotes: 1
Views: 1824
Reputation: 5405
You simply add Color to your canvas.
In your imports import Color too.
from kivy.graphics import Line, Color
And in your Painter class add Color to canvas. In this example I try red.
Its rgba values.
def on_touch_down(self, touch):
with self.canvas:
Color(1,0,0,1)
touch.ud["line"] = Line( points = (touch.x, touch.y))
Upvotes: 2