i am dealing the same aswell
basically i made a project where i can stream my computer screen to a part using frames.
my code:
http = game:GetService("HttpService")
function GetPixels()
local message = "request pixels"
http:PostAsync("http://localhost:1111/test", message,Enum.HttpContentType.ApplicationUrlEncoded)
local data = http:GetAsync("http://localhost:1111/test")
return http:JSONDecode(data)
end
function ClearPixels()
for index, pixel in ipairs(game.Workspace.Screen.SurfaceGui:GetChildren()) do
if pixel.Name == "Clone" then
pixel:Destroy()
end
end
end
function MakePixels()
local pixels = {game.Workspace.Screen.SurfaceGui.Frame}
local colors = GetPixels()
local dataIndex = 1
ClearPixels()
for y = 1, 101, 1 do
for x = 1, 100, 1 do
local pixel = pixels[#pixels]:Clone()
pixel.Name = "Clone"
pixel.Parent = game.Workspace.Screen.SurfaceGui
pixel.Position = UDim2.new(pixel.Position.X.Scale + 0.01, 0, pixel.Position.Y.Scale, 0)
pixel.BorderColor3 = Color3.fromRGB(tonumber(colors[dataIndex][1]), tonumber(colors[dataIndex][2]), tonumber(colors[dataIndex][3]))
table.insert(pixels, pixel)
dataIndex += 1
end
local pixel = pixels[#pixels]:Clone()
pixel.Name = "Clone"
pixel.Parent = game.Workspace.Screen.SurfaceGui
pixel.Position = UDim2.new(pixels[1].Position.X.Scale, 0, pixel.Position.Y.Scale + 0.01, 0)
pixel.BorderColor3 = Color3.fromRGB(tonumber(colors[dataIndex][1]), tonumber(colors[dataIndex][2]), tonumber(colors[dataIndex][3]))
table.insert(pixels, pixel)
dataIndex += 1
end
end
while true do
MakePixels()
end
python code:
from flask import Flask, render_template, request
import PIL
import os
import pyautogui
import time
from time import time, sleep
from numba import njit
def f():
l = []
for x in range(10):
for y in range(10):
for z in range (10):
if (z + y + x) / 10 == x:
l.append(x)
print(x)
return l
#idc about first timing
f()
start = time()
for x in range(0):
f()
print(f"fin after {round(time() - start,2)}sec")
def f():
l = []
for x in range(20):
for y in range(10):
for z in range (10):
if (z + y + x) / 10 == x:
l.append(x)
print(x)
return l
#idc about first timing
f()
start = time()
for x in range(0):
f()
print(f"fin after {round(time() - start,2)}sec")
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/test', methods=['POST', 'GET'])
def test():
if request.method == 'GET':
data = str(GetPixelColors())
return data
return render_template('index.html')
def GetPixelColors():
colors = []
screenshot = pyautogui.screenshot()
screenshot.save("ss.png")
img = PIL.Image.open("ss.png")
img = img.resize((101, 102))
img.show
pixels = img.load()
for y in range(102):
for x in range(101):
color = []
color.insert(0, pixels[x, y][0])
color.insert(1, pixels[x, y][1])
color.insert(2, pixels[x, y][2])
colors.insert(len(colors)-1, color)
os.remove("ss.png")
return colors
#print(GetPixelColors())
app.run(host='0.0.0.0',port='1111',debug=False)
appearance:
and the server client:
it uses localhost 1111
(connects to vs code python)
any solution to this?
i can give more information if u like