added few stuff
This commit is contained in:
Vendored
BIN
Binary file not shown.
Executable
+22
@@ -0,0 +1,22 @@
|
||||
from selenium import webdriver
|
||||
import time
|
||||
|
||||
url = 'https://protonmail.com/'
|
||||
|
||||
driver = webdriver.Chrome('/Users/olivierpartensky/Programs/Library/Selenium/chromedriver')
|
||||
driver.get(url)
|
||||
driver.find_element_by_xpath('//*[@title="Sign Up"]').click()
|
||||
time.sleep(2)
|
||||
driver.find_element_by_class_name('panel-heading').click()
|
||||
time.sleep(4)
|
||||
driver.find_element_by_id('freePlan').click()
|
||||
time.sleep(2)
|
||||
driver.find_element_by_id('username').send_keys('usernameForUser')
|
||||
time.sleep(1.5)
|
||||
driver.find_element_by_id('password').send_keys('passwordForUser')
|
||||
time.sleep(2)
|
||||
driver.find_element_by_id('passwordc').send_keys('passwordForUser')
|
||||
time.sleep(2)
|
||||
driver.find_element_by_class_name('signUpProcess-btn-create').click()
|
||||
time.sleep(1)
|
||||
driver.find_element_by_id('confirmModalBtn').click()
|
||||
@@ -0,0 +1,6 @@
|
||||
from selenium import webdriver
|
||||
import time
|
||||
|
||||
url="https://protonmail.com"
|
||||
|
||||
driver=webdriver.Chrome( )
|
||||
@@ -0,0 +1,23 @@
|
||||
import smtplib
|
||||
import credentials
|
||||
|
||||
|
||||
def send_email(subject, msg, receiver):
|
||||
try:
|
||||
server=smtplib.SMTP('smtp.gmail.com:587')
|
||||
server.ehlo()
|
||||
server.starttls()
|
||||
server.login(credentials.SENDER, credentials.PASSWORD)
|
||||
message = 'Subject: {}\n\n{}'.format(subject, msg)
|
||||
server.sendmail(credentials.SENDER, receiver, message)
|
||||
server.quit()
|
||||
print("Success: Email sent!")
|
||||
except:
|
||||
print("Email failed to send.")
|
||||
|
||||
|
||||
subject = "Test"
|
||||
msg = "Je pratique le test de l'envoie de mail automatique par python et tu es mon cobaye."
|
||||
receiver="alexandre.bigot@gmail.com"
|
||||
|
||||
send_email(subject, msg, receiver)
|
||||
Binary file not shown.
Executable
+2
@@ -0,0 +1,2 @@
|
||||
SENDER = "marc.gptl444@gmail.com"
|
||||
PASSWORD = "marcgptl44"
|
||||
@@ -0,0 +1,14 @@
|
||||
import os
|
||||
|
||||
def search():
|
||||
output=""
|
||||
for lettre in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
|
||||
print(os.access(lettre + ":\\", os.R_OK))
|
||||
if os.access(lettre + ":\\", os.R_OK):
|
||||
if os.access(lettre + ":\\" + "289571048976325.txt", os.R_OK):
|
||||
output+="Ma clé USB: "+lettre+"\n"
|
||||
if len(output)==0:
|
||||
output="No devices found."
|
||||
return output
|
||||
|
||||
print(search())
|
||||
@@ -0,0 +1,418 @@
|
||||
import pygame, sys, math, random, os
|
||||
import numpy as np
|
||||
import pyspace
|
||||
|
||||
from pyspace.coloring import *
|
||||
from pyspace.fold import *
|
||||
from pyspace.geo import *
|
||||
from pyspace.object import *
|
||||
from pyspace.shader import Shader
|
||||
from pyspace.camera import Camera
|
||||
|
||||
from ctypes import *
|
||||
from OpenGL.GL import *
|
||||
from pygame.locals import *
|
||||
|
||||
import os
|
||||
os.environ['SDL_VIDEO_WINDOW_POS'] = "700,100"
|
||||
|
||||
#Size of the window and rendering
|
||||
win_size = (1280, 720)
|
||||
|
||||
#Maximum frames per second
|
||||
fps = 30
|
||||
|
||||
#Forces an 'up' orientation when True, free-camera when False
|
||||
gimbal_lock = False
|
||||
|
||||
#Mouse look speed
|
||||
look_speed = 0.003
|
||||
|
||||
#Use this avoids collisions with the fractal
|
||||
auto_velocity = True
|
||||
auto_multiplier = 2.0
|
||||
|
||||
#Maximum velocity of the camera
|
||||
max_velocity = 2.0
|
||||
|
||||
#Amount of acceleration when moving
|
||||
speed_accel = 2.0
|
||||
|
||||
#Velocity decay factor when keys are released
|
||||
speed_decel = 0.6
|
||||
|
||||
clicking = False
|
||||
mouse_pos = None
|
||||
screen_center = (win_size[0]/2, win_size[1]/2)
|
||||
start_pos = [0, 0, 12.0]
|
||||
vel = np.zeros((3,), dtype=np.float32)
|
||||
look_x = 0.0
|
||||
look_y = 0.0
|
||||
|
||||
#----------------------------------------------
|
||||
# When building your own fractals, you can
|
||||
# substitute numbers with string placeholders
|
||||
# which can be tuned real-time with key bindings.
|
||||
#
|
||||
# In this example program:
|
||||
# '0' +Insert -Delete
|
||||
# '1' +Home -End
|
||||
# '2' +PageUp -PageDown
|
||||
# '3' +NumPad7 -NumPad4
|
||||
# '4' +NumPad8 -NumPad5
|
||||
# '5' +NumPad9 -NumPad6
|
||||
#
|
||||
# Hold down left-shift to decrease rate 10x
|
||||
# Hold down right-shift to increase rate 10x
|
||||
#
|
||||
# Set initial values of '0' through '6' below
|
||||
#----------------------------------------------
|
||||
keyvars = [1.5, 1.5, 2.0, 1.0, 1.0, 1.0]
|
||||
|
||||
#----------------------------------------------
|
||||
# Fractal Examples Below
|
||||
#----------------------------------------------
|
||||
def infinite_spheres():
|
||||
obj = Object()
|
||||
obj.add(FoldRepeatX(2.0))
|
||||
obj.add(FoldRepeatY(2.0))
|
||||
obj.add(FoldRepeatZ(2.0))
|
||||
obj.add(Sphere(0.5, (1.0, 1.0, 1.0), color=(0.9,0.9,0.5)))
|
||||
return obj
|
||||
|
||||
def butterweed_hills():
|
||||
obj = Object()
|
||||
obj.add(OrbitInitZero())
|
||||
for i in range(30):
|
||||
obj.add(FoldAbs())
|
||||
obj.add(FoldScaleTranslate(1.5, (-1.0,-0.5,-0.2)))
|
||||
obj.add(OrbitSum((0.5, 0.03, 0.0)))
|
||||
obj.add(FoldRotateX(3.61))
|
||||
obj.add(FoldRotateY(2.03))
|
||||
obj.add(Sphere(1.0, color='orbit'))
|
||||
return obj
|
||||
|
||||
def mandelbox():
|
||||
obj = Object()
|
||||
obj.add(OrbitInitInf())
|
||||
for i in range(16):
|
||||
obj.add(FoldBox(1.0))
|
||||
obj.add(FoldSphere(0.5, 1.0))
|
||||
obj.add(FoldScaleOrigin(2.0))
|
||||
obj.add(OrbitMinAbs(1.0))
|
||||
obj.add(Box(6.0, color='orbit'))
|
||||
return obj
|
||||
|
||||
def mausoleum():
|
||||
obj = Object()
|
||||
obj.add(OrbitInitZero())
|
||||
for i in range(8):
|
||||
obj.add(FoldBox(0.34))
|
||||
obj.add(FoldMenger())
|
||||
obj.add(FoldScaleTranslate(3.28, (-5.27,-0.34,0.0)))
|
||||
obj.add(FoldRotateX(math.pi/2))
|
||||
obj.add(OrbitMax((0.42,0.38,0.19)))
|
||||
obj.add(Box(2.0, color='orbit'))
|
||||
return obj
|
||||
|
||||
def menger():
|
||||
obj = Object()
|
||||
for i in range(8):
|
||||
obj.add(FoldAbs())
|
||||
obj.add(FoldMenger())
|
||||
obj.add(FoldScaleTranslate(3.0, (-2,-2,0)))
|
||||
obj.add(FoldPlane((0,0,-1), -1))
|
||||
obj.add(Box(2.0, color=(.2,.5,1)))
|
||||
return obj
|
||||
|
||||
def tree_planet():
|
||||
obj = Object()
|
||||
obj.add(OrbitInitInf())
|
||||
for i in range(30):
|
||||
obj.add(FoldRotateY(0.44))
|
||||
obj.add(FoldAbs())
|
||||
obj.add(FoldMenger())
|
||||
obj.add(OrbitMinAbs((0.24,2.28,7.6)))
|
||||
obj.add(FoldScaleTranslate(1.3, (-2,-4.8,0)))
|
||||
obj.add(FoldPlane((0,0,-1), 0))
|
||||
obj.add(Box(4.8, color='orbit'))
|
||||
return obj
|
||||
|
||||
def sierpinski_tetrahedron():
|
||||
obj = Object()
|
||||
obj.add(OrbitInitZero())
|
||||
for i in range(9):
|
||||
obj.add(FoldSierpinski())
|
||||
obj.add(FoldScaleTranslate(2, -1))
|
||||
obj.add(Tetrahedron(color=(0.8,0.8,0.5)))
|
||||
return obj
|
||||
|
||||
def snow_stadium():
|
||||
obj = Object()
|
||||
obj.add(OrbitInitInf())
|
||||
for i in range(30):
|
||||
obj.add(FoldRotateY(3.33))
|
||||
obj.add(FoldSierpinski())
|
||||
obj.add(FoldRotateX(0.15))
|
||||
obj.add(FoldMenger())
|
||||
obj.add(FoldScaleTranslate(1.57, (-6.61, -4.0, -2.42)))
|
||||
obj.add(OrbitMinAbs(1.0))
|
||||
obj.add(Box(4.8, color='orbit'))
|
||||
return obj
|
||||
|
||||
def test_fractal():
|
||||
obj = Object()
|
||||
obj.add(OrbitInitInf())
|
||||
for i in range(20):
|
||||
obj.add(FoldSierpinski())
|
||||
obj.add(FoldMenger())
|
||||
obj.add(FoldRotateY(math.pi/2))
|
||||
obj.add(FoldAbs())
|
||||
obj.add(FoldRotateZ('0'))
|
||||
obj.add(FoldScaleTranslate(1.89, (-7.10, 0.396, -6.29)))
|
||||
obj.add(OrbitMinAbs((1,1,1)))
|
||||
obj.add(Box(6.0, color='orbit'))
|
||||
return obj
|
||||
|
||||
#----------------------------------------------
|
||||
# Helper Utilities
|
||||
#----------------------------------------------
|
||||
def interp_data(x, f=2.0):
|
||||
new_dim = int(x.shape[0]*f)
|
||||
output = np.empty((new_dim,) + x.shape[1:], dtype=np.float32)
|
||||
for i in range(new_dim):
|
||||
a, b1 = math.modf(float(i) / f)
|
||||
b2 = min(b1 + 1, x.shape[0] - 1)
|
||||
output[i] = x[int(b1)]*(1-a) + x[int(b2)]*a
|
||||
return output
|
||||
|
||||
def make_rot(angle, axis_ix):
|
||||
s = math.sin(angle)
|
||||
c = math.cos(angle)
|
||||
if axis_ix == 0:
|
||||
return np.array([[ 1, 0, 0],
|
||||
[ 0, c, -s],
|
||||
[ 0, s, c]], dtype=np.float32)
|
||||
elif axis_ix == 1:
|
||||
return np.array([[ c, 0, s],
|
||||
[ 0, 1, 0],
|
||||
[-s, 0, c]], dtype=np.float32)
|
||||
elif axis_ix == 2:
|
||||
return np.array([[ c, -s, 0],
|
||||
[ s, c, 0],
|
||||
[ 0, 0, 1]], dtype=np.float32)
|
||||
|
||||
def reorthogonalize(mat):
|
||||
u, s, v = np.linalg.svd(mat)
|
||||
return np.dot(u, v)
|
||||
|
||||
#--------------------------------------------------
|
||||
# Video Recording
|
||||
#
|
||||
# When you're ready to record a video, press 'r'
|
||||
# to start recording, and then move around. The
|
||||
# camera's path and live '0' through '5' parameters
|
||||
# are recorded to a file. Press 'r' when finished.
|
||||
#
|
||||
# Now you can exit the program and turn up the
|
||||
# camera parameters for better rendering. For
|
||||
# example; window size, anti-aliasing, motion blur,
|
||||
# and depth of field are great options.
|
||||
#
|
||||
# When you're ready to playback and render, press
|
||||
# 'p' and the recorded movements are played back.
|
||||
# Images are saved to a './playback' folder. You
|
||||
# can import the image sequence to editing software
|
||||
# to convert it to a video.
|
||||
#
|
||||
# You can press 's' anytime for a screenshot.
|
||||
#---------------------------------------------------
|
||||
|
||||
if __name__ == '__main__':
|
||||
pygame.init()
|
||||
window = pygame.display.set_mode(win_size, OPENGL | DOUBLEBUF)
|
||||
pygame.mouse.set_visible(False)
|
||||
pygame.mouse.set_pos(screen_center)
|
||||
|
||||
#======================================================
|
||||
# Change the fractal here
|
||||
#======================================================
|
||||
obj_render = tree_planet()
|
||||
#======================================================
|
||||
|
||||
#======================================================
|
||||
# Change camera settings here
|
||||
# See pyspace/camera.py for all camera options
|
||||
#======================================================
|
||||
camera = Camera()
|
||||
camera['ANTIALIASING_SAMPLES'] = 1
|
||||
camera['AMBIENT_OCCLUSION_STRENGTH'] = 0.01
|
||||
#======================================================
|
||||
|
||||
shader = Shader(obj_render)
|
||||
program = shader.compile(camera)
|
||||
print("Compiled!")
|
||||
|
||||
matID = glGetUniformLocation(program, "iMat");
|
||||
prevMatID = glGetUniformLocation(program, "iPrevMat");
|
||||
resID = glGetUniformLocation(program, "iResolution");
|
||||
ipdID = glGetUniformLocation(program, "iIPD");
|
||||
|
||||
glUseProgram(program)
|
||||
glUniform2fv(resID, 1, win_size)
|
||||
glUniform1f(ipdID, 0.04)
|
||||
|
||||
mat = np.identity(4, np.float32)
|
||||
mat[3,:3] = np.array(start_pos)
|
||||
prevMat = np.copy(mat)
|
||||
for i in range(len(keyvars)):
|
||||
shader.set(str(i), keyvars[i])
|
||||
|
||||
recording = None
|
||||
rec_vars = None
|
||||
playback = None
|
||||
playback_vars = None
|
||||
playback_ix = -1
|
||||
frame_num = 0
|
||||
|
||||
def start_playback():
|
||||
global playback
|
||||
global playback_vars
|
||||
global playback_ix
|
||||
global prevMat
|
||||
if not os.path.exists('playback'):
|
||||
os.makedirs('playback')
|
||||
playback = np.load('recording.npy')
|
||||
playback_vars = np.load('rec_vars.npy')
|
||||
playback = interp_data(playback, 2)
|
||||
playback_vars = interp_data(playback_vars, 2)
|
||||
playback_ix = 0
|
||||
prevMat = playback[0]
|
||||
|
||||
clock = pygame.time.Clock()
|
||||
while True:
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
sys.exit(0)
|
||||
elif event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_r:
|
||||
if recording is None:
|
||||
print("Recording...")
|
||||
recording = []
|
||||
rec_vars = []
|
||||
else:
|
||||
np.save('recording.npy', np.array(recording, dtype=np.float32))
|
||||
np.save('rec_vars.npy', np.array(rec_vars, dtype=np.float32))
|
||||
recording = None
|
||||
rec_vars = None
|
||||
print("Finished Recording.")
|
||||
elif event.key == pygame.K_p:
|
||||
start_playback()
|
||||
elif event.key == pygame.K_s:
|
||||
pygame.image.save(window, 'screenshot.png')
|
||||
elif event.key == pygame.K_ESCAPE:
|
||||
sys.exit(0)
|
||||
|
||||
mat[3,:3] += vel / fps
|
||||
|
||||
if auto_velocity:
|
||||
de = obj_render.DE(mat[3]) * auto_multiplier
|
||||
if not np.isfinite(de):
|
||||
de = 0.0
|
||||
else:
|
||||
de = 1e20
|
||||
|
||||
all_keys = pygame.key.get_pressed()
|
||||
|
||||
rate = 0.01
|
||||
if all_keys[pygame.K_LSHIFT]: rate *= 0.1
|
||||
elif all_keys[pygame.K_RSHIFT]: rate *= 10.0
|
||||
|
||||
if all_keys[pygame.K_INSERT]: keyvars[0] += rate; print(keyvars)
|
||||
if all_keys[pygame.K_DELETE]: keyvars[0] -= rate; print(keyvars)
|
||||
if all_keys[pygame.K_HOME]: keyvars[1] += rate; print(keyvars)
|
||||
if all_keys[pygame.K_END]: keyvars[1] -= rate; print(keyvars)
|
||||
if all_keys[pygame.K_PAGEUP]: keyvars[2] += rate; print(keyvars)
|
||||
if all_keys[pygame.K_PAGEDOWN]: keyvars[2] -= rate; print(keyvars)
|
||||
if all_keys[pygame.K_KP7]: keyvars[3] += rate; print(keyvars)
|
||||
if all_keys[pygame.K_KP4]: keyvars[3] -= rate; print(keyvars)
|
||||
if all_keys[pygame.K_KP8]: keyvars[4] += rate; print(keyvars)
|
||||
if all_keys[pygame.K_KP5]: keyvars[4] -= rate; print(keyvars)
|
||||
if all_keys[pygame.K_KP9]: keyvars[5] += rate; print(keyvars)
|
||||
if all_keys[pygame.K_KP6]: keyvars[5] -= rate; print(keyvars)
|
||||
|
||||
if playback is None:
|
||||
prev_mouse_pos = mouse_pos
|
||||
mouse_pos = pygame.mouse.get_pos()
|
||||
dx,dy = 0,0
|
||||
if prev_mouse_pos is not None:
|
||||
pygame.mouse.set_pos(screen_center)
|
||||
dx = mouse_pos[0] - screen_center[0]
|
||||
dy = mouse_pos[1] - screen_center[1]
|
||||
|
||||
if gimbal_lock:
|
||||
look_x += dx * look_speed
|
||||
look_y += dy * look_speed
|
||||
look_y = min(max(look_y, -math.pi/2), math.pi/2)
|
||||
|
||||
rx = make_rot(look_x, 1)
|
||||
ry = make_rot(look_y, 0)
|
||||
|
||||
mat[:3,:3] = np.dot(ry, rx)
|
||||
else:
|
||||
rx = make_rot(dx * look_speed, 1)
|
||||
ry = make_rot(dy * look_speed, 0)
|
||||
|
||||
mat[:3,:3] = np.dot(ry, np.dot(rx, mat[:3,:3]))
|
||||
mat[:3,:3] = reorthogonalize(mat[:3,:3])
|
||||
|
||||
acc = np.zeros((3,), dtype=np.float32)
|
||||
if all_keys[pygame.K_LEFT]:
|
||||
acc[0] -= speed_accel / fps
|
||||
if all_keys[pygame.K_RIGHT]:
|
||||
acc[0] += speed_accel / fps
|
||||
if all_keys[pygame.K_UP]:
|
||||
acc[2] -= speed_accel / fps
|
||||
if all_keys[pygame.K_DOWN]:
|
||||
acc[2] += speed_accel / fps
|
||||
|
||||
if np.dot(acc, acc) == 0.0:
|
||||
vel *= speed_decel
|
||||
else:
|
||||
vel += np.dot(mat[:3,:3].T, acc)
|
||||
vel_ratio = min(max_velocity, de) / (np.linalg.norm(vel) + 1e-12)
|
||||
if vel_ratio < 1.0:
|
||||
vel *= vel_ratio
|
||||
if all_keys[pygame.K_SPACE]:
|
||||
vel *= 10.0
|
||||
|
||||
if recording is not None:
|
||||
recording.append(np.copy(mat))
|
||||
rec_vars.append(np.array(keyvars, dtype=np.float32))
|
||||
else:
|
||||
if playback_ix >= 0:
|
||||
ix_str = '%04d' % playback_ix
|
||||
pygame.image.save(window, 'playback/frame' + ix_str + '.png')
|
||||
if playback_ix >= playback.shape[0]:
|
||||
playback = None
|
||||
break
|
||||
else:
|
||||
mat = prevMat * 0.98 + playback[playback_ix] * 0.02
|
||||
mat[:3,:3] = reorthogonalize(mat[:3,:3])
|
||||
keyvars = playback_vars[playback_ix].tolist()
|
||||
playback_ix += 1
|
||||
|
||||
for i in range(3):
|
||||
shader.set(str(i), keyvars[i])
|
||||
shader.set('v', np.array(keyvars[3:6]))
|
||||
shader.set('pos', mat[3,:3])
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
||||
glUniformMatrix4fv(matID, 1, False, mat);
|
||||
glUniformMatrix4fv(prevMatID, 1, False, prevMat);
|
||||
prevMat = np.copy(mat)
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
pygame.display.flip()
|
||||
clock.tick(fps)
|
||||
frame_num += 1
|
||||
@@ -0,0 +1,58 @@
|
||||
|
||||
|
||||
"""
|
||||
class Hanoi:
|
||||
def __init__(self,tower1,tower2,tower3):
|
||||
self.tower1=tower1
|
||||
self.tower2=tower2
|
||||
self.tower3=tower3
|
||||
self.moveTower(10,tower1,tower2,tower3)
|
||||
|
||||
def moveTower(height,fromPole, toPole, withPole):
|
||||
if height >= 1:
|
||||
self.moveTower(height-1,fromPole,withPole,toPole)
|
||||
self.moveDisk(fromPole,toPole)
|
||||
self.moveTower(height-1,withPole,toPole,fromPole)
|
||||
|
||||
def moveDisk(fp,tp):
|
||||
print("before moving disk from",fp,"to",tp)
|
||||
tp=[fp[0]]+tp
|
||||
del fp[0]
|
||||
print("after moving disk from",fp,"to",tp)
|
||||
self
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
tower1=[x for x in range(10)]
|
||||
tower2=[]
|
||||
tower3=[]
|
||||
hanoi=Hanoi()
|
||||
|
||||
print(hanoi.tower1)
|
||||
print(hanoi.tower2)
|
||||
print(hanoi.tower3)
|
||||
"""
|
||||
|
||||
|
||||
number_of_disks=4
|
||||
|
||||
tower1=[x for x in range(number_of_disks)]
|
||||
tower2=[]
|
||||
tower3=[]
|
||||
|
||||
def moveTower(height,fromPole, toPole, withPole):
|
||||
if height >= 1:
|
||||
moveTower(height-1,fromPole,withPole,toPole)
|
||||
moveDisk(fromPole,toPole)
|
||||
moveTower(height-1,withPole,toPole,fromPole)
|
||||
|
||||
def moveDisk(fp,tp):
|
||||
print("moving disk from",fp,"to",tp)
|
||||
tp.reverse()
|
||||
tp.append(fp[0])
|
||||
tp.reverse()
|
||||
del fp[0]
|
||||
|
||||
moveTower(number_of_disks,tower1,tower2,tower3)
|
||||
|
||||
print(tower1,tower2,tower3)
|
||||
@@ -0,0 +1,30 @@
|
||||
import json
|
||||
|
||||
a=dict()
|
||||
a["chat"]=True
|
||||
a["chien"]=False
|
||||
a["combien"]=2
|
||||
|
||||
b=json.dumps(a)
|
||||
print(a)
|
||||
print(b)
|
||||
|
||||
c=json.loads(b)
|
||||
|
||||
print(c)
|
||||
|
||||
|
||||
print(json.dumps(c,indent=2))
|
||||
|
||||
with open("test.json","w") as file:
|
||||
json.dump(b,file)
|
||||
|
||||
|
||||
with open("test.json","r") as file:
|
||||
d=json.load(file)
|
||||
|
||||
print(d)
|
||||
|
||||
e=json.loads(d)
|
||||
|
||||
print(e)
|
||||
@@ -0,0 +1 @@
|
||||
"{\"chat\": true, \"chien\": false, \"combien\": 2}"
|
||||
@@ -0,0 +1,103 @@
|
||||
import matplotlib.pyplot as plt
|
||||
#from random import randint as rdt
|
||||
import csv
|
||||
import numpy as np
|
||||
|
||||
|
||||
"""
|
||||
x=[1,2,3]
|
||||
y=[5,7,4]
|
||||
|
||||
x2=[1,2,3]
|
||||
y2=[10,14,12]
|
||||
|
||||
plt.plot(x,y,label="First Line")
|
||||
plt.plot(x2,y2,label="Second Line")
|
||||
plt.xlabel("Plot Number")
|
||||
plt.ylabel("Important var")
|
||||
plt.title("Interesting graph\nCheck it out!")
|
||||
plt.legend()
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
x=[2,4,6,8,10]
|
||||
y=[6,7,8,9,10]
|
||||
|
||||
x2=[1,3,5,6,0]
|
||||
y2=[6,3,8,3,10]
|
||||
|
||||
population_ages=[20+rdt(0,50) for i in range(20)]
|
||||
ids=range(len(population_ages))
|
||||
|
||||
bins=[10*x for x in ids]
|
||||
|
||||
|
||||
plt.bar(ids,population_ages)
|
||||
plt.bar(x,y,label="Bars1",color="blue")
|
||||
plt.bar(x2,y2,label="Bars2",color="c")
|
||||
plt.hist(population_ages,bins,histtype="bar",rwidth=0.8)
|
||||
|
||||
|
||||
|
||||
x=[2,4,6,8,10]
|
||||
y=[6,7,8,9,10]
|
||||
|
||||
days=[1,2,3,4,5]
|
||||
sleeping=[7,6,6,11,7]
|
||||
eating=[2,3,4,3,2]
|
||||
working=[5,3,5,6,2]
|
||||
playing=[6,4,7,3,9]
|
||||
|
||||
#plt.scatter(x,y,label="skitcat",color="k",marker="x",s=100)
|
||||
|
||||
plt.plot([],[],color="m",label="Sleeping")
|
||||
plt.plot([],[],color="c",label="Eating")
|
||||
plt.plot([],[],color="r",label="Working")
|
||||
plt.plot([],[],color="k",label="Playing")
|
||||
|
||||
plt.stackplot(days,sleeping,eating,working,playing,colors=["m","c","r","k"])
|
||||
|
||||
|
||||
|
||||
slices=[7,4,2,13]
|
||||
activities=["sleeping","eating","working","playing"]
|
||||
cols=["c","m","r","k"]
|
||||
|
||||
plt.pie(slices,labels=activities,colors=cols,startangle=90,shadow=True,explode=[0,0,0.1,0],autopct="%1.1f%%")
|
||||
|
||||
|
||||
#Part 1
|
||||
|
||||
x=[]
|
||||
y=[]
|
||||
|
||||
with open("text.txt","r") as csvfile:
|
||||
plots=csv.reader(csvfile,delimiter=",")
|
||||
for row in plots:
|
||||
x.append(int(row[0]))
|
||||
y.append(int(row[1]))
|
||||
|
||||
plt.plot(x,y,label="loaded from file")
|
||||
|
||||
|
||||
#Part 2
|
||||
|
||||
x,y=np.loadtxt("text.txt",delimiter=",",unpack=True)
|
||||
|
||||
plt.plot(x,y,label="loaded from file")
|
||||
"""
|
||||
|
||||
|
||||
|
||||
def graph_data(stock):
|
||||
|
||||
stock_price_url = 'https://pythonprogramming.net/yahoo_finance_replacement'
|
||||
|
||||
plt.xlabel("x")
|
||||
plt.ylabel("y")
|
||||
plt.title("Interesting graph\nCheck it out!")
|
||||
plt.legend()
|
||||
plt.show()
|
||||
|
||||
graph_data("TSLA")
|
||||
@@ -0,0 +1,6 @@
|
||||
1,2
|
||||
4,5
|
||||
2,5
|
||||
1,3
|
||||
6,4
|
||||
7,3
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 270 B |
Binary file not shown.
|
After Width: | Height: | Size: 405 B |
Binary file not shown.
|
After Width: | Height: | Size: 665 B |
@@ -0,0 +1,125 @@
|
||||
from pyglet.gl import *
|
||||
from pyglet.window import key
|
||||
import math
|
||||
|
||||
|
||||
class Model:
|
||||
|
||||
def get_tex(self,file):
|
||||
tex = pyglet.image.load(file).texture
|
||||
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST)
|
||||
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST)
|
||||
return pyglet.graphics.TextureGroup(tex)
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.top = self.get_tex('grass_top.png')
|
||||
self.side = self.get_tex('grass_side.png')
|
||||
self.bottom = self.get_tex('dirt.png')
|
||||
|
||||
self.batch = pyglet.graphics.Batch()
|
||||
|
||||
tex_coords = ('t2f',(0,0, 1,0, 1,1, 0,1, ))
|
||||
|
||||
|
||||
for zi in range(-10,10):
|
||||
for yi in range(-10,10):
|
||||
for xi in range(-10,10):
|
||||
x,y,z = xi,yi,zi-1
|
||||
X,Y,Z = x+1,y+1,z+1
|
||||
|
||||
self.batch.add(4,GL_QUADS,self.side,('v3f',(x,y,z, x,y,Z, x,Y,Z, x,Y,z, )),tex_coords)
|
||||
self.batch.add(4,GL_QUADS,self.side,('v3f',(X,y,Z, X,y,z, X,Y,z, X,Y,Z, )),tex_coords)
|
||||
self.batch.add(4,GL_QUADS,self.bottom,('v3f',(x,y,z, X,y,z, X,y,Z, x,y,Z, )),tex_coords)
|
||||
self.batch.add(4,GL_QUADS,self.top,('v3f',(x,Y,Z, X,Y,Z, X,Y,z, x,Y,z, )),tex_coords)
|
||||
self.batch.add(4,GL_QUADS,self.side,('v3f',(X,y,z, x,y,z, x,Y,z, X,Y,z, )),tex_coords)
|
||||
self.batch.add(4,GL_QUADS,self.side,('v3f',(x,y,Z, X,y,Z, X,Y,Z, x,Y,Z, )),tex_coords)
|
||||
|
||||
yi=-10
|
||||
for zi in range(-100,100):
|
||||
for xi in range(-100,100):
|
||||
x,y,z = xi,yi,zi-1
|
||||
X,Y,Z = x+1,y+1,z+1
|
||||
|
||||
self.batch.add(4,GL_QUADS,self.side,('v3f',(x,y,z, x,y,Z, x,Y,Z, x,Y,z, )),tex_coords)
|
||||
self.batch.add(4,GL_QUADS,self.side,('v3f',(X,y,Z, X,y,z, X,Y,z, X,Y,Z, )),tex_coords)
|
||||
self.batch.add(4,GL_QUADS,self.bottom,('v3f',(x,y,z, X,y,z, X,y,Z, x,y,Z, )),tex_coords)
|
||||
self.batch.add(4,GL_QUADS,self.top,('v3f',(x,Y,Z, X,Y,Z, X,Y,z, x,Y,z, )),tex_coords)
|
||||
self.batch.add(4,GL_QUADS,self.side,('v3f',(X,y,z, x,y,z, x,Y,z, X,Y,z, )),tex_coords)
|
||||
self.batch.add(4,GL_QUADS,self.side,('v3f',(x,y,Z, X,y,Z, X,Y,Z, x,Y,Z, )),tex_coords)
|
||||
|
||||
|
||||
def draw(self):
|
||||
self.batch.draw()
|
||||
|
||||
|
||||
|
||||
class Player:
|
||||
def __init__(self,pos=(0,0,0),rot=(0,0)):
|
||||
self.pos = list(pos)
|
||||
self.rot = list(rot)
|
||||
|
||||
def mouse_motion(self,dx,dy):
|
||||
dx/=8; dy/=8; self.rot[0]+=dy; self.rot[1]-=dx
|
||||
if self.rot[0]>90: self.rot[0] = 90
|
||||
elif self.rot[0]<-90: self.rot[0] = -90
|
||||
|
||||
def update(self,dt,keys):
|
||||
s = dt*10
|
||||
rotY = -self.rot[1]/180*math.pi
|
||||
dx,dz = s*math.sin(rotY),s*math.cos(rotY)
|
||||
if keys[key.W]: self.pos[0]+=dx; self.pos[2]-=dz
|
||||
if keys[key.S]: self.pos[0]-=dx; self.pos[2]+=dz
|
||||
if keys[key.A]: self.pos[0]-=dz; self.pos[2]-=dx
|
||||
if keys[key.D]: self.pos[0]+=dz; self.pos[2]+=dx
|
||||
|
||||
if keys[key.SPACE]: self.pos[1]+=s
|
||||
if keys[key.LSHIFT]: self.pos[1]-=s
|
||||
|
||||
|
||||
class Window(pyglet.window.Window):
|
||||
|
||||
def push(self,pos,rot): glPushMatrix(); glRotatef(-rot[0],1,0,0); glRotatef(-rot[1],0,1,0); glTranslatef(-pos[0],-pos[1],-pos[2],)
|
||||
def Projection(self): glMatrixMode(GL_PROJECTION); glLoadIdentity()
|
||||
def Model(self): glMatrixMode(GL_MODELVIEW); glLoadIdentity()
|
||||
def set2d(self): self.Projection(); gluOrtho2D(0,self.width,0,self.height); self.Model()
|
||||
def set3d(self): self.Projection(); gluPerspective(70,self.width/self.height,0.05,1000); self.Model()
|
||||
|
||||
def setLock(self,state): self.lock = state; self.set_exclusive_mouse(state)
|
||||
lock = False; mouse_lock = property(lambda self:self.lock,setLock)
|
||||
|
||||
def __init__(self,*args,**kwargs):
|
||||
super().__init__(*args,**kwargs)
|
||||
self.set_minimum_size(300,200)
|
||||
self.keys = key.KeyStateHandler()
|
||||
self.push_handlers(self.keys)
|
||||
pyglet.clock.schedule(self.update)
|
||||
|
||||
self.model = Model()
|
||||
self.player = Player((0.5,1.5,1.5),(-30,0))
|
||||
|
||||
def on_mouse_motion(self,x,y,dx,dy):
|
||||
if self.mouse_lock: self.player.mouse_motion(dx,dy)
|
||||
|
||||
def on_key_press(self,KEY,MOD):
|
||||
if KEY == key.ESCAPE: self.close()
|
||||
#elif KEY == key.E: self.mouse_lock = not self.mouse_lock
|
||||
self.mouse_lock=True
|
||||
|
||||
def update(self,dt):
|
||||
self.player.update(dt,self.keys)
|
||||
|
||||
def on_draw(self):
|
||||
self.clear()
|
||||
self.set3d()
|
||||
self.push(self.player.pos,self.player.rot)
|
||||
self.model.draw()
|
||||
glPopMatrix()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
window = Window(width=1440,height=900,caption='Minecraft',fullscreen=True)
|
||||
glClearColor(0.5,0.7,1,1)
|
||||
glEnable(GL_DEPTH_TEST)
|
||||
#glEnable(GL_CULL_FACE)
|
||||
pyglet.app.run()
|
||||
@@ -0,0 +1,85 @@
|
||||
import numpy as np
|
||||
|
||||
picture=np.random.randn(28,28)
|
||||
|
||||
class NeuralNetwork:
|
||||
def __init__(self,sizes=[784,784,28,10]):
|
||||
"""Create a neural network using list of sizes."""
|
||||
self.sizes=sizes
|
||||
self.biases=[np.random.randn(y) for y in sizes[1:]]
|
||||
self.weights=[np.random.randn(x,y) for x,y in zip(sizes[:-1],sizes[1:])]
|
||||
#self.function=lamba x:1/(1+np.exp(-x))
|
||||
|
||||
def evaluate(self,test_data):
|
||||
"""Return number of successful predictions using test_datas list."""
|
||||
results=[(np.argmax(self.predict(x)),y]) for (x,y) in test_data]
|
||||
return sum(int(x==y) for (x,y) in results])
|
||||
|
||||
def predict(self,input):
|
||||
"""Return predictions for given input."""
|
||||
input=np.reshape(input,(1,self.sizes[0]))[0]
|
||||
for weight,bias in zip(self.weights,self.biases):
|
||||
input=self.sigmoid(np.dot(input,weight)+bias)
|
||||
return input
|
||||
|
||||
def train(self,training_data,learning_rate=0.1,mini_batch_size=10,epochs=10,test_data=None):
|
||||
"""Train neural network using training_data and optionnal parameters such as learning rate,
|
||||
mini_batch_size, epochs and test_data."""
|
||||
for epoch in range(epochs):
|
||||
random.shuffle(training_data)
|
||||
mini_batches=[training_data[k:k+10] for k in range(0,len(training_data)//10,mini_batch_size)]
|
||||
for mini_batch in mini_batches:
|
||||
self.learn(mini_batch,learning_rate)
|
||||
print("Epochs completed:",epoch,"/",epochs)
|
||||
if test_data:
|
||||
print("Results:",self.evaluate(test_data),"/",len(test_data))
|
||||
|
||||
def learn(self,mini_batch,learning_rate):
|
||||
"""Train neural network using minibatch and learning_rate."""
|
||||
l=learning_rate
|
||||
weights_errors = [np.zeros(weight.shape) for weight in self.weights]
|
||||
biases_error = [np.zeros(bias.shape) for bias in self.biases]
|
||||
for input,output in mini_batch:
|
||||
biases_columns,weights_columns=self.backpropagation(input,output)
|
||||
weights_errors = [error+column for (error,column) in zip(weights_errors,weights_columns)]
|
||||
biases_errors = [error+column for (error,column) in zip(biases_errors,biases_columns)]
|
||||
self.weights=[w-l*e for (w,e) in zip(self.weights,weights_errors)]
|
||||
self.weights=[b-l*e for (b,e) in zip(self.biases,biases_errors)]
|
||||
|
||||
|
||||
def backpropagation(self,x,y):
|
||||
"""Return tuple of weights_errors and biases in columns."""
|
||||
weights_errors = [np.zeros(weight.shape) for weight in self.weights]
|
||||
biases_error = [np.zeros(bias.shape) for bias in self.biases]
|
||||
|
||||
activations=[x]
|
||||
weighted=[]
|
||||
for (w,b) in zip(self.weights,self.biases):
|
||||
z=np.dot(x,w)+b
|
||||
weighted.append(z)
|
||||
x=sigmoid(z)
|
||||
activations.append(x)
|
||||
|
||||
|
||||
|
||||
return dB,dW
|
||||
|
||||
def opposite_sigmoid(self,x): #overly complicated
|
||||
return -np.log(abs((x-1)/x))
|
||||
|
||||
def sigmoid(self,x):
|
||||
return 1/(1+np.exp(-x))
|
||||
|
||||
def derivative_sigmoid(self,x):
|
||||
a=self.sigmoid(x)
|
||||
return a(1-a)
|
||||
|
||||
def cost(self,input,output):
|
||||
prediction=self.predict(input)
|
||||
l=len(predictions)
|
||||
return sum([(output[i]-prediction[i])**2] for i in range(l))
|
||||
|
||||
if __name__=="__main__":
|
||||
nn=NeuralNetwork()
|
||||
print(nn.__dict__)
|
||||
print(nn.run(picture))
|
||||
@@ -0,0 +1,9 @@
|
||||
class human:
|
||||
def __init__(self,nom):
|
||||
self.pieds=2
|
||||
self.nom=nom
|
||||
def marcher(self):
|
||||
print("Yes je marche avec mes "+self.nom+" pieds")
|
||||
|
||||
valentin=human("valentin")
|
||||
valentin.marcher()
|
||||
@@ -0,0 +1,78 @@
|
||||
from pyglet.gl import *
|
||||
|
||||
class Model:
|
||||
def get_tex(self,file):
|
||||
tex=pyglet.image.load(file).texture
|
||||
glTexParameterf(Gl_TEXTURE_2D,L_TEXTURE_MIN_FILTER,GL_NEAREST)
|
||||
glTexParameterf(Gl_TEXTURE_2D,L_TEXTURE_MIN_FILTER,GL_NEAREST)
|
||||
return pyglet.graphics.TextureGroup(tex)
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.top=self.get_tex("grass_top.png")
|
||||
self.size=self.get_tex("grass_side.png")
|
||||
self.bottom=self.get_tex("dirt.png")
|
||||
|
||||
self.batch=pyglet.graphics.Batch()
|
||||
|
||||
tex_coords=("t3f",(0,0,1,0,1,1,0,1))
|
||||
|
||||
x,y,z=0,0,0
|
||||
X,Y,Z=x+1,y+1,z+1
|
||||
|
||||
self.batch.add(4,GL_SQUADS,None,("v3f",(x,y,z,X,y,z,X,Y,z,x,Y,z)))
|
||||
|
||||
def draw(self):
|
||||
self.batch.draw()
|
||||
|
||||
class Player:
|
||||
def __inint__(self):
|
||||
pass
|
||||
|
||||
def update(self,dt,keys):
|
||||
if keys[key.A]: print("a")
|
||||
|
||||
class Window(pyglet.window.Window):
|
||||
def __init__(self,*args,**kwargs):
|
||||
super().__init__(*args,**kwargs)
|
||||
self.set_minimum_size(300,200)
|
||||
|
||||
self.model=Model()
|
||||
|
||||
def Projection(self):
|
||||
glMatrixMode(GL_PROJECTION)
|
||||
glLoadIdentity()
|
||||
|
||||
def Model(self):
|
||||
glMatrixMode(GL_MODELVIEW):
|
||||
glLoadIdentity()
|
||||
|
||||
def set2d(self):
|
||||
gluOrthod
|
||||
self.Projection()
|
||||
self.
|
||||
|
||||
|
||||
def set3d(self):
|
||||
self.Projection()
|
||||
#persperctive
|
||||
self.Model()
|
||||
|
||||
def on_draw(self):
|
||||
self.clear()
|
||||
self.set3d()
|
||||
self.Rotate()
|
||||
self.model.draw()
|
||||
|
||||
def on_key_press(self,KEY,MOD):
|
||||
if KEY==key.ESCAPE: self.close()
|
||||
elif KEY==key.SPACE: self.mouse_lock= not self.mouse.lock
|
||||
|
||||
def update(self,dt):
|
||||
self.player.update(dt,)
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
window=Window(width=400,height=300,caption="Awesome Game",resizable=True)
|
||||
glClearColor(0.5,0.7,1,1)
|
||||
pyglet.app.run()
|
||||
@@ -0,0 +1,16 @@
|
||||
import numpy as np
|
||||
import cv2
|
||||
from mss import mss
|
||||
from PIL import Image
|
||||
|
||||
mon = {'top': 160, 'left': 160, 'width': 200, 'height': 200}
|
||||
|
||||
sct = mss()
|
||||
|
||||
while 1:
|
||||
sct.get_pixels(mon)
|
||||
img = Image.frombytes('RGB', (sct.width, sct.height), sct.image)
|
||||
cv2.imshow('test', np.array(img))
|
||||
if cv2.waitKey(25) & 0xFF == ord('q'):
|
||||
cv2.destroyAllWindows()
|
||||
breakf
|
||||
Vendored
BIN
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,211 @@
|
||||
#-------#
|
||||
#Credits#
|
||||
#-------#
|
||||
|
||||
__author__="Marc Partensky"
|
||||
__license__="Marc Partensky Company"
|
||||
__title__="Grapher"
|
||||
|
||||
"""This program needs pygame to be run."""
|
||||
|
||||
#------------#
|
||||
#Dependencies#
|
||||
#------------#
|
||||
|
||||
from mycolors import *
|
||||
from mywindow import *
|
||||
from mymoves import *
|
||||
from mycontrols import *
|
||||
|
||||
|
||||
import math
|
||||
import random
|
||||
import numpy as np
|
||||
import noise
|
||||
|
||||
#-------#
|
||||
#Classes#
|
||||
#-------#
|
||||
|
||||
class Graph:
|
||||
def __init__(self,function,color=RED):
|
||||
self.function=function
|
||||
self.color=color
|
||||
self.dots=[]
|
||||
self.precision=1
|
||||
|
||||
def trace(self,plan,window):
|
||||
self.dots=[]
|
||||
zx,zy=plan.zoom
|
||||
ux,uy=plan.units
|
||||
mx,my=plan.middle
|
||||
px,py=plan.point
|
||||
wsx,wsy=window.size
|
||||
tx,ty=(wsx//2,wsy//2)
|
||||
for X in range(0,wsx,self.precision):
|
||||
x=((X-tx)/zx+mx)/ux
|
||||
y=eval(self.function)
|
||||
Y=(ty-(y*uy+my)*zy)
|
||||
if 0<=X<wsx and 0<=Y<wsy:
|
||||
self.dots.append((X,Y))
|
||||
|
||||
def draw(self,plan,window):
|
||||
self.trace(plan,window)
|
||||
for i in range(len(self.dots)-1):
|
||||
start=self.dots[i]
|
||||
end=self.dots[i+1]
|
||||
pygame.draw.line(window.screen, self.color, start, end, 1)
|
||||
|
||||
|
||||
class Plan:
|
||||
def __init__(self,background=WHITE,axis_color=BLACK,grid_color=DARKGREY):
|
||||
self.background=background
|
||||
self.axis_color=axis_color
|
||||
self.grid_color=grid_color
|
||||
self.graphs=[]
|
||||
self.default_middle=self.middle=[0,0]
|
||||
self.default_point=self.point=[0,0]
|
||||
self.default_units=self.units=[50,50]
|
||||
self.velocity=[1,1]
|
||||
self.acceleration=[0,0]
|
||||
self.action=[10,10]
|
||||
self.friction=[2,2]
|
||||
self.zoom=[1.,1.]
|
||||
|
||||
def addGraph(self,graph):
|
||||
self.graphs.append(graph)
|
||||
|
||||
def draw(self,window):
|
||||
window.screen.fill(self.background)
|
||||
wsx,wsy=window.size
|
||||
translation=[wsx//2,wsy//2]
|
||||
self.drawAxis(window)
|
||||
for i,graph in enumerate(self.graphs):
|
||||
graph.draw(self,window)
|
||||
position=[wsx-200,wsy-(2+i)*30]
|
||||
window.showText(graph.function,position,graph.color,"monospace",20)
|
||||
|
||||
def drawAxis(self,window):
|
||||
wsx,wsy=window.size
|
||||
ux,uy=self.units
|
||||
mx,my=self.middle
|
||||
zx,zy=self.zoom
|
||||
tx,ty=(wsx//2,wsy//2)
|
||||
for x in range(0,int(ux/zx)):
|
||||
X=ux*x*zx
|
||||
P=tx-mx*zx
|
||||
pygame.draw.line(window.screen, self.grid_color, (P-X,0),(P-X,wsy),1)
|
||||
pygame.draw.line(window.screen, self.grid_color, (P+X,0),(P+X,wsy),1)
|
||||
#for y in range(-ty,ty,int(float(uy)*zy)):
|
||||
#Y=y-my*zy+ty
|
||||
for y in range(0,int(uy/zy)):
|
||||
Y=uy*y*zy
|
||||
P=ty-my*zy
|
||||
pygame.draw.line(window.screen, self.grid_color, (0,P-Y),(wsx,P-Y),1)
|
||||
pygame.draw.line(window.screen, self.grid_color, (0,P+Y),(wsx,P+Y),1)
|
||||
X,Y=(tx-mx*zx,ty-my*zy)
|
||||
pygame.draw.line(window.screen, self.axis_color, (X,0),(X,wsy),1)
|
||||
pygame.draw.line(window.screen, self.axis_color, (0,Y),(wsx,Y),1)
|
||||
|
||||
|
||||
def move(self,window,controller):
|
||||
wsx,wsy=window.size
|
||||
tx,ty=wsx//2,wsy//2
|
||||
mx,my=self.middle
|
||||
ux,uy=self.units
|
||||
zx,zy=self.zoom
|
||||
vx,vy=self.velocity
|
||||
ax,ay=self.acceleration
|
||||
acx,acy=self.action
|
||||
fx,fy=self.friction
|
||||
middle_step=min(ux,uy)
|
||||
zoom_step=0.1
|
||||
pressed=False
|
||||
key=controller.pressed()
|
||||
if key[K_LEFT]:
|
||||
ax=-acx/zx
|
||||
if key[K_RIGHT]:
|
||||
ax=acx/zx
|
||||
if key[K_DOWN]:
|
||||
ay=acy/zy
|
||||
if key[K_UP]:
|
||||
ay=-acy/zy
|
||||
vx+=ax
|
||||
vy+=ay
|
||||
mx+=vx
|
||||
my+=vy
|
||||
vx/=fx
|
||||
vy/=fy
|
||||
ax,ay=[0,0]
|
||||
if key[K_RSHIFT]:
|
||||
zx*=(1.+zoom_step)
|
||||
zy*=(1.+zoom_step)
|
||||
if key[K_LSHIFT]:
|
||||
if zx>0.1:
|
||||
zx/=(1.+zoom_step)
|
||||
if zy>0.1:
|
||||
zy/=(1.+zoom_step)
|
||||
if key[K_RETURN]:
|
||||
px,py=self.default_point
|
||||
mx,my=self.default_middle
|
||||
ux,uy=self.default_units
|
||||
if pygame.mouse.get_pressed()[0]:
|
||||
pressed=bool(pygame.mouse.get_pressed()[0])
|
||||
ax,ay=pygame.mouse.get_pos()
|
||||
mx+=int(float(ax-tx)*0.1)
|
||||
my+=int(float(ay-ty)*0.1)
|
||||
self.acceleration=ax,ay
|
||||
self.velocity=vx,vy
|
||||
self.middle=mx,my
|
||||
self.units=ux,uy
|
||||
self.zoom=zx,zy
|
||||
|
||||
|
||||
class Grapher:
|
||||
def __init__(self,functions,settings=None):
|
||||
if settings is None:
|
||||
self.setDefaultSettings()
|
||||
else:
|
||||
self.setNewSettings(settings)
|
||||
|
||||
self.name="Grapher"
|
||||
self.controller=Controller()
|
||||
self.window=Window(self,self.window_size)
|
||||
self.plan=Plan(BLACK,WHITE)
|
||||
for function,color in zip(functions,self.graph_colors):
|
||||
self.graph=Graph(function,color)
|
||||
self.plan.addGraph(self.graph)
|
||||
self.plan.draw(self.window)
|
||||
self.session()
|
||||
|
||||
def session(self):
|
||||
while self.window.open:
|
||||
self.window.check()
|
||||
#self.plan.control()
|
||||
self.show()
|
||||
self.window.kill()
|
||||
|
||||
def show(self):
|
||||
self.plan.move(self.window,self.controller)
|
||||
self.plan.draw(self.window)
|
||||
self.window.flip()
|
||||
|
||||
def setNewSettings(self,settings):
|
||||
self.window_size=settings[0]
|
||||
self.plan_units=settings[1]
|
||||
self.graph_colors=settings[2]
|
||||
self.settings=settings
|
||||
|
||||
def setDefaultSettings(self):
|
||||
self.window_size=(1000,700)
|
||||
self.plan_units=[10,10]
|
||||
self.graph_colors=[RED,BLUE,GREEN,YELLOW,WHITE,PURPLE,GREY,DARKBLUE,DARKRED,DARKGREEN]
|
||||
self.settings=self.window_size,self.plan_units,self.graph_colors
|
||||
|
||||
#-------#
|
||||
#Actions#
|
||||
#-------#
|
||||
|
||||
if __name__=="__main__":
|
||||
functions=["math.sin(x)","math.cos(x)","random.random()"]
|
||||
Grapher=Grapher(functions)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,14 @@
|
||||
BLUE = ( 0, 0,255)
|
||||
RED = (255, 0, 0)
|
||||
GREEN = ( 0,255, 0)
|
||||
YELLOW = (255,255, 0)
|
||||
BLACK = ( 0, 0, 0)
|
||||
WHITE = (255,255,255)
|
||||
GREY = (100,100,100)
|
||||
PURPLE = (100, 0,100)
|
||||
DARKGREY = ( 20, 20, 20)
|
||||
DARKRED = ( 10, 10, 10)
|
||||
DARKGREEN = ( 10, 10, 10)
|
||||
DARKBLUE = ( 10, 10, 10)
|
||||
|
||||
print("mycolors imported")
|
||||
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
from mymoves import *
|
||||
|
||||
import pygame
|
||||
from pygame.locals import *
|
||||
|
||||
class Controller:
|
||||
def __init__(self):
|
||||
pass
|
||||
def pressed(self):
|
||||
return pygame.key.get_pressed()
|
||||
|
||||
print("mycontrols imported")
|
||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
RIGHT = 0
|
||||
UP = 1
|
||||
LEFT = 2
|
||||
DOWN = 3
|
||||
|
||||
print("my moves imported")
|
||||
Binary file not shown.
@@ -0,0 +1,84 @@
|
||||
from mycolors import *
|
||||
|
||||
import pygame
|
||||
from pygame.locals import *
|
||||
|
||||
|
||||
|
||||
class Window:
|
||||
made=0
|
||||
def __init__(self,game=None,size=None,font="monospace",text_color=BLACK,set=True):
|
||||
Window.made+=1
|
||||
self.number=Window.made
|
||||
self.title=game.name
|
||||
self.font=font
|
||||
self.open=True
|
||||
self.size=size
|
||||
self.text_color=text_color
|
||||
if set:
|
||||
self.set()
|
||||
|
||||
def set(self):
|
||||
pygame.init()
|
||||
self.setSize()
|
||||
self.font = pygame.font.SysFont(self.font, 65)
|
||||
self.screen=pygame.display.set_mode(self.size)
|
||||
pygame.display.set_caption(self.title)
|
||||
|
||||
def setSize(self):
|
||||
if self.size is None:
|
||||
info = pygame.display.Info()
|
||||
self.size=(info.current_w/2,info.current_h/2)
|
||||
|
||||
def pop_up(self,message):
|
||||
pass
|
||||
|
||||
def scale(self,picture,size):
|
||||
return pygame.transform.scale(picture,size)
|
||||
|
||||
def check(self):
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
self.open=False
|
||||
if event.type == KEYDOWN:
|
||||
if event.key == K_ESCAPE:
|
||||
self.open=False
|
||||
|
||||
def direction(self):
|
||||
keys=pygame.key.get_pressed()
|
||||
if keys[K_LEFT]:
|
||||
return LEFT
|
||||
if keys[K_RIGHT]:
|
||||
return RIGHT
|
||||
if keys[K_UP]:
|
||||
return UP
|
||||
if keys[K_DOWN]:
|
||||
return DOWN
|
||||
|
||||
def select(self):
|
||||
while self.open:
|
||||
self.check()
|
||||
for event in pygame.event.get():
|
||||
if event.type == MOUSEBUTTONDOWN and event.button == 1:
|
||||
return (event.pos[0],event.pos[1])
|
||||
|
||||
def point(self):
|
||||
for event in pygame.event.get():
|
||||
return (event.pos[0],event.pos[1])
|
||||
|
||||
def flip(self):
|
||||
pygame.display.flip()
|
||||
|
||||
def drawPicture(self,picture,position):
|
||||
self.screen.blit(picture, position)
|
||||
|
||||
def display(page):
|
||||
pass
|
||||
def showText(self,text,position,color,font,size):
|
||||
font=pygame.font.SysFont(font, size)
|
||||
label = font.render(text, 1, color)
|
||||
self.screen.blit(label, position)
|
||||
def kill(self):
|
||||
pygame.quit()
|
||||
|
||||
print("mywindow imported")
|
||||
Binary file not shown.
@@ -0,0 +1,54 @@
|
||||
from mywindow import *
|
||||
from mycolors import *
|
||||
|
||||
from GrapherV3 import *
|
||||
|
||||
class Tree:
|
||||
def __init__(self,position=(-10,0),size=(20,20)):
|
||||
self.position=position
|
||||
self.size=size
|
||||
self.coordonnates=size+position
|
||||
self.color=WHITE
|
||||
|
||||
def draw(self,plan,window):
|
||||
self.trace(plan,window)
|
||||
for i in range(len(self.trunk)):
|
||||
value,start,end=self.trunk[i]
|
||||
pygame.draw.line(window.screen, self.color, start, end, 1)
|
||||
|
||||
|
||||
|
||||
class Syracuse(Tree):
|
||||
def __init__(self):
|
||||
Tree.__init__(self)
|
||||
tx,ty=self.position
|
||||
self.trunk=[(1,(0,0),(0,0))]
|
||||
try:
|
||||
self.grow(self.trunk)
|
||||
#print(self.trunk)
|
||||
finally:
|
||||
print(self.trunk)
|
||||
|
||||
def grow(self,trunk):
|
||||
tx,ty=self.position
|
||||
sx,sy=self.size
|
||||
new_trunk=[]
|
||||
#print(position)
|
||||
for branch in trunk:
|
||||
#print(branch)
|
||||
value,old_position,position=branch
|
||||
x,y=position
|
||||
#print(position)
|
||||
if tx<=x<sx and ty<=y<sy:
|
||||
#print(position)
|
||||
new_trunk.append((2*value,(x,y),(x-1,y+1)))
|
||||
if (value-1)%3==0 and value!=1:
|
||||
new_trunk.append(((value-1)//3,(x,y),(x+1,y+1)))
|
||||
self.trunk+=new_trunk
|
||||
self.grow(new_trunk)
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
window=Window()
|
||||
arbre=Syracuse()
|
||||
print(arbre.trunk)
|
||||
@@ -0,0 +1,7 @@
|
||||
from GrapherV3 import *
|
||||
import math
|
||||
|
||||
def sigmoid(x):
|
||||
return 1/(1+math.exp(-x))
|
||||
|
||||
Grapher(["noise.pnoise1(x)","noise.pnoise1(x+5432)"])
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
"""mots=[]
|
||||
|
||||
determinants=["le","la","un","une"]
|
||||
|
||||
determinants={"avant":[],
|
||||
"apres":[],
|
||||
"masculin":None,
|
||||
"singulier":None}
|
||||
|
||||
#print(determinants)"""
|
||||
|
||||
words=[]
|
||||
|
||||
articles=["a","an","the"]
|
||||
a=["I","you","he","she","it","we","they"]
|
||||
|
||||
class List(list):
|
||||
def __init__(self,object):
|
||||
super().__init__(object)
|
||||
|
||||
def removeall(self,element):
|
||||
while element in self:
|
||||
self.remove(element)
|
||||
|
||||
def purge(self,elements):
|
||||
for element in elements:
|
||||
self.removeall(element)
|
||||
|
||||
def keep(self,elements):
|
||||
for element in self[:]:
|
||||
if not (element in elements):
|
||||
self.removeall(element)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Str(str):
|
||||
def __init__(self,object):
|
||||
super().__init__()
|
||||
self.alphabet="abcdefghijklmnopqrstuvwxyz"
|
||||
self.consonants="bcdfghjklmnpqrstvwxyz"
|
||||
self.vowels="aeiouy"
|
||||
self.numbers="0123456789"
|
||||
|
||||
def remove(self,element):
|
||||
self.replace(element,"")
|
||||
|
||||
|
||||
def removeall(self,element):
|
||||
while element in self:
|
||||
self.replace(element,"")
|
||||
|
||||
|
||||
def purge(self,elements):
|
||||
a=Str("")
|
||||
l=List(self)
|
||||
l.purge(elements)
|
||||
return Str(a.join(l))
|
||||
|
||||
def keep(self,elements):
|
||||
a=Str("")
|
||||
l=List(self)
|
||||
l.keep(elements)
|
||||
return Str(a.join(l))
|
||||
|
||||
|
||||
def reverse(self):
|
||||
self=[l for l in self[-1:]]
|
||||
#for i in range(len(self)//2):
|
||||
# self[i]=self[-i-1]
|
||||
|
||||
def append(self,element):
|
||||
self+=element
|
||||
|
||||
|
||||
def apphead(self,element):
|
||||
self.reverse()
|
||||
self.append(element)
|
||||
self.reverse()
|
||||
|
||||
def __sub__(self,element):
|
||||
return self.replace(element,"")
|
||||
|
||||
def __isub__(self,element):
|
||||
self.replace(element,"")
|
||||
|
||||
def __truediv__(self,element):
|
||||
self.replace(element,"")
|
||||
|
||||
def __floordiv__(self,element):
|
||||
while element in self:
|
||||
self.replace(element,"")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Sentence(Str):
|
||||
def __init__(self,object):
|
||||
super().__init__(object)
|
||||
self.words=self.wordsplit()
|
||||
|
||||
def wordsplit(self):
|
||||
text=self[:]
|
||||
text=text.lower()
|
||||
text=Str(text.replace("'"," "))
|
||||
text=text.keep(" "+self.alphabet)
|
||||
words=List(text.split(" "))
|
||||
words.removeall('')
|
||||
words=[Word(word) for word in words]
|
||||
return words
|
||||
|
||||
|
||||
|
||||
|
||||
class Word(Str):
|
||||
def __init__(self,object):
|
||||
super().__init__(object)
|
||||
self.syllables=self.syllablesplit()
|
||||
|
||||
def syllablesplit(self):
|
||||
syllables=[]
|
||||
word=self[:]
|
||||
while word!="":
|
||||
syllable=self.firstsyllable(word)
|
||||
syllables.append(syllable)
|
||||
word=word[len(syllable):]
|
||||
return syllables
|
||||
|
||||
def firstsyllable(self,word):
|
||||
vowelfound=False
|
||||
for i in range(len(word)-1):
|
||||
if word[i] in self.vowels: vowelfound=True
|
||||
if (word[i] in self.consonants) and (word[i+1] in self.vowels):
|
||||
if i>0 and vowelfound: return word[:i]
|
||||
return word
|
||||
|
||||
|
||||
class MutableString(object):
|
||||
def __init__(self, data):
|
||||
self.data = list(data)
|
||||
def __str__(self):
|
||||
return "".join(self.data)
|
||||
def append(self,element):
|
||||
self.data+=list(element)
|
||||
def appstart(self,element):
|
||||
self.data.reverse()
|
||||
element.reverse()
|
||||
self.data.append(element)
|
||||
self.data.reverse()
|
||||
|
||||
def __repr__(self):
|
||||
return "".join(self.data)
|
||||
def __setitem__(self, index, value):
|
||||
self.data[index] = value
|
||||
def __getitem__(self, index):
|
||||
if type(index) == slice:
|
||||
return "".join(self.data[index])
|
||||
return self.data[index]
|
||||
def __delitem__(self, index):
|
||||
del self.data[index]
|
||||
def __add__(self, other):
|
||||
self.data.extend(list(other))
|
||||
def __len__(self):
|
||||
return len(self.data)
|
||||
def __reverse__(self):
|
||||
self.data.reverse()
|
||||
|
||||
|
||||
|
||||
noun={"nature":None,
|
||||
"singular":None,
|
||||
"synonyms":[]}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
|
||||
sentence=Sentence("you're a fucking asshole you dumbass, you are a scrotumbag")
|
||||
b=Str([1,2])
|
||||
#a=a.remove(".")
|
||||
#print(a)
|
||||
print(sentence.words)
|
||||
print([word.syllables for word in sentence.words])
|
||||
print(sentence-"fucking ")
|
||||
sentence=MutableString(sentence)
|
||||
print(sentence)
|
||||
print(sentence.append("Wesh negro"))
|
||||
#print(list(a))
|
||||
#print(a.remove("s"))
|
||||
#print(b.remove(1))
|
||||
|
||||
|
||||
#def decomposeSentence(Str):
|
||||
|
||||
#return words
|
||||
|
||||
#decomposeSentence(a)
|
||||
@@ -0,0 +1,49 @@
|
||||
from classes import Str,List,Sentence,Word
|
||||
|
||||
def test(arg1,arg2):
|
||||
#do something with args
|
||||
a = arg1 + arg2
|
||||
return a
|
||||
|
||||
|
||||
|
||||
keywords=["assert","break","class","continue","def","del","elif","else","except","finally","for",
|
||||
"from","global","if","import","in","pass","print","raise","return","try","while","yield"]
|
||||
|
||||
conversion = {"assert":"ASSERT",
|
||||
"break":"SORTIR DE LA BOUCLE"
|
||||
"class":"CLASSE",
|
||||
"continue":"CONTINER",
|
||||
"def":"DONNEES",
|
||||
"del":"SUPPRIMER",
|
||||
"elif":["SINON SI","FAIRE"],
|
||||
"else":["SINON","FAIRE"],
|
||||
"except":"EXCEPTE",
|
||||
"finally":"FINALLEMENT",
|
||||
"for":["POUR","FAIRE"],
|
||||
"from":"DEPUIS",
|
||||
"global":"GLOBAL",
|
||||
"if":"SI",
|
||||
"import":"IMPORTER",
|
||||
"in":"DANS",
|
||||
"pass":"PASSER",
|
||||
"print":"AFFICHER",
|
||||
"raise":"RELEVER",
|
||||
"return":"AFFICHER",
|
||||
"try":"ESSAYER",
|
||||
"while":["TANT QUE","FAIRE"],
|
||||
"yield":"PASSER AU TOUR SUIVANT",
|
||||
"==":"=",
|
||||
"=":"<-"}
|
||||
|
||||
def convert(name):
|
||||
import inspect
|
||||
lines = inspect.getsource(foo)
|
||||
lines=Str(lines)
|
||||
output=[]
|
||||
for line in lines:
|
||||
output.append(convert(line)
|
||||
return "".join(output)
|
||||
|
||||
def convert(line):
|
||||
pass
|
||||
@@ -0,0 +1,31 @@
|
||||
def foo(arg1,arg2):
|
||||
#do something with args
|
||||
a = arg1 + arg2
|
||||
return a
|
||||
|
||||
|
||||
|
||||
print(lines.split("\n"))
|
||||
|
||||
|
||||
|
||||
def convertir(nom):
|
||||
import inspect
|
||||
lines = inspect.getsource(foo)
|
||||
lines=Str(lines)
|
||||
output=[]
|
||||
for line in lines:
|
||||
output.append(convert(line))
|
||||
return "".join(output)
|
||||
|
||||
def convert(line):
|
||||
if word_split():
|
||||
|
||||
|
||||
|
||||
#import dis
|
||||
#print(dis.dis(foo))
|
||||
|
||||
#from dill.source import getsource
|
||||
|
||||
#print(getsource(list.remove))
|
||||
@@ -0,0 +1,85 @@
|
||||
import random
|
||||
import sys
|
||||
|
||||
print(sys.getrecursionlimit())
|
||||
|
||||
sys.setrecursionlimit(10000)
|
||||
|
||||
print(sys.getrecursionlimit())
|
||||
|
||||
"""1"""
|
||||
|
||||
def belong(element,list):
|
||||
if len(list)==1:
|
||||
if [element]==list: return True
|
||||
else: return False
|
||||
else:
|
||||
return (belong(element,list[:1])+belong(element,list[1:])>0)
|
||||
|
||||
|
||||
|
||||
def union(l1,l2):
|
||||
if l1==[]: return l2
|
||||
if not belong(l1[0],l2): return [l1[0]]+union(l1[1:],l2)
|
||||
else: return union(l1[1:],l2)
|
||||
|
||||
def intersection(l1,l2):
|
||||
if l1==[]: return []
|
||||
if not belong(l1[0],l2): return intersection(l1[1:],l2)
|
||||
else: return [l1[0]]+intersection(l1[1:],l2)
|
||||
|
||||
#union = lambda l1,l2:list(set(l1+l2))
|
||||
|
||||
l1=list(range(100))
|
||||
l2=list(range(6,16,2))
|
||||
random.shuffle(l1)
|
||||
|
||||
#print(intersection(l1,l2))
|
||||
|
||||
"""2"""
|
||||
|
||||
def insert(e,l):
|
||||
if l==[]: return [e]
|
||||
if e>l[0]: return [l[0]]+insert(e,l[1:])
|
||||
else: return [e]+l
|
||||
|
||||
def sort(l):
|
||||
if l==[]: return l
|
||||
return insert(l[0],sort(l[1:]))
|
||||
|
||||
|
||||
#print(sort(l1))
|
||||
|
||||
"""3"""
|
||||
|
||||
|
||||
#sort1= lambda l:[min(l)]+sort1(l.remove(min(l)))
|
||||
|
||||
def sort1(l):
|
||||
if l==[]: return l
|
||||
t=min(l)
|
||||
l.remove(t)
|
||||
return [t]+sort1(l)
|
||||
|
||||
def factorial(n):
|
||||
if n<=1: return 1
|
||||
return n*factorial(n-1)
|
||||
|
||||
def shuffle(l):
|
||||
if l==[]: return l
|
||||
e=random.choice(l)
|
||||
l.remove(e)
|
||||
return [e]+shuffle(l)
|
||||
|
||||
#l3=[1,2,1,4,5,1,1,7]
|
||||
|
||||
def fusion(l1,l2):
|
||||
if l1==[]: return l1
|
||||
if l1[0]
|
||||
return
|
||||
|
||||
|
||||
#print(l1)
|
||||
#print(sort1(l1))
|
||||
|
||||
#print(factorial(10))
|
||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
import smtplib
|
||||
|
||||
import config
|
||||
|
||||
|
||||
def send_email(subject, msg):
|
||||
try:
|
||||
server = smtplib.SMTP('smtp.gmail.com:587')
|
||||
server.ehlo()
|
||||
server.starttls()
|
||||
server.login(config.EMAIL_ADDRESS, config.PASSWORD)
|
||||
message = 'Subject: {}\n\n{}'.format(subject, msg)
|
||||
server.sendmail(config.EMAIL_ADDRESS, config.EMAIL_ADDRESS, message)
|
||||
server.quit()
|
||||
print("Success: Email sent!")
|
||||
except:
|
||||
print("Email failed to send.")
|
||||
|
||||
|
||||
subject = "Test subject"
|
||||
msg = "Hello there, how are you today?"
|
||||
|
||||
send_email(subject, msg)
|
||||
@@ -0,0 +1,54 @@
|
||||
from math import sqrt
|
||||
|
||||
class Mandelbrot:
|
||||
def __init__(self,size,zone):
|
||||
self.zone=zone
|
||||
self.generate(self.size,self.zone)
|
||||
def generate(self,zone):
|
||||
zx,zy,zmx,zmy=zone
|
||||
sx,sy=self.size
|
||||
self.grid=[[0 for i in range(sx)] for j in range(sy)]
|
||||
maximum=0
|
||||
zsx=zmx-zx
|
||||
zsy=zmy-zy
|
||||
for y in range(sy):
|
||||
for x in range(sy):
|
||||
X=zx+x*zsx/sx
|
||||
Y=zy+y*zsy/sy
|
||||
self.grid[y][x]=self.evaluate(X,Y)
|
||||
maximum=max(maximum,convergence)
|
||||
self.maximum=maximum
|
||||
|
||||
def show(self,grid):
|
||||
|
||||
color=self.percentToRGB(convergence/10)
|
||||
|
||||
|
||||
|
||||
|
||||
def evaluate(self,x,y,step=10):
|
||||
for i in range(step):
|
||||
a=x+x**2-y**2
|
||||
y=y+2*x*y
|
||||
x=a
|
||||
value=sqrt(x**2+y**2)
|
||||
|
||||
def percentToRGB(self,percentage):
|
||||
wavelength=percentage*400+380
|
||||
gamma,max_intensity=0.80,255
|
||||
def adjust(color, factor):
|
||||
if color==0: return 0
|
||||
else: return round(max_intensity*pow(color*factor,gamma))
|
||||
if 380<=wavelength<=440: r,g,b=-(wavelength-440)/(440-380),0,1
|
||||
elif 440<=wavelength<=490: r,g,b=0,(wavelength-440)/(490-440),1
|
||||
elif 490<=wavelength<=510: r,g,b=0,1,-(wavelength-510)/(510-490)
|
||||
elif 510<=wavelength<=580: r,g,b=(wavelength-510)/(580-510),1,0
|
||||
elif 580<=wavelength<=645: r,g,b=1,-(wavelength-645)/(645-580),0
|
||||
elif 645<=wavelength<=780: r,g,b=1,0,0
|
||||
else: r,g,b=0,0,0
|
||||
if 380<=wavelength<=420: factor=0.3+0.7*(wavelength-380)/(420-380)
|
||||
elif 420<=wavelength<=701: factor=1
|
||||
elif 701<=wavelength<=780: factor=0.3+0.7*(780-wavelength)/(780-700)
|
||||
else: factor=0
|
||||
r,g,b=adjust(r,factor),adjust(g,factor),adjust(b,factor)
|
||||
return (r,g,b)
|
||||
@@ -0,0 +1,16 @@
|
||||
import numpy as np
|
||||
import cv2
|
||||
from mss import mss
|
||||
from PIL import Image
|
||||
|
||||
mon = {'top': 160, 'left': 160, 'width': 200, 'height': 200}
|
||||
|
||||
sct = mss()
|
||||
|
||||
while 1:
|
||||
sct.get_pixels(mon)
|
||||
img = Image.frombytes('RGB', (sct.width, sct.height), sct.image)
|
||||
cv2.imshow('test', np.array(img))
|
||||
if cv2.waitKey(25) & 0xFF == ord('q'):
|
||||
cv2.destroyAllWindows()
|
||||
break
|
||||
@@ -0,0 +1,3 @@
|
||||
def f(a,b):
|
||||
if a==0: return b
|
||||
else: return (b+1)
|
||||
Reference in New Issue
Block a user