/programs/develop/tinypy/CHANGES.txt |
---|
File deleted |
\ No newline at end of file |
/programs/develop/tinypy/modules/random/tests.py |
---|
File deleted |
/programs/develop/tinypy/modules/random/random.c |
---|
File deleted |
/programs/develop/tinypy/modules/random/init.c |
---|
File deleted |
/programs/develop/tinypy/modules/pygame/init.c |
---|
File deleted |
/programs/develop/tinypy/modules/re/testsuite.py |
---|
File deleted |
/programs/develop/tinypy/modules/re/regexpr.h |
---|
File deleted |
/programs/develop/tinypy/modules/re/init.c |
---|
File deleted |
/programs/develop/tinypy/modules/re/tests.py |
---|
File deleted |
/programs/develop/tinypy/modules/re/regexpr.c |
---|
File deleted |
/programs/develop/tinypy/modules/math/init.c |
---|
File deleted |
/programs/develop/tinypy/modules/math/tests.py |
---|
File deleted |
/programs/develop/tinypy/modules/math/math.c |
---|
File deleted |
/programs/develop/tinypy/modules/kolibri/net.c |
---|
File deleted |
/programs/develop/tinypy/modules/kolibri/debug.c |
---|
File deleted |
/programs/develop/tinypy/modules/kolibri/fs.c |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/programs/develop/tinypy/modules/kolibri/init.c |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/programs/develop/tinypy/modules/kolibri/gui.c |
---|
File deleted |
/programs/develop/tinypy/setup.py |
---|
File deleted |
/programs/develop/tinypy/examples/asteroid.py |
---|
0,0 → 1,119 |
""" |
a simple diversing asteroids simulation |
""" |
import sys |
import math |
import random |
import pygame |
if "tinypy" not in sys.version: # not tinypy |
import pygame.locals |
SCR_WIDTH = 600 |
SCR_HEIGHT = 600 |
NASTEROIDS = 320 # number of asteroids |
INIT_NASTEROIDS = 80 # initial number of asteroids |
OFFSET = 20 # max initial offset |
DIV_FACTOR = 1.1 # diverse factor |
class Center(object): |
x = SCR_WIDTH / 2 |
y = SCR_HEIGHT / 2 |
class Graphics(object): |
x = 0 |
y = 0 |
w = SCR_WIDTH |
h = SCR_HEIGHT |
center = Center() |
BACKGROUND = (0, 0, 0) # black background |
def __init__(self): |
pygame.init() |
self.screen = pygame.display.set_mode((SCR_WIDTH, SCR_HEIGHT)) |
self.clearScreen() |
def drawRect(self, sx, sy, w, h, color): |
sx = int(sx) |
sy = int(sy) |
dx = int(sx + w) |
dy = int(sy + h) |
for x in range(sx, dx): |
for y in range(sy, dy): |
self.screen.set_at((x, y), color) |
def clearScreen(self): |
for x in range(SCR_WIDTH): |
for y in range(SCR_HEIGHT): |
self.screen.set_at((x, y), self.BACKGROUND) |
def flipDisplay(self): |
pygame.display.flip() |
class Asteroid(object): |
graphics = Graphics() |
def __init__(self): |
self.x = 0 # x and y, set to invalid position |
self.y = 0 |
self.size = 1 |
self.color = [0, 0, 0] |
def show(self): |
self.graphics.drawRect(self.x, self.y, self.size, self.size, self.color) |
def hide(self): |
self.graphics.drawRect(self.x, self.y, self.size, self.size, self.graphics.BACKGROUND) |
def update(self): |
# update asteroids[i]'s position |
if (self.x <= self.graphics.x or self.x >= self.graphics.w or |
self.y <= self.graphics.y or self.y >= self.graphics.h): |
self.x = self.graphics.center.x - OFFSET + OFFSET * 2 * random.random() |
self.y = self.graphics.center.y - OFFSET + OFFSET * 2 * random.random() |
self.color[0] = random.randint(20, 255) |
self.color[1] = random.randint(20, 255) |
self.color[2] = random.randint(20, 255) |
else: |
gx = self.graphics.center.x + (self.x - self.graphics.center.x) * DIV_FACTOR |
if (math.fabs(self.x - self.graphics.center.x) < 1e-6): |
gy = self.graphics.center.y + (self.y - self.graphics.center.y) * DIV_FACTOR |
else: |
k = (gx - self.graphics.center.x) / (self.x - self.graphics.center.x) |
gy = self.graphics.center.y + (self.y - self.graphics.center.y) * k |
self.x = gx |
self.y = gy |
# update self's size |
self.size = int(5 * ((math.fabs(self.x - self.graphics.center.x) * 2) / self.graphics.w)) |
if self.size <= 1: |
self.size = 1 |
def main(): |
asteroids = [] |
for i in range(INIT_NASTEROIDS): |
asteroid = Asteroid() |
asteroid.update() |
asteroids.append(asteroid) |
_quit = False |
while not _quit: |
for e in pygame.event.get(): |
if e.type in (pygame.locals.QUIT, pygame.locals.KEYDOWN): |
_quit = True |
if (len(asteroids) < NASTEROIDS): |
asteroid = Asteroid() |
asteroid.update() |
asteroids.append(asteroid) |
for i in range(len(asteroids)): |
# hide asteroids[i] |
asteroids[i].hide() |
# update asteroids[i] |
asteroids[i].update() |
# show asteroids[i] |
asteroids[i].show() |
# swap display content actually |
Asteroid.graphics.flipDisplay() |
if __name__ == '__main__': |
main() |
print("#OK") |
/programs/develop/tinypy/examples/julia.py |
---|
1,6 → 1,6 |
# center: 10043 |
import pygame |
if '.' in str(1.0): |
import pygame, sys |
if not "tinypy" in sys.version: |
import pygame.locals |
SW,SH = 120,120 |
/programs/develop/tinypy/examples/net/ATTENTION.txt |
---|
0,0 → 1,0 |
While sockets are disabled these examples don't work! |
/programs/develop/tinypy/examples/rw_file.py |
---|
0,0 → 1,13 |
# Read/Write file example |
# Copyright (C) 2019-2021 Logaev Maxim (turbocat2001), GPLv3 |
import ksys # KolibriOS syscalls |
fw=ksys.open('my.txt','w') # Open file for writing |
fw.write("I love KolibriOS") # Write symbols to my.txt file |
fw.close() # Close file |
fr=ksys.open('my.txt', 'r') # Open file for reading |
str=fr.read() # Read symbols from file |
print(str) # Print to console |
fr.close() # Close file |
/programs/develop/tinypy/examples/vines.py |
---|
0,0 → 1,170 |
#!/bin/env python |
# |
# vines borrowed from xscreensaver |
# |
""" |
/*- |
* Copyright (c) 1997 by Tracy Camp campt@hurrah.com |
* |
* Permission to use, copy, modify, and distribute this software and its |
* documentation for any purpose and without fee is hereby granted, |
* provided that the above copyright notice appear in all copies and that |
* both that copyright notice and this permission notice appear in |
* supporting documentation. |
* |
* This file is provided AS IS with no warranties of any kind. The author |
* shall have no liability with respect to the infringement of copyrights, |
* trade secrets or any patents by this file or any part thereof. In no |
* event will the author be liable for any lost revenue or profits or |
* other special, indirect and consequential damages. |
* |
* If you make a modification I would of course appreciate a copy. |
* |
* Revision History: |
* 01-Nov-2000: Allocation checks |
* 11-Jul-1997: David Hansen <dhansen@metapath.com> |
* Changed names to vines and modified draw loop |
* to honor batchcount so vines can be grown or plotted. |
* 10-May-1997: Compatible with xscreensaver |
* 21-Mar-1997: David Hansen <dhansen@metapath.com> |
* Updated mode to draw complete patterns on every |
* iteration instead of growing the vine. Also made |
* adjustments to randomization and changed variable |
* names to make logic easier to follow. |
*/ |
/*- |
* This was modifed from a 'screen saver' that a friend and I |
* wrote on our TI-8x calculators in high school physics one day |
* Basically another geometric pattern generator, this ones claim |
* to fame is a pseudo-fractal looking vine like pattern that creates |
* nifty whorls and loops. |
*/ |
""" |
import sys |
import math |
import random |
import pygame |
if "tinypy" not in sys.version: # not tinypy |
import pygame.locals |
SCR_WIDTH = 800 |
SCR_HEIGHT = 600 |
class VineStruct(object): |
a = 0 |
x1 = 0 |
y1 = 0 |
x2 = 0 |
y2 = 0 |
i = 0 |
length = 0 |
iterations = 0 |
constant = 0 |
ang = 0 |
centerx = 0 |
centery = 0 |
class Vines(object): |
def __init__(self): |
self.fp = VineStruct() |
self.fp.i = 0 |
self.fp.length = 0 |
self.fp.iterations = 30 + random.randint(0, 100) |
pygame.init() |
self.screen = pygame.display.set_mode((SCR_WIDTH, SCR_HEIGHT)) |
def __drawLine__(self, x1, y1, x2, y2, color): |
# validate the bounds |
if x1 < 0: x1 = 0 |
if x1 > SCR_WIDTH: x1 = SCR_WIDTH |
if x2 < 0: x2 = 0 |
if x2 > SCR_WIDTH: x2 = SCR_WIDTH |
if y1 < 0: y1 = 0 |
if y1 > SCR_HEIGHT: y1 = SCR_HEIGHT |
if y2 < 0: y2 = 0 |
if y2 > SCR_HEIGHT: y2 = SCR_HEIGHT |
if x1 <= x2: |
sx, sy = x1, y1 |
dx, dy = x2, y2 |
else: |
sx, sy = x2, y2 |
dx, dy = x1, y1 |
if (abs(x1 - x2) < 1e-4): |
x = sx |
if sy > dy: |
sy, dy = dy, sy |
y = sy |
while (y < dy): |
self.screen.set_at((x, y), color) |
y += 1 |
else: |
k = (dy - sy) / (dx - sx) |
x = sx |
while (x < dx): |
y = sy + k * (x - sx) |
self.screen.set_at((x, y), color) |
x += 1 |
pygame.display.flip() |
def draw(self): |
red = random.randint(0, 255) |
green = random.randint(0, 255) |
blue = random.randint(0, 255) |
if (self.fp.i >= self.fp.length): |
self.fp.iterations -= 1 |
if (self.fp.iterations == 0): |
self.__init__(self) |
self.fp.centerx = random.randint(0, SCR_WIDTH); |
self.fp.centery = random.randint(0, SCR_HEIGHT); |
self.fp.ang = 60 + random.randint(0, 720); |
self.fp.length = 100 + random.randint(0, 3000); |
self.fp.constant= self.fp.length * (10 + random.randint(0, 10)) |
self.fp.i = 0; |
self.fp.a = 0; |
self.fp.x1 = 0; |
self.fp.y1 = 0; |
self.fp.x2 = 1; |
self.fp.y2 = 0; |
count = self.fp.i + random.randint(10, 100) |
if (count > self.fp.length): |
count = self.fp.length |
while (self.fp.i < count): |
x1 = self.fp.centerx + (self.fp.x1 / self.fp.constant) |
y1 = self.fp.centery - (self.fp.y1 / self.fp.constant) |
x2 = self.fp.centerx + (self.fp.x2 / self.fp.constant) |
y2 = self.fp.centery - (self.fp.y2 / self.fp.constant) |
color = (red, green, blue) |
self.__drawLine__(x1, y1, x2, y2, color) |
self.fp.a += (self.fp.ang * self.fp.i) |
self.fp.x1 = self.fp.x2 |
self.fp.y1 = self.fp.y2 |
self.fp.x2 += int((self.fp.i * (math.cos(self.fp.a) * 360.0)) / (2.0 * math.pi)) |
self.fp.y2 += int((self.fp.i * (math.sin(self.fp.a) * 360.0)) / (2.0 * math.pi)) |
self.fp.i += 1 |
def main(): |
myVine = Vines() |
_quit = False |
while not _quit: |
for e in pygame.event.get(): |
if e.type in (pygame.locals.QUIT,pygame.locals.KEYDOWN): |
_quit = True |
myVine.draw() |
if __name__ == '__main__': |
main() |
print("#OK") |