From 7394f79da5f1d91bd2f50a82106f6c027110c079 Mon Sep 17 00:00:00 2001 From: richard Date: Thu, 23 Jun 2022 17:18:22 +0100 Subject: [PATCH] add some legacy #defines --- pyray/__init__.py | 30 ++++-------------------------- raylib/__init__.py | 2 +- raylib/colors.py | 3 ++- raylib/defines.py | 9 +++++++++ tests/test_defines.py | 14 ++++++++++++++ 5 files changed, 30 insertions(+), 28 deletions(-) create mode 100644 raylib/defines.py create mode 100644 tests/test_defines.py diff --git a/pyray/__init__.py b/pyray/__init__.py index e0a2104..7e2a312 100644 --- a/pyray/__init__.py +++ b/pyray/__init__.py @@ -13,6 +13,9 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 from raylib import rl, ffi +from raylib.colors import * +from raylib.defines import * + from inspect import ismethod,getmembers,isbuiltin import inflection @@ -24,32 +27,7 @@ current_module = __import__(__name__) def pointer(self, struct): return ffi.addressof(struct) -LIGHTGRAY =( 200, 200, 200, 255 ) -GRAY =( 130, 130, 130, 255 ) -DARKGRAY =( 80, 80, 80, 255 ) -YELLOW =( 253, 249, 0, 255 ) -GOLD =( 255, 203, 0, 255 ) -ORANGE =( 255, 161, 0, 255 ) -PINK =( 255, 109, 194, 255 ) -RED =( 230, 41, 55, 255 ) -MAROON =( 190, 33, 55, 255 ) -GREEN =( 0, 228, 48, 255 ) -LIME =( 0, 158, 47, 255 ) -DARKGREEN =( 0, 117, 44, 255 ) -SKYBLUE =( 102, 191, 255, 255 ) -BLUE =( 0, 121, 241, 255 ) -DARKBLUE =( 0, 82, 172, 255 ) -PURPLE =( 200, 122, 255, 255 ) -VIOLET =( 135, 60, 190, 255 ) -DARKPURPLE =( 112, 31, 126, 255 ) -BEIGE =( 211, 176, 131, 255 ) -BROWN =( 127, 106, 79, 255 ) -DARKBROWN =( 76, 63, 47, 255 ) -WHITE =( 255, 255, 255, 255 ) -BLACK =( 0, 0, 0, 255 ) -BLANK =( 0, 0, 0, 0 ) -MAGENTA =( 255, 0, 255, 255 ) -RAYWHITE =( 245, 245, 245, 255 ) + # I'm concerned that we are doing a lot of string comparisons on every function call to detect types. diff --git a/raylib/__init__.py b/raylib/__init__.py index 38d8641..7bf11ee 100644 --- a/raylib/__init__.py +++ b/raylib/__init__.py @@ -15,9 +15,9 @@ from ._raylib_cffi import ffi, lib as rl from raylib._raylib_cffi.lib import * from raylib.colors import * +from raylib.defines import * import cffi import sys -#from raylib.pyray import PyRay from .version import __version__ print("RAYLIB STATIC "+__version__+" LOADED", file=sys.stderr) diff --git a/raylib/colors.py b/raylib/colors.py index 468e7ef..024297f 100644 --- a/raylib/colors.py +++ b/raylib/colors.py @@ -37,4 +37,5 @@ WHITE =( 255, 255, 255, 255 ) BLACK =( 0, 0, 0, 255 ) BLANK =( 0, 0, 0, 0 ) MAGENTA =( 255, 0, 255, 255 ) -RAYWHITE =( 245, 245, 245, 255 ) \ No newline at end of file +RAYWHITE =( 245, 245, 245, 255 ) + diff --git a/raylib/defines.py b/raylib/defines.py new file mode 100644 index 0000000..9b988bf --- /dev/null +++ b/raylib/defines.py @@ -0,0 +1,9 @@ +import raylib + +MOUSE_LEFT_BUTTON = raylib.MOUSE_BUTTON_LEFT +MOUSE_RIGHT_BUTTON = raylib.MOUSE_BUTTON_RIGHT +MOUSE_MIDDLE_BUTTON = raylib.MOUSE_BUTTON_MIDDLE +MATERIAL_MAP_DIFFUSE = raylib.MATERIAL_MAP_ALBEDO +MATERIAL_MAP_SPECULAR = raylib.MATERIAL_MAP_METALNESS +SHADER_LOC_MAP_DIFFUSE = raylib.SHADER_LOC_MAP_ALBEDO +SHADER_LOC_MAP_SPECULAR = raylib.SHADER_LOC_MAP_METALNESS \ No newline at end of file diff --git a/tests/test_defines.py b/tests/test_defines.py new file mode 100644 index 0000000..e6c36be --- /dev/null +++ b/tests/test_defines.py @@ -0,0 +1,14 @@ +""" +This shows how to use the Pyray wrapper around the static binding. +""" + +import pyray as pr + +print(pr.WHITE) +print(pr.MOUSE_BUTTON_LEFT) +print(pr.MOUSE_LEFT_BUTTON ) +print(pr.MATERIAL_MAP_SPECULAR) + +import raylib as rl + +print(rl.MATERIAL_MAP_DIFFUSE) \ No newline at end of file