Python Forum
how to draw vertical line on screen
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to draw vertical line on screen
#1
I try to draw the vertical line on the screen here is my code
import time
import random
import os.path
import socket
import sys
from demo_opts import get_device
from luma.core.virtual import viewport
from luma.core.render import canvas
from PIL import Image
from PIL import ImageDraw
UDP_IP = "0.0.0.0"
UDP_PORT = 7015
sock = socket.socket(socket.AF_INET, #INTERNET
                       socket.SOCK_DGRAM) #UDP
sock.bind((UDP_IP, UDP_PORT))
print ("Start")

def scroll_right(virtual, pos):
    x, y = pos
    if virtual.width > device.width:
        while x < virtual.width - device.width:
	    (data, addr) = sock.recvfrom(1024)  # buffer size
            d = int(data.decode('utf-8'))
            print("message:", d)
            virtual.set_position((x, y))
            x = d * 2.2

    return (x, y)
def main():
    while True:
        img_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
            'images', 'test.png'))
        pixel_art = Image.open(img_path).convert(device.mode)
	draw = ImageDraw.ImageDraw(pixel_art)
        w, h = pixel_art.size
	shape = [(40, 30), (w - 64, h - 64)] 
        virtual = viewport(device, width=w, height=h)
	draw.line(shape , fill="white", width = 0)
        virtual.display(pixel_art)
        pos = (1100, 0)
        pos = scroll_right(virtual, pos)
	

if __name__ == "__main__":
    try:
        device = get_device()
        main()
    except KeyboardInterrupt:
        pass

From the code I import the picture and I scrolling the picture and I want to create the vertical line on the middle of the screen but this line must stay still at the middle of the screen not scrolling with the picture (my screen size 128*128).
Any advice ? Thank You Smile
Reply


Messages In This Thread
how to draw vertical line on screen - by kalihotname - Aug-17-2020, 02:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  wn = turtle.screen() AttributeError: module 'turtle' has no attribute 'screen' Shadower 1 6,231 Feb-06-2019, 01:25 AM
Last Post: woooee
  Vertical Seam Removal scott14 0 1,987 Dec-27-2018, 03:03 AM
Last Post: scott14
  Finding values to draw a line on a curve kesenthilkumar 2 3,586 Sep-19-2017, 09:50 AM
Last Post: kesenthilkumar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020