This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Get the value always between minv and maxv""" | |
| clamp = lambda value, minv, maxv: max(min(value, maxv), minv) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| import random | |
| class Vector: | |
| """ Compact Vector2d class | |
| @2024_03_24_1520-2024_04_11_1345 updated by Beotiger | |
| If no arguments in create given returns null Vector instance | |
| Methods add, sub, mul, div, normalize, mag, magSq, limit, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ECHO off | |
| REM @2024_04_09_0912 by Beotiger | |
| REM Installing compiled tkscrsavers.scr to Windows\System32 folder | |
| REM You should run this file as Administrator or it will not work. | |
| REM See README.md for details | |
| REM NET FILE 1>NUL 2>NUL & IF ERRORLEVEL 1 (ECHO You must right-click and select "Run as administrator" to run this batch. & ECHO. & PAUSE & EXIT /B) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ECHO OFF | |
| :: | |
| :: Restart as Admin if not already running as Admin | |
| :: | |
| (NET session >nul 2>&1)||(PowerShell start """%~fn0""" -verb RunAs & Exit /B) | |
| REM ... proceed here with admin rights ... | |
| ECHO You are admin! | |
| ECHO. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Block: | |
| def __init__(self, c, main): | |
| self.c = c | |
| self.main = main | |
| self.colRange = self.randomLengthGen(main.cols + 1) | |
| self.rowRange = self.randomLengthGen(main.rows + 1) | |
| self.block = dict( | |
| ((i, j), Cell(i * main.wx, j * main.hx, main.wx, main.hx, j)) for i in range(self.colRange[0], self.colRange[1]) for j in range(self.rowRange[0], self.rowRange[1]) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # From: https://stackoverflow.com/questions/12284311/python-tkinter-how-to-work-with-pixels | |
| from tkinter import Tk, Canvas, PhotoImage, mainloop | |
| from math import sin | |
| WIDTH, HEIGHT = 640, 480 | |
| window = Tk() | |
| canvas = Canvas(window, width=WIDTH, height=HEIGHT, bg="#000000") | |
| canvas.pack() | |
| img = PhotoImage(width=WIDTH, height=HEIGHT) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Import the required libraries | |
| from tkinter import * | |
| import math | |
| WIDTH, HEIGHT = 500, 500 | |
| class Vector: | |
| """ Compact but powerful Vector2d class | |
| @2024_03_24_1520 updated by Beotiger """ | |
| def __init__(self, x=0.0, y=0.0): self.x = x; self.y = y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tkinter as tk | |
| def drag_start(event): | |
| widget = event.widget | |
| widget._drag_start_x = event.x | |
| widget._drag_start_y = event.y | |
| def drag_motion(event): | |
| widget = event.widget | |
| x = widget.winfo_x() - widget._drag_start_x + event.x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Import the required libraries | |
| from tkinter import * | |
| import math | |
| WIDTH, HEIGHT = 500, 500 | |
| class GradientColor: | |
| @staticmethod | |
| def hex_to_RGB(hex): | |
| """ "#FFFFFF" -> [255,255,255] """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from tkinter import * | |
| # from ship import * | |
| import math | |
| class Ship: | |
| def centroid(self): | |
| return 1 / 3 * (self.x0 + self.x1 + self.x2), 1 / 3 * (self.y0 + self.y1 + self.y2) | |
| def __init__(self, canvas, x, y, width, height, turnspeed, acceleration=1): |
NewerOlder