Compare commits

...
This repository has been archived on 2025-06-21. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.

3 commits
master ... mypy

Author SHA1 Message Date
Richard Smith
fedf2589da update docs and stubs 2024-11-17 01:15:35 +00:00
Richard Smith
0069436610 generate type stubs which are sufficiently self-consistent to run mypy on all the examples 2024-11-16 20:12:17 +00:00
Richard Smith
6441bca77c update examples 2024-11-16 20:11:08 +00:00
97 changed files with 17337 additions and 10474 deletions

View file

@ -45,8 +45,8 @@ def process(filename):
strval = str(e['value']).strip() strval = str(e['value']).strip()
if strval.startswith("__"): if strval.startswith("__"):
continue continue
if strval in known_enum: # if strval in known_enum:
print(e['name'] + " = raylib." + strval) # print(e['name'] + " = raylib." + strval)
elif strval in known_define: elif strval in known_define:
print(e['name'] + " = " + strval) print(e['name'] + " = " + strval)
else: else:

View file

@ -29,6 +29,12 @@ for filename in (Path("raylib.json"), Path("raymath.json"), Path("rlgl.json"), P
for st in js["structs"]: for st in js["structs"]:
if st["name"] not in known_structs: if st["name"] not in known_structs:
known_structs[st["name"]] = st known_structs[st["name"]] = st
for e in js['enums']:
if e['name'] and e['values']:
print ("class "+e['name']+"(int):")
for value in e['values']:
print(" "+value['name']+" = "+str(value['value']))
print("")
def ctype_to_python_type(t): def ctype_to_python_type(t):
@ -42,29 +48,39 @@ def ctype_to_python_type(t):
return "int" return "int"
elif t == "uint64_t": elif t == "uint64_t":
return "int" return "int"
elif t == "short":
return "int"
elif t == "unsigned short":
return "int"
elif t == "double": elif t == "double":
return "float" return "float"
elif "char * *" in t: elif "char * *" in t:
return "list[str]" return "list[str]"
elif "char *" in t: elif "char *" in t:
return "str" return "str"
elif "char" in t: elif t == "char":
return "str" # not sure about this one return "str" # not sure about this one
elif t == "unsigned char":
return "int"
elif "*" in t: elif "*" in t:
return "Any" return "Any"
elif "[" in t:
return "list" # TODO FIXME type of items in the list
elif t.startswith("struct"): elif t.startswith("struct"):
return t.replace("struct ", "") return t.replace("struct ", "")
elif t.startswith("unsigned"): elif t.startswith("unsigned"):
return t.replace("unsigned ", "") return t.replace("unsigned ", "")
elif t.startswith("enum"):
return t.replace("enum ", "")
else: else:
return t return t
print("""from typing import Any print("""from typing import Any
import _cffi_backend # type: ignore
def pointer(struct): ffi: _cffi_backend.FFI
...
""") """)
# These words can be used for c arg names, but not in python # These words can be used for c arg names, but not in python
@ -90,6 +106,8 @@ for name, attr in getmembers(rl):
if param_name in reserved_words: if param_name in reserved_words:
param_name = param_name + "_" + str(i) param_name = param_name + "_" + str(i)
param_type = ctype_to_python_type(arg.cname) param_type = ctype_to_python_type(arg.cname)
if "struct" in arg.cname:
param_type += "|list|tuple"
sig += f"{param_name}: {param_type}," sig += f"{param_name}: {param_type},"
return_type = ffi.typeof(attr).result.cname return_type = ffi.typeof(attr).result.cname
@ -128,11 +146,14 @@ for struct in ffi.list_types()[0]:
print(f' """ struct """') print(f' """ struct """')
sig = "" sig = ""
for arg in ffi.typeof(struct).fields: for arg in ffi.typeof(struct).fields:
sig += ", " + arg[0] ptype = ctype_to_python_type(arg[1].type.cname)
if arg[1].type.kind == "struct":
ptype += "|list|tuple"
sig += f", {arg[0]}: {ptype}|None = None"
print(f" def __init__(self{sig}):") print(f" def __init__(self{sig}):")
for arg in ffi.typeof(struct).fields: for arg in ffi.typeof(struct).fields:
print(f" self.{arg[0]}={arg[0]}") print(f" self.{arg[0]}:{ctype_to_python_type(arg[1].type.cname)} = {arg[0]} # type: ignore")
# elif ffi.typeof(struct).kind == "enum": # elif ffi.typeof(struct).kind == "enum":
# print(f"{struct}: int") # print(f"{struct}: int")

View file

@ -42,27 +42,35 @@ def ctype_to_python_type(t):
return "int" return "int"
elif t == "uint64_t": elif t == "uint64_t":
return "int" return "int"
elif t == "short":
return "int"
elif t == "unsigned short":
return "int"
elif t == "double": elif t == "double":
return "float" return "float"
elif "char * *" in t: elif "char * *" in t:
return "list[str]" return "list[bytes]"
elif "char *" in t: elif "char *" in t:
return "str" return "bytes"
elif "char" in t: elif "char" in t:
return "str" # not sure about this one return "bytes" # not sure about this one
elif "*" in t: elif "*" in t:
return "Any" return "Any"
elif "[" in t:
return "list" # TODO FIXME type of items in the list
elif t.startswith("struct"): elif t.startswith("struct"):
return t.replace("struct ", "") return t.replace("struct ", "")
elif t.startswith("unsigned"): elif t.startswith("unsigned"):
return t.replace("unsigned ", "") return t.replace("unsigned ", "")
elif t.startswith("enum"):
return t.replace("enum ", "")
else: else:
return t return t
print("""from typing import Any print("""from typing import Any
import _cffi_backend import _cffi_backend # type: ignore
ffi: _cffi_backend.FFI ffi: _cffi_backend.FFI
rl: _cffi_backend.Lib rl: _cffi_backend.Lib
@ -96,6 +104,8 @@ for name, attr in getmembers(rl):
if param_name in reserved_words: if param_name in reserved_words:
param_name = param_name + "_" + str(i) param_name = param_name + "_" + str(i)
param_type = ctype_to_python_type(arg.cname) param_type = ctype_to_python_type(arg.cname)
if "struct" in arg.cname:
param_type += "|list|tuple"
sig += f"{param_name}: {param_type}," sig += f"{param_name}: {param_type},"
return_type = ffi.typeof(attr).result.cname return_type = ffi.typeof(attr).result.cname
@ -121,17 +131,22 @@ for struct in ffi.list_types()[0]:
# if ffi.typeof(struct).fields is None: # if ffi.typeof(struct).fields is None:
# print("weird empty struct, skipping", file=sys.stderr) # print("weird empty struct, skipping", file=sys.stderr)
# continue # continue
print(f"{struct}: struct") print(f"class {struct}:")
# sig = "" # sig = ""
# for arg in ffi.typeof(struct).fields: fields = ffi.typeof(struct).fields
# sig += ", " + arg[0] if fields is not None:
#print(ffi.typeof(struct).fields)
#print(f" {arg}: {arg}")
# print(f" def __init__(self{sig}):") # print(f" def __init__(self{sig}):")
# #
# for arg in ffi.typeof(struct).fields: for arg in ffi.typeof(struct).fields:
print(f" {arg[0]}: {ctype_to_python_type(arg[1].type.cname)}")
else:
print(" ...")
# print(f" self.{arg[0]}={arg[0]}") # print(f" self.{arg[0]}={arg[0]}")
elif ffi.typeof(struct).kind == "enum": elif ffi.typeof(struct).kind == "enum":
print(f"{struct}: int") print(f"{struct} = int")
else: else:
print("ERROR UNKNOWN TYPE", ffi.typeof(struct), file=sys.stderr) print("ERROR UNKNOWN TYPE", ffi.typeof(struct), file=sys.stderr)

View file

@ -1,4 +1,4 @@
# Sphinx build info version 1 # Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. # This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 614f580883a5bffb7f1606004f7be223 config: 6b88b88b20947586d6498748ffd23a92
tags: 645f666f9bcd5a90fca523b33c5a78b7 tags: 645f666f9bcd5a90fca523b33c5a78b7

View file

@ -1,3 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./"> <html class="writer-html5" lang="en" data-content_root="./">
<head> <head>
@ -6,19 +8,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Building from source &mdash; Raylib Python documentation</title> <title>Building from source &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" /> <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" /> <link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=fd3f3429" /> <link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
<!--[if lt IE 9]> <script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/js/html5shiv.min.js"></script> <script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<![endif]--> <script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/jquery.js?v=5d32c60e"></script> <script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script> <script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" /> <link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" /> <link rel="search" title="Search" href="search.html" />

View file

@ -1,3 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./"> <html class="writer-html5" lang="en" data-content_root="./">
<head> <head>
@ -6,19 +8,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Python Bindings for Raylib 5.0 &mdash; Raylib Python documentation</title> <title>Python Bindings for Raylib 5.0 &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" /> <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" /> <link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=fd3f3429" /> <link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
<!--[if lt IE 9]> <script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/js/html5shiv.min.js"></script> <script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<![endif]--> <script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/jquery.js?v=5d32c60e"></script> <script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script> <script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" /> <link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" /> <link rel="search" title="Search" href="search.html" />
@ -105,7 +103,6 @@
<section id="python-bindings-for-raylib-5-0"> <section id="python-bindings-for-raylib-5-0">
<h1>Python Bindings for Raylib 5.0<a class="headerlink" href="#python-bindings-for-raylib-5-0" title="Link to this heading"></a></h1> <h1>Python Bindings for Raylib 5.0<a class="headerlink" href="#python-bindings-for-raylib-5-0" title="Link to this heading"></a></h1>
<iframe src="https://electronstudio.github.io/raylib-python-cffi-pygbag-examples/shapes_bouncing_ball/build/web/" style="border:0px #ffffff none;" name="myiFrame" scrolling="no" frameborder="1" marginheight="0px" marginwidth="0px" height="450px" width="800px" allowfullscreen></iframe>
<p>Chatroom: <a class="reference external" href="https://discord.gg/fKDwt85aX6">Discord</a> or <a class="reference external" href="https://matrix.to/#/#raylib-python-cffi:matrix.org">Matrix</a></p> <p>Chatroom: <a class="reference external" href="https://discord.gg/fKDwt85aX6">Discord</a> or <a class="reference external" href="https://matrix.to/#/#raylib-python-cffi:matrix.org">Matrix</a></p>
<p>New CFFI API static bindings.</p> <p>New CFFI API static bindings.</p>
<ul class="simple"> <ul class="simple">

View file

@ -1,3 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./"> <html class="writer-html5" lang="en" data-content_root="./">
<head> <head>
@ -6,19 +8,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Raspberry Pi &mdash; Raylib Python documentation</title> <title>Raspberry Pi &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" /> <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" /> <link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=fd3f3429" /> <link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
<!--[if lt IE 9]> <script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/js/html5shiv.min.js"></script> <script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<![endif]--> <script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/jquery.js?v=5d32c60e"></script> <script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script> <script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" /> <link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" /> <link rel="search" title="Search" href="search.html" />

View file

@ -1,12 +1,5 @@
/* /*
* basic.css
* ~~~~~~~~~
*
* Sphinx stylesheet -- basic theme. * Sphinx stylesheet -- basic theme.
*
* :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/ */
/* -- main layout ----------------------------------------------------------- */ /* -- main layout ----------------------------------------------------------- */
@ -115,15 +108,11 @@ img {
/* -- search page ----------------------------------------------------------- */ /* -- search page ----------------------------------------------------------- */
ul.search { ul.search {
margin: 10px 0 0 20px; margin-top: 10px;
padding: 0;
} }
ul.search li { ul.search li {
padding: 5px 0 5px 20px; padding: 5px 0;
background-image: url(file.png);
background-repeat: no-repeat;
background-position: 0 7px;
} }
ul.search li a { ul.search li a {

View file

@ -1 +1 @@
.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-style:normal;font-weight:400;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#FontAwesome) format("svg")}.fa:before{font-family:FontAwesome;font-style:normal;font-weight:400;line-height:1}.fa:before,a .fa{text-decoration:inherit}.fa:before,a .fa,li .fa{display:inline-block}li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before,.icon-book:before{content:"\f02d"}.fa-caret-down:before,.icon-caret-down:before{content:"\f0d7"}.fa-caret-up:before,.icon-caret-up:before{content:"\f0d8"}.fa-caret-left:before,.icon-caret-left:before{content:"\f0d9"}.fa-caret-right:before,.icon-caret-right:before{content:"\f0da"}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60}.rst-versions .rst-current-version:after{clear:both;content:"";display:block}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}} .clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-style:normal;font-weight:400;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#FontAwesome) format("svg")}.fa:before{font-family:FontAwesome;font-style:normal;font-weight:400;line-height:1}.fa:before,a .fa{text-decoration:inherit}.fa:before,a .fa,li .fa{display:inline-block}li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before,.icon-book:before{content:"\f02d"}.fa-caret-down:before,.icon-caret-down:before{content:"\f0d7"}.fa-caret-up:before,.icon-caret-up:before{content:"\f0d8"}.fa-caret-left:before,.icon-caret-left:before{content:"\f0d9"}.fa-caret-right:before,.icon-caret-right:before{content:"\f0da"}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60}.rst-versions .rst-current-version:after{clear:both;content:"";display:block}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions .rst-other-versions .rtd-current-item{font-weight:700}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}}#flyout-search-form{padding:6px}

File diff suppressed because one or more lines are too long

View file

@ -1,12 +1,5 @@
/* /*
* doctools.js
* ~~~~~~~~~~~
*
* Base JavaScript utilities for all Sphinx HTML documentation. * Base JavaScript utilities for all Sphinx HTML documentation.
*
* :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/ */
"use strict"; "use strict";

BIN
docs/_static/fonts/Lato/lato-bold.eot vendored Normal file

Binary file not shown.

BIN
docs/_static/fonts/Lato/lato-bold.ttf vendored Normal file

Binary file not shown.

BIN
docs/_static/fonts/Lato/lato-bold.woff vendored Normal file

Binary file not shown.

BIN
docs/_static/fonts/Lato/lato-bold.woff2 vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
docs/_static/fonts/Lato/lato-italic.eot vendored Normal file

Binary file not shown.

BIN
docs/_static/fonts/Lato/lato-italic.ttf vendored Normal file

Binary file not shown.

BIN
docs/_static/fonts/Lato/lato-italic.woff vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
docs/_static/fonts/Lato/lato-regular.eot vendored Normal file

Binary file not shown.

BIN
docs/_static/fonts/Lato/lato-regular.ttf vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,12 +1,5 @@
/* /*
* graphviz.css
* ~~~~~~~~~~~~
*
* Sphinx stylesheet -- graphviz extension. * Sphinx stylesheet -- graphviz extension.
*
* :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/ */
img.graphviz { img.graphviz {

View file

@ -1,4 +0,0 @@
/**
* @preserve HTML5 Shiv 3.7.3-pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=y.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=y.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),y.elements=c+" "+a,j(b)}function f(a){var b=x[a[v]];return b||(b={},w++,a[v]=w,x[w]=b),b}function g(a,c,d){if(c||(c=b),q)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():u.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||t.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),q)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return y.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(y,b.frag)}function j(a){a||(a=b);var d=f(a);return!y.shivCSS||p||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),q||i(a,d),a}function k(a){for(var b,c=a.getElementsByTagName("*"),e=c.length,f=RegExp("^(?:"+d().join("|")+")$","i"),g=[];e--;)b=c[e],f.test(b.nodeName)&&g.push(b.applyElement(l(b)));return g}function l(a){for(var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(A+":"+a.nodeName);d--;)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function m(a){for(var b,c=a.split("{"),e=c.length,f=RegExp("(^|[\\s,>+~])("+d().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),g="$1"+A+"\\:$2";e--;)b=c[e]=c[e].split("}"),b[b.length-1]=b[b.length-1].replace(f,g),c[e]=b.join("}");return c.join("{")}function n(a){for(var b=a.length;b--;)a[b].removeNode()}function o(a){function b(){clearTimeout(g._removeSheetTimer),d&&d.removeNode(!0),d=null}var d,e,g=f(a),h=a.namespaces,i=a.parentWindow;return!B||a.printShived?a:("undefined"==typeof h[A]&&h.add(A),i.attachEvent("onbeforeprint",function(){b();for(var f,g,h,i=a.styleSheets,j=[],l=i.length,n=Array(l);l--;)n[l]=i[l];for(;h=n.pop();)if(!h.disabled&&z.test(h.media)){try{f=h.imports,g=f.length}catch(o){g=0}for(l=0;g>l;l++)n.push(f[l]);try{j.push(h.cssText)}catch(o){}}j=m(j.reverse().join("")),e=k(a),d=c(a,j)}),i.attachEvent("onafterprint",function(){n(e),clearTimeout(g._removeSheetTimer),g._removeSheetTimer=setTimeout(b,500)}),a.printShived=!0,a)}var p,q,r="3.7.3",s=a.html5||{},t=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,u=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,v="_html5shiv",w=0,x={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",p="hidden"in a,q=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){p=!0,q=!0}}();var y={elements:s.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:r,shivCSS:s.shivCSS!==!1,supportsUnknownElements:q,shivMethods:s.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=y,j(b);var z=/^$|\b(?:all|print)\b/,A="html5shiv",B=!q&&function(){var c=b.documentElement;return!("undefined"==typeof b.namespaces||"undefined"==typeof b.parentWindow||"undefined"==typeof c.applyElement||"undefined"==typeof c.removeNode||"undefined"==typeof a.attachEvent)}();y.type+=" print",y.shivPrint=o,o(b),"object"==typeof module&&module.exports&&(module.exports=y)}("undefined"!=typeof window?window:this,document);

View file

@ -1,4 +0,0 @@
/**
* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3-pre",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document);

224
docs/_static/js/versions.js vendored Normal file
View file

@ -0,0 +1,224 @@
const themeFlyoutDisplay = "hidden";
const themeVersionSelector = "True";
const themeLanguageSelector = "True";
if (themeFlyoutDisplay === "attached") {
function renderLanguages(config) {
if (!config.projects.translations.length) {
return "";
}
const languagesHTML = `
<dl>
<dt>Languages</dt>
${config.projects.translations
.map(
(translation) => `
<dd ${translation.slug == config.projects.current.slug ? 'class="rtd-current-item"' : ""}>
<a href="${translation.urls.documentation}">${translation.language.code}</a>
</dd>
`,
)
.join("\n")}
</dl>
`;
return languagesHTML;
}
function renderVersions(config) {
if (!config.versions.active.length) {
return "";
}
const versionsHTML = `
<dl>
<dt>Versions</dt>
${config.versions.active
.map(
(version) => `
<dd ${version.slug === config.versions.current.slug ? 'class="rtd-current-item"' : ""}>
<a href="${version.urls.documentation}">${version.slug}</a>
</dd>
`,
)
.join("\n")}
</dl>
`;
return versionsHTML;
}
function renderDownloads(config) {
if (!Object.keys(config.versions.current.downloads).length) {
return "";
}
const downloadsNameDisplay = {
pdf: "PDF",
epub: "Epub",
htmlzip: "HTML",
};
const downloadsHTML = `
<dl>
<dt>Downloads</dt>
${Object.entries(config.versions.current.downloads)
.map(
([name, url]) => `
<dd>
<a href="${url}">${downloadsNameDisplay[name]}</a>
</dd>
`,
)
.join("\n")}
</dl>
`;
return downloadsHTML;
}
document.addEventListener("readthedocs-addons-data-ready", function (event) {
const config = event.detail.data();
const flyout = `
<div class="rst-versions" data-toggle="rst-versions" role="note">
<span class="rst-current-version" data-toggle="rst-current-version">
<span class="fa fa-book"> Read the Docs</span>
v: ${config.versions.current.slug}
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
<div class="injected">
${renderLanguages(config)}
${renderVersions(config)}
${renderDownloads(config)}
<dl>
<dt>On Read the Docs</dt>
<dd>
<a href="${config.projects.current.urls.home}">Project Home</a>
</dd>
<dd>
<a href="${config.projects.current.urls.builds}">Builds</a>
</dd>
<dd>
<a href="${config.projects.current.urls.downloads}">Downloads</a>
</dd>
</dl>
<dl>
<dt>Search</dt>
<dd>
<form id="flyout-search-form">
<input
class="wy-form"
type="text"
name="q"
aria-label="Search docs"
placeholder="Search docs"
/>
</form>
</dd>
</dl>
<hr />
<small>
<span>Hosted by <a href="https://about.readthedocs.org/?utm_source=&utm_content=flyout">Read the Docs</a></span>
</small>
</div>
</div>
`;
// Inject the generated flyout into the body HTML element.
document.body.insertAdjacentHTML("beforeend", flyout);
// Trigger the Read the Docs Addons Search modal when clicking on the "Search docs" input from inside the flyout.
document
.querySelector("#flyout-search-form")
.addEventListener("focusin", () => {
const event = new CustomEvent("readthedocs-search-show");
document.dispatchEvent(event);
});
})
}
if (themeLanguageSelector || themeVersionSelector) {
function onSelectorSwitch(event) {
const option = event.target.selectedIndex;
const item = event.target.options[option];
window.location.href = item.dataset.url;
}
document.addEventListener("readthedocs-addons-data-ready", function (event) {
const config = event.detail.data();
const versionSwitch = document.querySelector(
"div.switch-menus > div.version-switch",
);
if (themeVersionSelector) {
let versions = config.versions.active;
if (config.versions.current.hidden || config.versions.current.type === "external") {
versions.unshift(config.versions.current);
}
const versionSelect = `
<select>
${versions
.map(
(version) => `
<option
value="${version.slug}"
${config.versions.current.slug === version.slug ? 'selected="selected"' : ""}
data-url="${version.urls.documentation}">
${version.slug}
</option>`,
)
.join("\n")}
</select>
`;
versionSwitch.innerHTML = versionSelect;
versionSwitch.firstElementChild.addEventListener("change", onSelectorSwitch);
}
const languageSwitch = document.querySelector(
"div.switch-menus > div.language-switch",
);
if (themeLanguageSelector) {
if (config.projects.translations.length) {
// Add the current language to the options on the selector
let languages = config.projects.translations.concat(
config.projects.current,
);
languages = languages.sort((a, b) =>
a.language.name.localeCompare(b.language.name),
);
const languageSelect = `
<select>
${languages
.map(
(language) => `
<option
value="${language.language.code}"
${config.projects.current.slug === language.slug ? 'selected="selected"' : ""}
data-url="${language.urls.documentation}">
${language.language.name}
</option>`,
)
.join("\n")}
</select>
`;
languageSwitch.innerHTML = languageSelect;
languageSwitch.firstElementChild.addEventListener("change", onSelectorSwitch);
}
else {
languageSwitch.remove();
}
}
});
}
document.addEventListener("readthedocs-addons-data-ready", function (event) {
// Trigger the Read the Docs Addons Search modal when clicking on "Search docs" input from the topnav.
document
.querySelector("[role='search'] input")
.addEventListener("focusin", () => {
const event = new CustomEvent("readthedocs-search-show");
document.dispatchEvent(event);
});
});

View file

@ -1,13 +1,6 @@
/* /*
* language_data.js
* ~~~~~~~~~~~~~~~~
*
* This script contains the language-specific data used by searchtools.js, * This script contains the language-specific data used by searchtools.js,
* namely the list of stopwords, stemmer, scorer and splitter. * namely the list of stopwords, stemmer, scorer and splitter.
*
* :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/ */
var stopwords = ["a", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "near", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"]; var stopwords = ["a", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "near", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"];

View file

@ -1,12 +1,5 @@
/* /*
* searchtools.js
* ~~~~~~~~~~~~~~~~
*
* Sphinx JavaScript utilities for the full-text search. * Sphinx JavaScript utilities for the full-text search.
*
* :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/ */
"use strict"; "use strict";
@ -20,7 +13,7 @@ if (typeof Scorer === "undefined") {
// and returns the new score. // and returns the new score.
/* /*
score: result => { score: result => {
const [docname, title, anchor, descr, score, filename] = result const [docname, title, anchor, descr, score, filename, kind] = result
return score return score
}, },
*/ */
@ -47,6 +40,14 @@ if (typeof Scorer === "undefined") {
}; };
} }
// Global search result kind enum, used by themes to style search results.
class SearchResultKind {
static get index() { return "index"; }
static get object() { return "object"; }
static get text() { return "text"; }
static get title() { return "title"; }
}
const _removeChildren = (element) => { const _removeChildren = (element) => {
while (element && element.lastChild) element.removeChild(element.lastChild); while (element && element.lastChild) element.removeChild(element.lastChild);
}; };
@ -64,9 +65,13 @@ const _displayItem = (item, searchTerms, highlightTerms) => {
const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY; const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY;
const contentRoot = document.documentElement.dataset.content_root; const contentRoot = document.documentElement.dataset.content_root;
const [docName, title, anchor, descr, score, _filename] = item; const [docName, title, anchor, descr, score, _filename, kind] = item;
let listItem = document.createElement("li"); let listItem = document.createElement("li");
// Add a class representing the item's type:
// can be used by a theme's CSS selector for styling
// See SearchResultKind for the class names.
listItem.classList.add(`kind-${kind}`);
let requestUrl; let requestUrl;
let linkUrl; let linkUrl;
if (docBuilder === "dirhtml") { if (docBuilder === "dirhtml") {
@ -115,8 +120,10 @@ const _finishSearch = (resultCount) => {
"Your search did not match any documents. Please make sure that all words are spelled correctly and that you've selected enough categories." "Your search did not match any documents. Please make sure that all words are spelled correctly and that you've selected enough categories."
); );
else else
Search.status.innerText = _( Search.status.innerText = Documentation.ngettext(
"Search finished, found ${resultCount} page(s) matching the search query." "Search finished, found one page matching the search query.",
"Search finished, found ${resultCount} pages matching the search query.",
resultCount,
).replace('${resultCount}', resultCount); ).replace('${resultCount}', resultCount);
}; };
const _displayNextItem = ( const _displayNextItem = (
@ -138,7 +145,7 @@ const _displayNextItem = (
else _finishSearch(resultCount); else _finishSearch(resultCount);
}; };
// Helper function used by query() to order search results. // Helper function used by query() to order search results.
// Each input is an array of [docname, title, anchor, descr, score, filename]. // Each input is an array of [docname, title, anchor, descr, score, filename, kind].
// Order the results by score (in opposite order of appearance, since the // Order the results by score (in opposite order of appearance, since the
// `_displayNextItem` function uses pop() to retrieve items) and then alphabetically. // `_displayNextItem` function uses pop() to retrieve items) and then alphabetically.
const _orderResultsByScoreThenName = (a, b) => { const _orderResultsByScoreThenName = (a, b) => {
@ -178,7 +185,7 @@ const Search = {
htmlToText: (htmlString, anchor) => { htmlToText: (htmlString, anchor) => {
const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html'); const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html');
for (const removalQuery of [".headerlinks", "script", "style"]) { for (const removalQuery of [".headerlink", "script", "style"]) {
htmlElement.querySelectorAll(removalQuery).forEach((el) => { el.remove() }); htmlElement.querySelectorAll(removalQuery).forEach((el) => { el.remove() });
} }
if (anchor) { if (anchor) {
@ -248,6 +255,7 @@ const Search = {
searchSummary.classList.add("search-summary"); searchSummary.classList.add("search-summary");
searchSummary.innerText = ""; searchSummary.innerText = "";
const searchList = document.createElement("ul"); const searchList = document.createElement("ul");
searchList.setAttribute("role", "list");
searchList.classList.add("search"); searchList.classList.add("search");
const out = document.getElementById("search-results"); const out = document.getElementById("search-results");
@ -318,7 +326,7 @@ const Search = {
const indexEntries = Search._index.indexentries; const indexEntries = Search._index.indexentries;
// Collect multiple result groups to be sorted separately and then ordered. // Collect multiple result groups to be sorted separately and then ordered.
// Each is an array of [docname, title, anchor, descr, score, filename]. // Each is an array of [docname, title, anchor, descr, score, filename, kind].
const normalResults = []; const normalResults = [];
const nonMainIndexResults = []; const nonMainIndexResults = [];
@ -328,14 +336,16 @@ const Search = {
for (const [title, foundTitles] of Object.entries(allTitles)) { for (const [title, foundTitles] of Object.entries(allTitles)) {
if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) { if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) {
for (const [file, id] of foundTitles) { for (const [file, id] of foundTitles) {
let score = Math.round(100 * queryLower.length / title.length) const score = Math.round(Scorer.title * queryLower.length / title.length);
const boost = titles[file] === title ? 1 : 0; // add a boost for document titles
normalResults.push([ normalResults.push([
docNames[file], docNames[file],
titles[file] !== title ? `${titles[file]} > ${title}` : title, titles[file] !== title ? `${titles[file]} > ${title}` : title,
id !== null ? "#" + id : "", id !== null ? "#" + id : "",
null, null,
score, score + boost,
filenames[file], filenames[file],
SearchResultKind.title,
]); ]);
} }
} }
@ -353,6 +363,7 @@ const Search = {
null, null,
score, score,
filenames[file], filenames[file],
SearchResultKind.index,
]; ];
if (isMain) { if (isMain) {
normalResults.push(result); normalResults.push(result);
@ -474,6 +485,7 @@ const Search = {
descr, descr,
score, score,
filenames[match[0]], filenames[match[0]],
SearchResultKind.object,
]); ]);
}; };
Object.keys(objects).forEach((prefix) => Object.keys(objects).forEach((prefix) =>
@ -584,6 +596,7 @@ const Search = {
null, null,
score, score,
filenames[file], filenames[file],
SearchResultKind.text,
]); ]);
} }
return results; return results;

View file

@ -1,3 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./"> <html class="writer-html5" lang="en" data-content_root="./">
<head> <head>
@ -6,19 +8,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dynamic Bindings &mdash; Raylib Python documentation</title> <title>Dynamic Bindings &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" /> <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" /> <link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=fd3f3429" /> <link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
<!--[if lt IE 9]> <script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/js/html5shiv.min.js"></script> <script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<![endif]--> <script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/jquery.js?v=5d32c60e"></script> <script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script> <script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" /> <link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" /> <link rel="search" title="Search" href="search.html" />

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./"> <html class="writer-html5" lang="en" data-content_root="./">
<head> <head>
@ -6,19 +8,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Raylib Python &mdash; Raylib Python documentation</title> <title>Raylib Python &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" /> <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" /> <link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=fd3f3429" /> <link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
<!--[if lt IE 9]> <script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/js/html5shiv.min.js"></script> <script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<![endif]--> <script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/jquery.js?v=5d32c60e"></script> <script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script> <script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" /> <link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" /> <link rel="search" title="Search" href="search.html" />

Binary file not shown.

View file

@ -1,3 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./"> <html class="writer-html5" lang="en" data-content_root="./">
<head> <head>
@ -5,19 +7,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Python Module Index &mdash; Raylib Python documentation</title> <title>Python Module Index &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" /> <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" /> <link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=fd3f3429" /> <link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
<!--[if lt IE 9]> <script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/js/html5shiv.min.js"></script> <script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<![endif]--> <script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/jquery.js?v=5d32c60e"></script> <script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script> <script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" /> <link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" /> <link rel="search" title="Search" href="search.html" />

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./"> <html class="writer-html5" lang="en" data-content_root="./">
<head> <head>
@ -5,20 +7,16 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Search &mdash; Raylib Python documentation</title> <title>Search &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" /> <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" /> <link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=fd3f3429" /> <link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
<!--[if lt IE 9]> <script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/js/html5shiv.min.js"></script> <script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<![endif]--> <script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/jquery.js?v=5d32c60e"></script> <script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script> <script src="_static/js/theme.js"></script>
<script src="_static/searchtools.js"></script> <script src="_static/searchtools.js"></script>
<script src="_static/language_data.js"></script> <script src="_static/language_data.js"></script>

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -7,17 +7,7 @@ RAYLIB_VERSION: str = "5.0"
PI: float = 3.141592653589793 PI: float = 3.141592653589793
DEG2RAD = PI / 180.0 DEG2RAD = PI / 180.0
RAD2DEG = 180.0 / PI RAD2DEG = 180.0 / PI
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
PI: float = 3.141592653589793
EPSILON: float = 1e-06 EPSILON: float = 1e-06
DEG2RAD = PI / 180.0
RAD2DEG = 180.0 / PI
RLGL_VERSION: str = "4.5" RLGL_VERSION: str = "4.5"
RL_DEFAULT_BATCH_BUFFER_ELEMENTS: int = 8192 RL_DEFAULT_BATCH_BUFFER_ELEMENTS: int = 8192
RL_DEFAULT_BATCH_BUFFERS: int = 1 RL_DEFAULT_BATCH_BUFFERS: int = 1
@ -89,11 +79,6 @@ RL_BLEND_SRC_RGB: int = 32969
RL_BLEND_DST_ALPHA: int = 32970 RL_BLEND_DST_ALPHA: int = 32970
RL_BLEND_SRC_ALPHA: int = 32971 RL_BLEND_SRC_ALPHA: int = 32971
RL_BLEND_COLOR: int = 32773 RL_BLEND_COLOR: int = 32773
RL_SHADER_LOC_MAP_DIFFUSE = raylib.RL_SHADER_LOC_MAP_ALBEDO
RL_SHADER_LOC_MAP_SPECULAR = raylib.RL_SHADER_LOC_MAP_METALNESS
PI: float = 3.141592653589793
DEG2RAD = PI / 180.0
RAD2DEG = 180.0 / PI
GL_SHADING_LANGUAGE_VERSION: int = 35724 GL_SHADING_LANGUAGE_VERSION: int = 35724
GL_COMPRESSED_RGB_S3TC_DXT1_EXT: int = 33776 GL_COMPRESSED_RGB_S3TC_DXT1_EXT: int = 33776
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: int = 33777 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: int = 33777

View file

@ -6,26 +6,6 @@ raylib [audio] example - playing
import dataclasses import dataclasses
import pyray import pyray
import raylib as rl import raylib as rl
from raylib.colors import (
RAYWHITE,
ORANGE,
RED,
GOLD,
LIME,
BLUE,
VIOLET,
BROWN,
LIGHTGRAY,
PINK,
YELLOW,
GREEN,
SKYBLUE,
PURPLE,
BEIGE,
MAROON,
GRAY,
BLACK
)
MAX_CIRCLES=64 MAX_CIRCLES=64
@ -33,12 +13,11 @@ MAX_CIRCLES=64
@dataclasses.dataclass @dataclasses.dataclass
class CircleWave: class CircleWave:
position: 'rl.Vector2' position: pyray.Vector2
radius: float radius: float
alpha: float alpha: float
speed: float speed: float
color: 'rl.Color' color: pyray.Color
screenWidth = 800 screenWidth = 800
screenHeight = 450 screenHeight = 450
@ -49,8 +28,8 @@ rl.InitWindow(screenWidth, screenHeight, b"raylib [audio] example - module playi
rl.InitAudioDevice() # Initialize audio device rl.InitAudioDevice() # Initialize audio device
colors = [ ORANGE, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, colors = [pyray.ORANGE, pyray.RED, pyray.GOLD, pyray.LIME, pyray.BLUE, pyray.VIOLET, pyray.BROWN, pyray.LIGHTGRAY, pyray.PINK,
YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE ] pyray.YELLOW, pyray.GREEN, pyray.SKYBLUE, pyray.PURPLE, pyray.BEIGE]
# Creates some circles for visual effect # Creates some circles for visual effect
circles = [] circles = []
@ -141,23 +120,23 @@ while not rl.WindowShouldClose(): # Detect window close button or ESC key
#---------------------------------------------------------------------------------- #----------------------------------------------------------------------------------
pyray.begin_drawing() pyray.begin_drawing()
pyray.clear_background(RAYWHITE) pyray.clear_background(pyray.RAYWHITE)
for i in range(MAX_CIRCLES): for i in range(MAX_CIRCLES):
pyray.draw_circle_v(circles[i].position, circles[i].radius, rl.Fade(circles[i].color, circles[i].alpha)) pyray.draw_circle_v(circles[i].position, circles[i].radius, pyray.fade(circles[i].color, circles[i].alpha))
# Draw time bar # Draw time bar
pyray.draw_rectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, LIGHTGRAY) pyray.draw_rectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, pyray.LIGHTGRAY)
pyray.draw_rectangle(20, screenHeight - 20 - 12, int(timePlayed), 12, MAROON) pyray.draw_rectangle(20, screenHeight - 20 - 12, int(timePlayed), 12, pyray.MAROON)
pyray.draw_rectangle_lines(20, screenHeight - 20 - 12, screenWidth - 40, 12, GRAY) pyray.draw_rectangle_lines(20, screenHeight - 20 - 12, screenWidth - 40, 12, pyray.GRAY)
# Draw help instructions # Draw help instructions
pyray.draw_rectangle(20, 20, 425, 145, RAYWHITE) pyray.draw_rectangle(20, 20, 425, 145, pyray.RAYWHITE)
pyray.draw_rectangle_lines(20, 20, 425, 145, GRAY) pyray.draw_rectangle_lines(20, 20, 425, 145, pyray.GRAY)
pyray.draw_text("PRESS SPACE TO RESTART MUSIC", 40, 40, 20, BLACK) pyray.draw_text("PRESS SPACE TO RESTART MUSIC", 40, 40, 20, pyray.BLACK)
pyray.draw_text("PRESS P TO PAUSE/RESUME", 40, 70, 20, BLACK) pyray.draw_text("PRESS P TO PAUSE/RESUME", 40, 70, 20, pyray.BLACK)
pyray.draw_text("PRESS UP/DOWN TO CHANGE SPEED", 40, 100, 20, BLACK) pyray.draw_text("PRESS UP/DOWN TO CHANGE SPEED", 40, 100, 20, pyray.BLACK)
pyray.draw_text(f"SPEED: {pitch}", 40, 130, 20, MAROON) pyray.draw_text(f"SPEED: {pitch}", 40, 130, 20, pyray.MAROON)
pyray.end_drawing() pyray.end_drawing()
#---------------------------------------------------------------------------------- #----------------------------------------------------------------------------------

View file

@ -57,18 +57,18 @@ while not pyray.window_should_close(): # Detect window close button or ESC key
# Update # Update
# Player movement # Player movement
if pyray.is_key_down(pyray.KEY_RIGHT): if pyray.is_key_down(pyray.KeyboardKey.KEY_RIGHT):
player.x += 2 player.x += 2
elif pyray.is_key_down(pyray.KEY_LEFT): elif pyray.is_key_down(pyray.KeyboardKey.KEY_LEFT):
player.x -= 2 player.x -= 2
# Camera target follows player # Camera target follows player
camera.target = pyray.Vector2(player.x + 20, player.y + 20) camera.target = pyray.Vector2(player.x + 20, player.y + 20)
# Camera rotation controls # Camera rotation controls
if pyray.is_key_down(pyray.KEY_A): if pyray.is_key_down(pyray.KeyboardKey.KEY_A):
camera.rotation -= 1 camera.rotation -= 1
elif pyray.is_key_down(pyray.KEY_S): elif pyray.is_key_down(pyray.KeyboardKey.KEY_S):
camera.rotation += 1 camera.rotation += 1
# Limit camera rotation to 80 degrees (-40 to 40) # Limit camera rotation to 80 degrees (-40 to 40)
@ -86,7 +86,7 @@ while not pyray.window_should_close(): # Detect window close button or ESC key
camera.zoom = 0.1 camera.zoom = 0.1
# Camera reset (zoom and rotation) # Camera reset (zoom and rotation)
if pyray.is_key_pressed(pyray.KEY_R): if pyray.is_key_pressed(pyray.KeyboardKey.KEY_R):
camera.zoom = 1.0 camera.zoom = 1.0
camera.rotation = 0.0 camera.rotation = 0.0

View file

@ -13,15 +13,14 @@ pyray.set_target_fps(60)
camera = pyray.Camera2D() camera = pyray.Camera2D()
camera = pyray.Camera2D()
camera.zoom = 1.0 camera.zoom = 1.0
pyray.set_target_fps(60); pyray.set_target_fps(60)
# main game loop # main game loop
while not pyray.window_should_close(): while not pyray.window_should_close():
# update # update
if pyray.is_mouse_button_down(pyray.MOUSE_BUTTON_RIGHT): if pyray.is_mouse_button_down(pyray.MouseButton.MOUSE_BUTTON_RIGHT):
delta = pyray.get_mouse_delta() delta = pyray.get_mouse_delta()
delta = pyray.vector2_scale(delta, -1.0 / camera.zoom) delta = pyray.vector2_scale(delta, -1.0 / camera.zoom)
camera.target = pyray.vector2_add(camera.target, delta) camera.target = pyray.vector2_add(camera.target, delta)
@ -58,7 +57,7 @@ while not pyray.window_should_close():
pyray.end_mode_2d() pyray.end_mode_2d()
pyray.draw_text("Mouse right button drag to move, mouse wheel to zoom", 10, 10, 20, pyray.WHITE); pyray.draw_text("Mouse right button drag to move, mouse wheel to zoom", 10, 10, 20, pyray.WHITE)
pyray.end_drawing() pyray.end_drawing()

View file

@ -62,11 +62,11 @@ class EnvItem:
def update_player(player, env_items, delta): def update_player(player, env_items, delta):
if pyray.is_key_down(pyray.KEY_LEFT): if pyray.is_key_down(pyray.KeyboardKey.KEY_LEFT):
player.position.x -= PLAYER_HOR_SPD * delta player.position.x -= PLAYER_HOR_SPD * delta
if pyray.is_key_down(pyray.KEY_RIGHT): if pyray.is_key_down(pyray.KeyboardKey.KEY_RIGHT):
player.position.x += PLAYER_HOR_SPD * delta player.position.x += PLAYER_HOR_SPD * delta
if pyray.is_key_down(pyray.KEY_SPACE) and player.can_jump: if pyray.is_key_down(pyray.KeyboardKey.KEY_SPACE) and player.can_jump:
player.speed = -PLAYER_JUMP_SPD player.speed = -PLAYER_JUMP_SPD
player.can_jump = False player.can_jump = False
@ -264,11 +264,11 @@ while not pyray.window_should_close(): # Detect window close button or ESC key
elif camera.zoom < 0.25: elif camera.zoom < 0.25:
camera.zoom = 0.25 camera.zoom = 0.25
if pyray.is_key_pressed(pyray.KEY_R): if pyray.is_key_pressed(pyray.KeyboardKey.KEY_R):
camera.zoom = 1.0 camera.zoom = 1.0
player.position = pyray.Vector2(400, 280) player.position = pyray.Vector2(400, 280)
if pyray.is_key_pressed(pyray.KEY_C): if pyray.is_key_pressed(pyray.KeyboardKey.KEY_C):
camera_option = (camera_option + 1) % camera_updaters_length camera_option = (camera_option + 1) % camera_updaters_length
# Call update camera function by its pointer # Call update camera function by its pointer

View file

@ -10,7 +10,7 @@ MAX_COLUMNS = 20
SCREEN_WIDTH = 800 SCREEN_WIDTH = 800
SCREEN_HEIGHT = 450 SCREEN_HEIGHT = 450
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, b"raylib [core] example - 3d camera first person") pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [core] example - 3d camera first person")
# Define the camera to look into our 3d world (position, target, up vector) # Define the camera to look into our 3d world (position, target, up vector)
camera = pyray.Camera3D() camera = pyray.Camera3D()
@ -18,24 +18,24 @@ camera.position = pyray.Vector3(4.0, 2.0, 4.0)
camera.target = pyray.Vector3(0.0, 1.8, 0.0) camera.target = pyray.Vector3(0.0, 1.8, 0.0)
camera.up = pyray.Vector3(0.0, 1.0, 0.0) camera.up = pyray.Vector3(0.0, 1.0, 0.0)
camera.fovy = 60.0 camera.fovy = 60.0
camera.projection = pyray.CAMERA_PERSPECTIVE camera.projection = pyray.CameraProjection.CAMERA_PERSPECTIVE
# Generates some random columns # Generates some random columns
heights = [None] * MAX_COLUMNS heights = []
positions = [None] * MAX_COLUMNS positions = []
colors = [None] * MAX_COLUMNS colors = []
for i in range(MAX_COLUMNS): for i in range(MAX_COLUMNS):
heights[i] = pyray.get_random_value(1, 12) * 1.0 heights.append(pyray.get_random_value(1, 12) * 1.0)
positions[i] = pyray.Vector3(pyray.get_random_value(-15, 15) * 1.0, heights[i]/2.0 * 1.0, pyray.get_random_value(-15, 15) * 1.0) positions.append(pyray.Vector3(pyray.get_random_value(-15, 15) * 1.0, heights[i]/2.0 * 1.0, pyray.get_random_value(-15, 15) * 1.0))
colors[i] = pyray.Color(pyray.get_random_value(20, 255), pyray.get_random_value(10, 55), 30, 255) colors.append(pyray.Color(pyray.get_random_value(20, 255), pyray.get_random_value(10, 55), 30, 255))
pyray.set_target_fps(60) pyray.set_target_fps(60)
while not pyray.window_should_close(): while not pyray.window_should_close():
pyray.update_camera(camera, pyray.CAMERA_FIRST_PERSON) pyray.update_camera(camera, pyray.CameraMode.CAMERA_FIRST_PERSON)
pyray.begin_drawing() pyray.begin_drawing()

View file

@ -25,7 +25,7 @@ while not window_should_close(): # Detect window close button or ESC key
# Update # Update
update_camera(camera, CameraMode.CAMERA_FREE) update_camera(camera, CameraMode.CAMERA_FREE)
if is_key_pressed(KEY_Z): if is_key_pressed(KeyboardKey.KEY_Z):
camera.target = Vector3(0.0, 0.0, 0.0) camera.target = Vector3(0.0, 0.0, 0.0)
# Draw # Draw

View file

@ -40,7 +40,7 @@ while not pyray.window_should_close():
pyray.end_mode_3d() pyray.end_mode_3d()
pyray.draw_text("Welcome to the third dimension!", 10, 40, 20, pyray.DARKGRAY); pyray.draw_text("Welcome to the third dimension!", 10, 40, 20, pyray.DARKGRAY)
pyray.draw_fps(10, 10) pyray.draw_fps(10, 10)

View file

@ -27,13 +27,13 @@ def main():
if frame_count > 120: if frame_count > 120:
current_screen = GameScreen.TITLE current_screen = GameScreen.TITLE
elif current_screen == GameScreen.TITLE: elif current_screen == GameScreen.TITLE:
if is_key_pressed(KEY_ENTER) or is_gesture_detected(GESTURE_TAP): if is_key_pressed(KeyboardKey.KEY_ENTER) or is_gesture_detected(Gesture.GESTURE_TAP):
current_screen = GameScreen.GAMEPLAY current_screen = GameScreen.GAMEPLAY
elif current_screen == GameScreen.GAMEPLAY: elif current_screen == GameScreen.GAMEPLAY:
if is_key_pressed(KEY_ENTER) or is_gesture_detected(GESTURE_TAP): if is_key_pressed(KeyboardKey.KEY_ENTER) or is_gesture_detected(Gesture.GESTURE_TAP):
current_screen = GameScreen.ENDING current_screen = GameScreen.ENDING
elif current_screen == GameScreen.ENDING: elif current_screen == GameScreen.ENDING:
if is_key_pressed(KEY_ENTER) or is_gesture_detected(GESTURE_TAP): if is_key_pressed(KeyboardKey.KEY_ENTER) or is_gesture_detected(Gesture.GESTURE_TAP):
current_screen = GameScreen.TITLE current_screen = GameScreen.TITLE
begin_drawing() begin_drawing()

View file

@ -11,12 +11,6 @@
""" """
import pyray import pyray
from raylib.colors import (
RAYWHITE,
DARKGRAY,
LIGHTGRAY,
GRAY
)
screenWidth = 800 screenWidth = 800
screenHeight = 450 screenHeight = 450
@ -36,21 +30,21 @@ while not pyray.window_should_close():
pyray.begin_drawing() pyray.begin_drawing()
pyray.clear_background(RAYWHITE) pyray.clear_background(pyray.RAYWHITE)
if droppedFiles.count == 0: if droppedFiles.count == 0:
pyray.draw_text("Drop your files to this window!", 100, 40, 20, DARKGRAY) pyray.draw_text("Drop your files to this window!", 100, 40, 20, pyray.DARKGRAY)
else: else:
pyray.draw_text("Dropped files:", 100, 40, 20, DARKGRAY) pyray.draw_text("Dropped files:", 100, 40, 20, pyray.DARKGRAY)
for i in range(0, droppedFiles.count): for i in range(0, droppedFiles.count):
if i % 2 == 0: if i % 2 == 0:
pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(LIGHTGRAY, 0.5)) pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(pyray.LIGHTGRAY, 0.5))
else: else:
pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(LIGHTGRAY, 0.3)) pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(pyray.LIGHTGRAY, 0.3))
pyray.draw_text(droppedFiles.paths[i], 120, 100 + 40*i, 10, GRAY) pyray.draw_text(droppedFiles.paths[i], 120, 100 + 40*i, 10, pyray.GRAY)
pyray.draw_text("Drop new files...", 100, 110 + 40*droppedFiles.count, 20, DARKGRAY) pyray.draw_text("Drop new files...", 100, 110 + 40*droppedFiles.count, 20, pyray.DARKGRAY)
pyray.end_drawing() pyray.end_drawing()
# De-Initialization # De-Initialization

View file

@ -4,13 +4,6 @@ raylib [core] example - Input Gestures Detection
""" """
import pyray import pyray
from raylib.colors import (
RAYWHITE,
LIGHTGRAY,
DARKGRAY,
MAROON,
GRAY,
)
@ -26,20 +19,20 @@ touch_area = pyray.Rectangle(220, 10, SCREEN_WIDTH - 230, SCREEN_HEIGHT - 20)
gesture_strings = [] gesture_strings = []
current_gesture = pyray.GESTURE_NONE current_gesture = pyray.Gesture.GESTURE_NONE
last_gesture = pyray.GESTURE_NONE last_gesture = pyray.Gesture.GESTURE_NONE
GESTURE_LABELS = { GESTURE_LABELS = {
pyray.GESTURE_TAP: 'GESTURE TAP', pyray.Gesture.GESTURE_TAP: 'GESTURE TAP',
pyray.GESTURE_DOUBLETAP: 'GESTURE DOUBLETAP', pyray.Gesture.GESTURE_DOUBLETAP: 'GESTURE DOUBLETAP',
pyray.GESTURE_HOLD: 'GESTURE HOLD', pyray.Gesture.GESTURE_HOLD: 'GESTURE HOLD',
pyray.GESTURE_DRAG: 'GESTURE DRAG', pyray.Gesture.GESTURE_DRAG: 'GESTURE DRAG',
pyray.GESTURE_SWIPE_RIGHT: 'GESTURE SWIPE RIGHT', pyray.Gesture.GESTURE_SWIPE_RIGHT: 'GESTURE SWIPE RIGHT',
pyray.GESTURE_SWIPE_LEFT: 'GESTURE SWIPE LEFT', pyray.Gesture.GESTURE_SWIPE_LEFT: 'GESTURE SWIPE LEFT',
pyray.GESTURE_SWIPE_UP: 'GESTURE SWIPE UP', pyray.Gesture.GESTURE_SWIPE_UP: 'GESTURE SWIPE UP',
pyray.GESTURE_SWIPE_DOWN: 'GESTURE SWIPE DOWN', pyray.Gesture.GESTURE_SWIPE_DOWN: 'GESTURE SWIPE DOWN',
pyray.GESTURE_PINCH_IN: 'GESTURE PINCH IN', pyray.Gesture.GESTURE_PINCH_IN: 'GESTURE PINCH IN',
pyray.GESTURE_PINCH_OUT: 'GESTURE PINCH OUT', pyray.Gesture.GESTURE_PINCH_OUT: 'GESTURE PINCH OUT',
} }
pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second
@ -54,7 +47,7 @@ while not pyray.window_should_close(): # Detect window close button or ESC key
if ( if (
pyray.check_collision_point_rec(touch_position, touch_area) pyray.check_collision_point_rec(touch_position, touch_area)
and current_gesture != pyray.GESTURE_NONE and current_gesture != pyray.Gesture.GESTURE_NONE
): ):
if current_gesture != last_gesture: if current_gesture != last_gesture:
gesture_strings.append(GESTURE_LABELS[current_gesture]) gesture_strings.append(GESTURE_LABELS[current_gesture])
@ -66,34 +59,34 @@ while not pyray.window_should_close(): # Detect window close button or ESC key
# Draw # Draw
pyray.begin_drawing() pyray.begin_drawing()
pyray.clear_background(RAYWHITE) pyray.clear_background(pyray.RAYWHITE)
pyray.draw_rectangle_rec(touch_area, GRAY) pyray.draw_rectangle_rec(touch_area, pyray.GRAY)
pyray.draw_rectangle(225, 15, SCREEN_WIDTH - 240, SCREEN_HEIGHT - 30, pyray.draw_rectangle(225, 15, SCREEN_WIDTH - 240, SCREEN_HEIGHT - 30,
RAYWHITE) pyray.RAYWHITE)
pyray.draw_text( pyray.draw_text(
'GESTURES TEST AREA', 'GESTURES TEST AREA',
SCREEN_WIDTH - 270, SCREEN_HEIGHT - 40, 20, pyray.fade(GRAY, 0.5) SCREEN_WIDTH - 270, SCREEN_HEIGHT - 40, 20, pyray.fade(pyray.GRAY, 0.5)
) )
for i, val in enumerate(gesture_strings): for i, val in enumerate(gesture_strings):
if i % 2 == 0: if i % 2 == 0:
pyray.draw_rectangle( pyray.draw_rectangle(
10, 30 + 20 * i, 200, 20, pyray.fade(LIGHTGRAY, 0.5)) 10, 30 + 20 * i, 200, 20, pyray.fade(pyray.LIGHTGRAY, 0.5))
else: else:
pyray.draw_rectangle( pyray.draw_rectangle(
10, 30 + 20 * i, 200, 20, pyray.fade(LIGHTGRAY, 0.3)) 10, 30 + 20 * i, 200, 20, pyray.fade(pyray.LIGHTGRAY, 0.3))
if i < len(gesture_strings) - 1: if i < len(gesture_strings) - 1:
pyray.draw_text(val, 35, 36 + 20 * i, 10, DARKGRAY) pyray.draw_text(val, 35, 36 + 20 * i, 10, pyray.DARKGRAY)
else: else:
pyray.draw_text(val, 35, 36 + 20 * i, 10, MAROON) pyray.draw_text(val, 35, 36 + 20 * i, 10, pyray.MAROON)
pyray.draw_rectangle_lines(10, 29, 200, SCREEN_HEIGHT - 50, GRAY) pyray.draw_rectangle_lines(10, 29, 200, SCREEN_HEIGHT - 50, pyray.GRAY)
pyray.draw_text('DETECTED GESTURES', 50, 15, 10, GRAY) pyray.draw_text('DETECTED GESTURES', 50, 15, 10, pyray.GRAY)
if current_gesture != pyray.GESTURE_NONE: if current_gesture != pyray.Gesture.GESTURE_NONE:
pyray.draw_circle_v(touch_position, 30, MAROON) pyray.draw_circle_v(touch_position, 30, pyray.MAROON)
pyray.end_drawing() pyray.end_drawing()

View file

@ -19,13 +19,13 @@ pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second
# Main game loop # Main game loop
while not pyray.window_should_close(): # Detect window close button or ESC key while not pyray.window_should_close(): # Detect window close button or ESC key
# Update # Update
if pyray.is_key_down(pyray.KEY_RIGHT): if pyray.is_key_down(pyray.KeyboardKey.KEY_RIGHT):
ball_position.x += 2 ball_position.x += 2
if pyray.is_key_down(pyray.KEY_LEFT): if pyray.is_key_down(pyray.KeyboardKey.KEY_LEFT):
ball_position.x -= 2 ball_position.x -= 2
if pyray.is_key_down(pyray.KEY_UP): if pyray.is_key_down(pyray.KeyboardKey.KEY_UP):
ball_position.y -= 2 ball_position.y -= 2
if pyray.is_key_down(pyray.KEY_DOWN): if pyray.is_key_down(pyray.KeyboardKey.KEY_DOWN):
ball_position.y += 2 ball_position.y += 2
# Draw # Draw

View file

@ -22,19 +22,19 @@ while not window_should_close(): # Detect window close button or ESC key
# Update # Update
ball_position = get_mouse_position() ball_position = get_mouse_position()
if is_mouse_button_pressed(MOUSE_BUTTON_LEFT): if is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_LEFT):
ball_color = MAROON ball_color = MAROON
elif is_mouse_button_pressed(MOUSE_BUTTON_MIDDLE): elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_MIDDLE):
ball_color = LIME ball_color = LIME
elif is_mouse_button_pressed(MOUSE_BUTTON_RIGHT): elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_RIGHT):
ball_color = DARKBLUE ball_color = DARKBLUE
elif is_mouse_button_pressed(MOUSE_BUTTON_SIDE): elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_SIDE):
ball_color = PURPLE ball_color = PURPLE
elif is_mouse_button_pressed(MOUSE_BUTTON_EXTRA): elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_EXTRA):
ball_color = YELLOW ball_color = YELLOW
elif is_mouse_button_pressed(MOUSE_BUTTON_FORWARD): elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_FORWARD):
ball_color = ORANGE ball_color = ORANGE
elif is_mouse_button_pressed(MOUSE_BUTTON_BACK): elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_BACK):
ball_color = BEIGE ball_color = BEIGE
# Draw # Draw
begin_drawing() begin_drawing()

View file

@ -23,7 +23,7 @@ set_target_fps(60) # Set our game to run at 60 frames-per-second
while not window_should_close(): # Detect window close button or ESC key while not window_should_close(): # Detect window close button or ESC key
# Update # Update
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
if is_key_pressed(KEY_S): if is_key_pressed(KeyboardKey.KEY_S):
scissorMode = not scissorMode scissorMode = not scissorMode
# Centre the scissor area around the mouse position # Centre the scissor area around the mouse position

View file

@ -18,7 +18,7 @@ worldSpaceCamera.zoom = 1.0
screenSpaceCamera = Camera2D([0]) # Smoothing camera screenSpaceCamera = Camera2D([0]) # Smoothing camera
screenSpaceCamera.zoom = 1.0 screenSpaceCamera.zoom = 1.0
target = load_render_texture(virtualScreenWidth, virtualScreenHeight); # This is where we'll draw all our objects. target = load_render_texture(virtualScreenWidth, virtualScreenHeight) # This is where we'll draw all our objects.
rec01 = Rectangle(70.0, 35.0, 20.0, 20.0) rec01 = Rectangle(70.0, 35.0, 20.0, 20.0)
rec02 = Rectangle(90.0, 55.0, 30.0, 10.0) rec02 = Rectangle(90.0, 55.0, 30.0, 10.0)
@ -42,7 +42,7 @@ while not window_should_close(): # Detect window close button or ESC key
# Update # Update
rotation += 60.0 *get_frame_time(); # Rotate the rectangles, 60 degrees per second rotation += 60.0 *get_frame_time() # Rotate the rectangles, 60 degrees per second
# Make the camera move to demonstrate the effect # Make the camera move to demonstrate the effect
cameraX = (math.sin(get_time())*50.0) - 10.0 cameraX = (math.sin(get_time())*50.0) - 10.0

View file

@ -66,21 +66,21 @@ while not window_should_close(): # Detect window close button or ESC key
# Move Player1 forward and backwards (no turning) # Move Player1 forward and backwards (no turning)
if is_key_down(KEY_W): if is_key_down(KeyboardKey.KEY_W):
cameraPlayer1.position.z += offsetThisFrame cameraPlayer1.position.z += offsetThisFrame
cameraPlayer1.target.z += offsetThisFrame cameraPlayer1.target.z += offsetThisFrame
elif is_key_down(KEY_S): elif is_key_down(KeyboardKey.KEY_S):
cameraPlayer1.position.z -= offsetThisFrame cameraPlayer1.position.z -= offsetThisFrame
cameraPlayer1.target.z -= offsetThisFrame cameraPlayer1.target.z -= offsetThisFrame
# Move Player2 forward and backwards (no turning) # Move Player2 forward and backwards (no turning)
if is_key_down(KEY_UP): if is_key_down(KeyboardKey.KEY_UP):
cameraPlayer2.position.x += offsetThisFrame cameraPlayer2.position.x += offsetThisFrame
cameraPlayer2.target.x += offsetThisFrame cameraPlayer2.target.x += offsetThisFrame
elif is_key_down(KEY_DOWN): elif is_key_down(KeyboardKey.KEY_DOWN):
cameraPlayer2.position cameraPlayer2.position
cameraPlayer2.position.x -= offsetThisFrame cameraPlayer2.position.x -= offsetThisFrame
cameraPlayer2.target.x -= offsetThisFrame cameraPlayer2.target.x -= offsetThisFrame

View file

@ -17,7 +17,6 @@ device = pyray.VrDeviceInfo(
1200, # Vertical resolution in pixels 1200, # Vertical resolution in pixels
0.133793, # Horizontal size in meters 0.133793, # Horizontal size in meters
0.0669, # Vertical size in meters 0.0669, # Vertical size in meters
0.04678, # Screen center in meters
0.041, # Distance between eye and display in meters 0.041, # Distance between eye and display in meters
0.07, # Lens separation distance in meters 0.07, # Lens separation distance in meters
0.07, # IPD (distance between pupils) in meters 0.07, # IPD (distance between pupils) in meters
@ -35,15 +34,15 @@ config = pyray.load_vr_stereo_config(device)
distortion = pyray.load_shader(pyray.ffi.NULL, f"resources/distortion{GLSL_VERSION}.fs") distortion = pyray.load_shader(pyray.ffi.NULL, f"resources/distortion{GLSL_VERSION}.fs")
# Update distortion shader with lens and distortion-scale parameters # Update distortion shader with lens and distortion-scale parameters
pyray.set_shader_value(distortion, 2, pyray.ffi.new('char []', b"leftLensCenter"), pyray.SHADER_UNIFORM_VEC2) pyray.set_shader_value(distortion, 2, pyray.ffi.new('char []', b"leftLensCenter"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2)
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightLensCenter"), pyray.SHADER_UNIFORM_VEC2) pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightLensCenter"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2)
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"leftScreenCenter"), pyray.SHADER_UNIFORM_VEC2) pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"leftScreenCenter"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2)
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightScreenCenter"), pyray.SHADER_UNIFORM_VEC2) pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightScreenCenter"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2)
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scale"), pyray.SHADER_UNIFORM_VEC2) pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scale"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2)
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scaleIn"), pyray.SHADER_UNIFORM_VEC2) pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scaleIn"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2)
pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"deviceWarpParam"), pyray.SHADER_UNIFORM_VEC4) pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"deviceWarpParam"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC4)
pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"chromaAbParam"), pyray.SHADER_UNIFORM_VEC4) pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"chromaAbParam"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC4)
# Initialize framebuffer for stereo rendering # Initialize framebuffer for stereo rendering
# NOTE: Screen size should match HMD aspect ratio # NOTE: Screen size should match HMD aspect ratio
@ -59,7 +58,7 @@ camera = pyray.Camera3D(
pyray.Vector3(0.0, 2.0, 0.0), # Camera looking at point pyray.Vector3(0.0, 2.0, 0.0), # Camera looking at point
pyray.Vector3(0.0, 1.0, 0.0), # Camera up vector pyray.Vector3(0.0, 1.0, 0.0), # Camera up vector
60.0, # Camera field-of-view Y 60.0, # Camera field-of-view Y
pyray.CAMERA_PERSPECTIVE # Camera projection type pyray.CameraProjection.CAMERA_PERSPECTIVE # Camera projection type
) )
cubePosition = pyray.Vector3(0.0, 0.0, 0.0) cubePosition = pyray.Vector3(0.0, 0.0, 0.0)
@ -71,7 +70,7 @@ pyray.set_target_fps(90) # Set our game to run at 90 frames-per-sec
# Main game loop # Main game loop
while not pyray.window_should_close(): # Detect window close button or ESC key while not pyray.window_should_close(): # Detect window close button or ESC key
# Update # Update
pyray.update_camera(camera, pyray.CAMERA_FIRST_PERSON) pyray.update_camera(camera, pyray.CameraMode.CAMERA_FIRST_PERSON)
# Draw # Draw
pyray.begin_texture_mode(target) pyray.begin_texture_mode(target)

View file

@ -6,7 +6,7 @@ import pyray
screen_width = 800 screen_width = 800
screen_height = 450 screen_height = 450
init_window(screen_width, screen_height, b"raylib [core] example - window flags") init_window(screen_width, screen_height, "raylib [core] example - window flags")
ball_position = Vector2(get_screen_width() / 2.0, get_screen_height() / 2.0) ball_position = Vector2(get_screen_width() / 2.0, get_screen_height() / 2.0)
ball_speed = Vector2(5.0, 4.0) ball_speed = Vector2(5.0, 4.0)
@ -18,71 +18,71 @@ frames_counter = 0
while not window_should_close(): # Detect window close button or ESC key while not window_should_close(): # Detect window close button or ESC key
# Update # Update
# ----------------------------------------------------- # -----------------------------------------------------
if is_key_pressed(pyray.KEY_F): if is_key_pressed(pyray.KeyboardKey.KEY_F):
toggle_fullscreen() toggle_fullscreen()
if is_key_pressed(pyray.KEY_R): if is_key_pressed(pyray.KeyboardKey.KEY_R):
if is_window_state(pyray.FLAG_WINDOW_RESIZABLE): if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_RESIZABLE):
clear_window_state(pyray.FLAG_WINDOW_RESIZABLE) clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_RESIZABLE)
else: else:
set_window_state(pyray.FLAG_WINDOW_RESIZABLE) set_window_state(pyray.ConfigFlags.FLAG_WINDOW_RESIZABLE)
if is_key_pressed(pyray.KEY_D): if is_key_pressed(pyray.KeyboardKey.KEY_D):
if is_window_state(pyray.FLAG_WINDOW_UNDECORATED): if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNDECORATED):
clear_window_state(pyray.FLAG_WINDOW_UNDECORATED) clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNDECORATED)
else: else:
set_window_state(pyray.FLAG_WINDOW_UNDECORATED) set_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNDECORATED)
if is_key_pressed(pyray.KEY_H): if is_key_pressed(pyray.KeyboardKey.KEY_H):
if not is_window_state(pyray.FLAG_WINDOW_HIDDEN): if not is_window_state(pyray.ConfigFlags.FLAG_WINDOW_HIDDEN):
set_window_state(pyray.FLAG_WINDOW_HIDDEN) set_window_state(pyray.ConfigFlags.FLAG_WINDOW_HIDDEN)
frames_counter = 0 frames_counter = 0
if is_window_state(pyray.FLAG_WINDOW_HIDDEN): if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_HIDDEN):
frames_counter += 1 frames_counter += 1
if frames_counter >= 240: if frames_counter >= 240:
clear_window_state(pyray.FLAG_WINDOW_HIDDEN) # Show window after 3 seconds clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_HIDDEN) # Show window after 3 seconds
if is_key_pressed(pyray.KEY_N): if is_key_pressed(pyray.KeyboardKey.KEY_N):
if not is_window_state(pyray.FLAG_WINDOW_MINIMIZED): if not is_window_state(pyray.ConfigFlags.FLAG_WINDOW_MINIMIZED):
minimize_window() minimize_window()
frames_counter = 0 frames_counter = 0
if is_window_state(pyray.FLAG_WINDOW_MINIMIZED): if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_MINIMIZED):
frames_counter += 1 frames_counter += 1
if frames_counter >= 240: if frames_counter >= 240:
restore_window() # Restore window after 3 seconds restore_window() # Restore window after 3 seconds
if is_key_pressed(pyray.KEY_M): if is_key_pressed(pyray.KeyboardKey.KEY_M):
if is_window_state(pyray.FLAG_WINDOW_RESIZABLE): if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_RESIZABLE):
if is_window_state(pyray.FLAG_WINDOW_MAXIMIZED): if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_MAXIMIZED):
restore_window() restore_window()
else: else:
maximize_window() maximize_window()
if is_key_pressed(pyray.KEY_U): if is_key_pressed(pyray.KeyboardKey.KEY_U):
if is_window_state(pyray.FLAG_WINDOW_UNFOCUSED): if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNFOCUSED):
clear_window_state(pyray.FLAG_WINDOW_UNFOCUSED) clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNFOCUSED)
else: else:
set_window_state(pyray.FLAG_WINDOW_UNFOCUSED) set_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNFOCUSED)
if is_key_pressed(pyray.KEY_T): if is_key_pressed(pyray.KeyboardKey.KEY_T):
if is_window_state(pyray.FLAG_WINDOW_TOPMOST): if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_TOPMOST):
clear_window_state(pyray.FLAG_WINDOW_TOPMOST) clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_TOPMOST)
else: else:
set_window_state(pyray.FLAG_WINDOW_TOPMOST) set_window_state(pyray.ConfigFlags.FLAG_WINDOW_TOPMOST)
if is_key_pressed(pyray.KEY_A): if is_key_pressed(pyray.KeyboardKey.KEY_A):
if is_window_state(pyray.FLAG_WINDOW_ALWAYS_RUN): if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_ALWAYS_RUN):
clear_window_state(pyray.FLAG_WINDOW_ALWAYS_RUN) clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_ALWAYS_RUN)
else: else:
set_window_state(pyray.FLAG_WINDOW_ALWAYS_RUN) set_window_state(pyray.ConfigFlags.FLAG_WINDOW_ALWAYS_RUN)
if is_key_pressed(pyray.KEY_V): if is_key_pressed(pyray.KeyboardKey.KEY_V):
if is_window_state(pyray.FLAG_VSYNC_HINT): if is_window_state(pyray.ConfigFlags.FLAG_VSYNC_HINT):
clear_window_state(pyray.FLAG_VSYNC_HINT) clear_window_state(pyray.ConfigFlags.FLAG_VSYNC_HINT)
else: else:
set_window_state(pyray.FLAG_VSYNC_HINT) set_window_state(pyray.ConfigFlags.FLAG_VSYNC_HINT)
# Bouncing ball logic # Bouncing ball logic
ball_position.x += ball_speed.x ball_position.x += ball_speed.x
@ -96,7 +96,7 @@ while not window_should_close(): # Detect window close button or ESC key
# ----------------------------------------------------- # -----------------------------------------------------
begin_drawing() begin_drawing()
if is_window_state(pyray.FLAG_WINDOW_TRANSPARENT): if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_TRANSPARENT):
clear_background(BLANK) clear_background(BLANK)
else: else:
clear_background(RAYWHITE) clear_background(RAYWHITE)
@ -113,16 +113,16 @@ while not window_should_close(): # Detect window close button or ESC key
# Draw window state info # Draw window state info
draw_text("Following flags can be set after window creation:", 10, 60, 10, GRAY) draw_text("Following flags can be set after window creation:", 10, 60, 10, GRAY)
flag_texts = [ flag_texts = [
("FLAG_FULLSCREEN_MODE", pyray.FLAG_FULLSCREEN_MODE), ("FLAG_FULLSCREEN_MODE", pyray.ConfigFlags.FLAG_FULLSCREEN_MODE),
("FLAG_WINDOW_RESIZABLE", pyray.FLAG_WINDOW_RESIZABLE), ("FLAG_WINDOW_RESIZABLE", pyray.ConfigFlags.FLAG_WINDOW_RESIZABLE),
("FLAG_WINDOW_UNDECORATED", pyray.FLAG_WINDOW_UNDECORATED), ("FLAG_WINDOW_UNDECORATED", pyray.ConfigFlags.FLAG_WINDOW_UNDECORATED),
("FLAG_WINDOW_HIDDEN", pyray.FLAG_WINDOW_HIDDEN), ("FLAG_WINDOW_HIDDEN", pyray.ConfigFlags.FLAG_WINDOW_HIDDEN),
("FLAG_WINDOW_MINIMIZED", pyray.FLAG_WINDOW_MINIMIZED), ("FLAG_WINDOW_MINIMIZED", pyray.ConfigFlags.FLAG_WINDOW_MINIMIZED),
("FLAG_WINDOW_MAXIMIZED", pyray.FLAG_WINDOW_MAXIMIZED), ("FLAG_WINDOW_MAXIMIZED", pyray.ConfigFlags.FLAG_WINDOW_MAXIMIZED),
("FLAG_WINDOW_UNFOCUSED", pyray.FLAG_WINDOW_UNFOCUSED), ("FLAG_WINDOW_UNFOCUSED", pyray.ConfigFlags.FLAG_WINDOW_UNFOCUSED),
("FLAG_WINDOW_TOPMOST", pyray.FLAG_WINDOW_TOPMOST), ("FLAG_WINDOW_TOPMOST", pyray.ConfigFlags.FLAG_WINDOW_TOPMOST),
("FLAG_WINDOW_ALWAYS_RUN", pyray.FLAG_WINDOW_ALWAYS_RUN), ("FLAG_WINDOW_ALWAYS_RUN", pyray.ConfigFlags.FLAG_WINDOW_ALWAYS_RUN),
("FLAG_VSYNC_HINT", pyray.FLAG_VSYNC_HINT), ("FLAG_VSYNC_HINT", pyray.ConfigFlags.FLAG_VSYNC_HINT),
] ]
y_offset = 80 y_offset = 80
for text, flag in flag_texts: for text, flag in flag_texts:
@ -133,15 +133,15 @@ while not window_should_close(): # Detect window close button or ESC key
y_offset += 20 y_offset += 20
draw_text("Following flags can only be set before window creation:", 10, 300, 10, GRAY) draw_text("Following flags can only be set before window creation:", 10, 300, 10, GRAY)
if is_window_state(pyray.FLAG_WINDOW_HIGHDPI): if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_HIGHDPI):
draw_text("FLAG_WINDOW_HIGHDPI: on", 10, 320, 10, LIME) draw_text("FLAG_WINDOW_HIGHDPI: on", 10, 320, 10, LIME)
else: else:
draw_text("FLAG_WINDOW_HIGHDPI: off", 10, 320, 10, MAROON) draw_text("FLAG_WINDOW_HIGHDPI: off", 10, 320, 10, MAROON)
if is_window_state(pyray.FLAG_WINDOW_TRANSPARENT): if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_TRANSPARENT):
draw_text("FLAG_WINDOW_TRANSPARENT: on", 10, 340, 10, LIME) draw_text("FLAG_WINDOW_TRANSPARENT: on", 10, 340, 10, LIME)
else: else:
draw_text("FLAG_WINDOW_TRANSPARENT: off", 10, 340, 10, MAROON) draw_text("FLAG_WINDOW_TRANSPARENT: off", 10, 340, 10, MAROON)
if is_window_state(pyray.FLAG_MSAA_4X_HINT): if is_window_state(pyray.ConfigFlags.FLAG_MSAA_4X_HINT):
draw_text("FLAG_MSAA_4X_HINT: on", 10, 360, 10, LIME) draw_text("FLAG_MSAA_4X_HINT: on", 10, 360, 10, LIME)
else: else:
draw_text("FLAG_MSAA_4X_HINT: off", 10, 360, 10, MAROON) draw_text("FLAG_MSAA_4X_HINT: off", 10, 360, 10, MAROON)

View file

@ -12,7 +12,7 @@ SCREEN_HEIGHT = 450
init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [core] example - window should close") init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [core] example - window should close")
set_exit_key(KEY_NULL) # Disable KEY_ESCAPE to close window, X-button still works set_exit_key(KeyboardKey.KEY_NULL) # Disable KEY_ESCAPE to close window, X-button still works
exitWindowRequested = False # Flag to request window to exit exitWindowRequested = False # Flag to request window to exit
exitWindow = False # Flag to set window to exit exitWindow = False # Flag to set window to exit
@ -26,7 +26,7 @@ while not exitWindow:
# Update # Update
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
# Detect if X-button or KEY_ESCAPE have been pressed to close window # Detect if X-button or KEY_ESCAPE have been pressed to close window
if window_should_close() or is_key_pressed(KEY_ESCAPE): if window_should_close() or is_key_pressed(KeyboardKey.KEY_ESCAPE):
exitWindowRequested = True exitWindowRequested = True
if exitWindowRequested: if exitWindowRequested:
@ -34,9 +34,9 @@ while not exitWindow:
# A request for close window has been issued, we can save data before closing # A request for close window has been issued, we can save data before closing
# or just show a message asking for confirmation # or just show a message asking for confirmation
if is_key_pressed(KEY_Y): if is_key_pressed(KeyboardKey.KEY_Y):
exitWindow = True exitWindow = True
elif is_key_pressed(KEY_N): elif is_key_pressed(KeyboardKey.KEY_N):
exitWindowRequested = False exitWindowRequested = False
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------

View file

@ -1,7 +1,7 @@
# python3 -m pip install pyglm # python3 -m pip install pyglm
from math import sin, cos from math import sin, cos
import glm import glm # type: ignore
from raylib import rl, ffi from raylib import rl, ffi

View file

@ -8,7 +8,8 @@ python3 flow-field
""" """
import sys, math, time, random import sys, math, time, random
import glm # Note package is PyGLM, not glm. import glm # type: ignore
# Note package is PyGLM, not glm.
from raylib import rl, ffi from raylib import rl, ffi
from raylib.colors import * from raylib.colors import *

View file

@ -18,9 +18,9 @@ Mac:
""" """
import sys, time import sys, time
import glm import glm # type: ignore
import pytweening as tween import pytweening as tween # type: ignore
import screeninfo import screeninfo # type: ignore
from raylib import rl, ffi from raylib import rl, ffi
from raylib.colors import * from raylib.colors import *

View file

@ -1,4 +1,4 @@
import cv2 as cv import cv2 as cv # type:ignore
from pyray import * from pyray import *
opencv_image = cv.imread("resources/raylib_logo.jpg") opencv_image = cv.imread("resources/raylib_logo.jpg")
@ -10,7 +10,7 @@ screenHeight = 450
init_window(screenWidth, screenHeight, "example - image loading") init_window(screenWidth, screenHeight, "example - image loading")
pointer_to_image_data = ffi.from_buffer(opencv_image.data) pointer_to_image_data = ffi.from_buffer(opencv_image.data)
raylib_image = Image(pointer_to_image_data, 256, 256, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8) raylib_image = Image(pointer_to_image_data, 256, 256, 1, PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8)
texture = load_texture_from_image(raylib_image) texture = load_texture_from_image(raylib_image)
unload_image(raylib_image) unload_image(raylib_image)

View file

@ -1,4 +1,3 @@
import pyray as ray import pyray as ray
@ -13,11 +12,11 @@ camera.position = ray.Vector3( 10.0, 10.0, 10.0 ) # Camera position
camera.target = ray.Vector3( 0.0, 0.0, 0.0 ) # Camera looking at point camera.target = ray.Vector3( 0.0, 0.0, 0.0 ) # Camera looking at point
camera.up = ray.Vector3( 0.0, 1.0, 0.0 ) # Camera up vector (rotation towards target) camera.up = ray.Vector3( 0.0, 1.0, 0.0 ) # Camera up vector (rotation towards target)
camera.fovy = 45.0 # Camera field-of-view Y camera.fovy = 45.0 # Camera field-of-view Y
camera.projection = ray.CAMERA_PERSPECTIVE # Camera mode type camera.projection = ray.CameraProjection.CAMERA_PERSPECTIVE # Camera mode type
model = ray.load_model("resources/models/iqm/guy.iqm") # Load the animated model mesh and basic data model = ray.load_model("resources/models/iqm/guy.iqm") # Load the animated model mesh and basic data
texture = ray.load_texture("resources/models/iqm/guytex.png") # Load model texture and set material texture = ray.load_texture("resources/models/iqm/guytex.png") # Load model texture and set material
ray.set_material_texture(model.materials, ray.MATERIAL_MAP_ALBEDO, texture) # Set model material map texture ray.set_material_texture(model.materials, ray.MaterialMapIndex.MATERIAL_MAP_ALBEDO, texture) # Set model material map texture
position = ( 0., 0., 0. ) # Set model position position = ( 0., 0., 0. ) # Set model position
@ -33,10 +32,10 @@ ray.set_target_fps(60) # Set our game to run at 60 frames-per-
while not ray.window_should_close(): # Detect window close button or ESC key while not ray.window_should_close(): # Detect window close button or ESC key
# Update # Update
#---------------------------------------------------------------------------------- #----------------------------------------------------------------------------------
ray.update_camera(camera, ray.CAMERA_FREE) ray.update_camera(camera, ray.CameraMode.CAMERA_FREE)
# Play animation when spacebar is held down # Play animation when spacebar is held down
if ray.is_key_down(ray.KEY_SPACE): if ray.is_key_down(ray.KeyboardKey.KEY_SPACE):
anim_frame_counter+=1 anim_frame_counter+=1
ray.update_model_animation(model, anims[0], anim_frame_counter) ray.update_model_animation(model, anims[0], anim_frame_counter)
if anim_frame_counter >= anims[0].frameCount: if anim_frame_counter >= anims[0].frameCount:

View file

@ -1,3 +1,4 @@
#type: ignore
import raylib as rl import raylib as rl
from raylib.colors import * from raylib.colors import *

View file

@ -15,7 +15,7 @@ camera.position = Vector3(30.0, 20.0, 30.0) # Camera position
camera.target = Vector3(0.0, 0.0, 0.0) # Camera looking at point camera.target = Vector3(0.0, 0.0, 0.0) # Camera looking at point
camera.up = Vector3(0.0, 1.0, 0.0) # Camera up vector (rotation towards target) camera.up = Vector3(0.0, 1.0, 0.0) # Camera up vector (rotation towards target)
camera.fovy = 70.0 # Camera field-of-view Y camera.fovy = 70.0 # Camera field-of-view Y
camera.projection = pyray.CAMERA_PERSPECTIVE # Camera projection type camera.projection = pyray.CameraProjection.CAMERA_PERSPECTIVE # Camera projection type
# Specify the amount of blocks in each direction # Specify the amount of blocks in each direction
numBlocks = 15 numBlocks = 15

View file

@ -118,18 +118,18 @@ class Camera:
# GLFW3: Error callback # GLFW3: Error callback
@ffi.callback("void(int, const char *)") @ffi.callback("void(int, const char *)")
def ErrorCallback(error: int, description: bytes): def ErrorCallback(error: int, description: bytes):
print("%s" % description, file=sys.stderr) print("%r" % description, file=sys.stderr)
# GLFW3: Keyboard callback # GLFW3: Keyboard callback
@ffi.callback("void(GLFWwindow *, int, int, int, int)") @ffi.callback("void(GLFWwindow *, int, int, int, int)")
def KeyCallback(window: 'GLFWwindow', key: int, scancode: int, action: int, mods: int): def KeyCallback(window, key: int, scancode: int, action: int, mods: int):
if key == GLFW_KEY_ESCAPE and action == GLFW_PRESS: if key == GLFW_KEY_ESCAPE and action == GLFW_PRESS:
rl.glfwSetWindowShouldClose(window, GLFW_TRUE) rl.glfwSetWindowShouldClose(window, GLFW_TRUE)
# Draw rectangle using rlgl OpenGL 1.1 style coding (translated to OpenGL 3.3 internally) # Draw rectangle using rlgl OpenGL 1.1 style coding (translated to OpenGL 3.3 internally)
def DrawRectangleV(position: 'raylib.Vector2', size: 'raylib.Vector2', color: Color): def DrawRectangleV(position, size, color: Color):
rl.rlBegin(RL_TRIANGLES) rl.rlBegin(RL_TRIANGLES)
rl.rlColor4ub(color.r, color.g, color.b, color.a) rl.rlColor4ub(color.r, color.g, color.b, color.a)
rl.rlVertex2f(position.x, position.y) rl.rlVertex2f(position.x, position.y)
@ -168,7 +168,7 @@ def DrawGrid(slices: int, spacing: float):
# Draw cube # Draw cube
# NOTE: Cube position is the center position # NOTE: Cube position is the center position
def DrawCube(position: 'raylib.Vector3', width: float, height: float, length: float, color: Color): def DrawCube(position, width: float, height: float, length: float, color: Color):
x: float = 0.0 x: float = 0.0
y: float = 0.0 y: float = 0.0
z: float = 0.0 z: float = 0.0
@ -242,7 +242,7 @@ def DrawCube(position: 'raylib.Vector3', width: float, height: float, length: fl
#Draw cube wires #Draw cube wires
def DrawCubeWires(position: 'raylib.Vector3', width: float, height: float, length: float, color: Color): def DrawCubeWires(position, width: float, height: float, length: float, color: Color):
x: float = 0.0 x: float = 0.0
y: float = 0.0 y: float = 0.0
z: float = 0.0 z: float = 0.0

View file

@ -2,13 +2,9 @@
raylib [physac] example - physics demo raylib [physac] example - physics demo
""" """
from pyray import Vector2
from raylib import * from raylib import *
from raylib.colors import (
BLACK,
GREEN,
WHITE
)
SCREEN_WIDTH = 800 SCREEN_WIDTH = 800
SCREEN_HEIGHT = 450 SCREEN_HEIGHT = 450
@ -18,10 +14,10 @@ InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, b'[physac] Basic demo')
InitPhysics() InitPhysics()
floor = CreatePhysicsBodyRectangle(Vector2(SCREEN_WIDTH/2, SCREEN_HEIGHT), 500, 100, 10) floor = CreatePhysicsBodyRectangle((SCREEN_WIDTH/2, SCREEN_HEIGHT), 500, 100, 10)
floor.enabled = False floor.enabled = False
circle = CreatePhysicsBodyCircle(Vector2(SCREEN_WIDTH/2, SCREEN_HEIGHT/2), 45, 10) circle = CreatePhysicsBodyCircle((SCREEN_WIDTH/2, SCREEN_HEIGHT/2), 45, 10)
circle.enabled = False circle.enabled = False
SetTargetFPS(60) SetTargetFPS(60)
@ -34,10 +30,10 @@ while not WindowShouldClose():
if IsKeyPressed(KEY_R): # Reset physics system if IsKeyPressed(KEY_R): # Reset physics system
ResetPhysics() ResetPhysics()
floor = CreatePhysicsBodyRectangle(Vector2(SCREEN_WIDTH/2, SCREEN_HEIGHT), 500, 100, 10) floor = CreatePhysicsBodyRectangle((SCREEN_WIDTH/2, SCREEN_HEIGHT), 500, 100, 10)
floor.enabled = False floor.enabled = False
circle = CreatePhysicsBodyCircle(Vector2(SCREEN_WIDTH/2, SCREEN_HEIGHT/2), 45, 10) circle = CreatePhysicsBodyCircle((SCREEN_WIDTH/2, SCREEN_HEIGHT/2), 45, 10)
circle.enabled = False circle.enabled = False
# Physics body creation inputs # Physics body creation inputs

View file

@ -4,20 +4,20 @@ import raylib as rl
class LightSystem: class LightSystem:
MAX_LIGHTS = 4 #// Max dynamic lights supported by shader MAX_LIGHTS = 4 #// Max dynamic lights supported by shader
lightsCount = 0 lightsCount = 0
lights = [] lights: list['Light'] = []
def __init__(self, ambient = [ 0.2, 0.2, 0.2, 1.0 ], *ls): def __init__(self, ambient = [ 0.2, 0.2, 0.2, 1.0 ], *ls):
self.shader = rl.LoadShader(b"resources/shaders/fogLight.vs", self.shader = rl.LoadShader(b"resources/shaders/fogLight.vs",
b"resources/shaders/fogLight.fs"); b"resources/shaders/fogLight.fs");
#// Get some shader loactions #// Get some shader loactions
self.shader.locs[rl.SHADER_LOC_MATRIX_MODEL] = rl.GetShaderLocation(self.shader, b"matModel"); self.shader.locs[rl.SHADER_LOC_MATRIX_MODEL] = rl.GetShaderLocation(self.shader, b"matModel")
self.shader.locs[rl.SHADER_LOC_VECTOR_VIEW] = rl.GetShaderLocation(self.shader, b"viewPos"); self.shader.locs[rl.SHADER_LOC_VECTOR_VIEW] = rl.GetShaderLocation(self.shader, b"viewPos")
#// ambient light level #// ambient light level
self.ambientLoc = rl.GetShaderLocation(self.shader, b"ambient"); self.ambientLoc = rl.GetShaderLocation(self.shader, b"ambient")
v = rl.ffi.new("struct Vector4 *", ambient) v = rl.ffi.new("struct Vector4 *", ambient)
rl.SetShaderValue(self.shader, self.ambientLoc, v, rl.SHADER_UNIFORM_VEC4); rl.SetShaderValue(self.shader, self.ambientLoc, v, rl.SHADER_UNIFORM_VEC4)
for light in ls: for light in ls:
self.add(light) self.add(light)

View file

@ -48,7 +48,7 @@ screenWidth = 1200
screenHeight = 720 screenHeight = 720
rl.SetConfigFlags( rl.SetConfigFlags(
rl.FLAG_MSAA_4X_HINT | rl.FLAG_WINDOW_RESIZABLE); # Enable Multi Sampling Anti Aliasing 4x (if available) rl.FLAG_MSAA_4X_HINT | rl.FLAG_WINDOW_RESIZABLE) # Enable Multi Sampling Anti Aliasing 4x (if available)
rl.InitWindow(screenWidth, screenHeight, b"raylib [shaders] example - basic lighting") rl.InitWindow(screenWidth, screenHeight, b"raylib [shaders] example - basic lighting")
camera = rl.ffi.new('struct Camera3D *', [ camera = rl.ffi.new('struct Camera3D *', [

View file

@ -9,7 +9,7 @@ def LoadRenderTextureDepthTex(width, height):
target = RenderTexture() target = RenderTexture()
target.id = rl_load_framebuffer(width, height) # Load an empty framebuffer target.id = rl_load_framebuffer() # Load an empty framebuffer
if target.id > 0: if target.id > 0:
@ -72,12 +72,7 @@ shader = load_shader("","resources/shaders/glsl330/write_depth.fs")
target = LoadRenderTextureDepthTex(screenWidth, screenHeight) target = LoadRenderTextureDepthTex(screenWidth, screenHeight)
# Define the camera to look into our 3d world # Define the camera to look into our 3d world
camera = Camera3D() camera = Camera3D((2.0, 2.0, 3.0),(0.0, 0.5, 0.0),(0.0, 1.0, 0.0),45.0, CameraProjection.CAMERA_PERSPECTIVE)
camera.position = (2.0, 2.0, 3.0) # Camera position
camera.target = (0.0, 0.5, 0.0) # Camera looking at point
camera.up = (0.0, 1.0, 0.0) # Camera up vector (rotation towards target)
camera.fovy = 45.0 # Camera field-of-view Y
camera.projection = CameraProjection.CAMERA_PERSPECTIVE # Camera projection type
set_target_fps(60) # Set our game to run at 60 frames-per-second set_target_fps(60) # Set our game to run at 60 frames-per-second

View file

@ -1,19 +1,4 @@
import pyray import pyray
from raylib.colors import (
RAYWHITE,
DARKGRAY,
DARKBLUE,
SKYBLUE,
MAROON,
ORANGE,
RED,
VIOLET,
BEIGE,
BROWN,
BLACK,
GREEN,
GOLD
)
# Initialization # Initialization
@ -33,37 +18,37 @@ while not pyray.window_should_close():
# Draw # Draw
pyray.begin_drawing() pyray.begin_drawing()
pyray.clear_background(RAYWHITE) pyray.clear_background(pyray.RAYWHITE)
pyray.draw_text("some basic shapes available on raylib", 20, 20, 20, DARKGRAY) pyray.draw_text("some basic shapes available on raylib", 20, 20, 20, pyray.DARKGRAY)
# Circle shapes and lines # Circle shapes and lines
pyray.draw_circle(screenWidth // 5, 120, 35, DARKBLUE) pyray.draw_circle(screenWidth // 5, 120, 35, pyray.DARKBLUE)
pyray.draw_circle_gradient(screenWidth // 5, 220, 60, GREEN, SKYBLUE) pyray.draw_circle_gradient(screenWidth // 5, 220, 60, pyray.GREEN, pyray.SKYBLUE)
pyray.draw_circle_lines(screenWidth // 5, 340, 80, DARKBLUE) pyray.draw_circle_lines(screenWidth // 5, 340, 80, pyray.DARKBLUE)
# Rectangle shapes and lines # Rectangle shapes and lines
pyray.draw_rectangle(screenWidth // 4 * 2 - 60, 100, 120, 60, RED) pyray.draw_rectangle(screenWidth // 4 * 2 - 60, 100, 120, 60, pyray.RED)
pyray.draw_rectangle_gradient_h(screenWidth // 4 * 2 - 90, 170, 180, 130, MAROON, GOLD) pyray.draw_rectangle_gradient_h(screenWidth // 4 * 2 - 90, 170, 180, 130, pyray.MAROON, pyray.GOLD)
pyray.draw_rectangle_lines(screenWidth // 4 * 2 - 40, 320, 80, 60, ORANGE) pyray.draw_rectangle_lines(screenWidth // 4 * 2 - 40, 320, 80, 60, pyray.ORANGE)
# Triangle shapes and lines # Triangle shapes and lines
pyray.draw_triangle(pyray.Vector2(screenWidth / 4.0 * 3.0, 80.0), pyray.draw_triangle(pyray.Vector2(screenWidth / 4.0 * 3.0, 80.0),
pyray.Vector2(screenWidth / 4.0 * 3.0 - 60.0, 150.0), pyray.Vector2(screenWidth / 4.0 * 3.0 - 60.0, 150.0),
pyray.Vector2(screenWidth / 4.0 * 3.0 + 60.0, 150.0), VIOLET) pyray.Vector2(screenWidth / 4.0 * 3.0 + 60.0, 150.0), pyray.VIOLET)
pyray.draw_triangle_lines(pyray.Vector2(screenWidth / 4.0 * 3.0, 160.0), pyray.draw_triangle_lines(pyray.Vector2(screenWidth / 4.0 * 3.0, 160.0),
pyray.Vector2(screenWidth / 4.0 * 3.0 - 20.0, 230.0), pyray.Vector2(screenWidth / 4.0 * 3.0 - 20.0, 230.0),
pyray.Vector2(screenWidth / 4.0 * 3.0 + 20.0, 230.0), DARKBLUE) pyray.Vector2(screenWidth / 4.0 * 3.0 + 20.0, 230.0), pyray.DARKBLUE)
# Polygon shapes and lines # Polygon shapes and lines
pyray.draw_poly(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 80, rotation, BROWN) pyray.draw_poly(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 80, rotation, pyray.BROWN)
pyray.draw_poly_lines(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 90, rotation, BROWN) pyray.draw_poly_lines(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 90, rotation, pyray.BROWN)
pyray.draw_poly_lines_ex(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 85, rotation, 6, BEIGE) pyray.draw_poly_lines_ex(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 85, rotation, 6, pyray.BEIGE)
# NOTE: We draw all LINES based shapes together to optimize internal drawing, # NOTE: We draw all LINES based shapes together to optimize internal drawing,
# this way, all LINES are rendered in a single draw pass # this way, all LINES are rendered in a single draw pass
pyray.draw_line(18, 42, screenWidth - 18, 42, BLACK) pyray.draw_line(18, 42, screenWidth - 18, 42, pyray.BLACK)
pyray.end_drawing() pyray.end_drawing()

View file

@ -17,7 +17,7 @@ pyray.set_target_fps(60)
# Main game loop # Main game loop
while not pyray.window_should_close(): while not pyray.window_should_close():
# Update # Update
if pyray.is_key_pressed(pyray.KEY_SPACE): if pyray.is_key_pressed(pyray.KeyboardKey.KEY_SPACE):
pause = not pause pause = not pause
if not pause: if not pause:

View file

@ -12,13 +12,6 @@
#********************************************************************************************/ #********************************************************************************************/
import pyray import pyray
from raylib.colors import (
RAYWHITE,
LIGHTGRAY,
DARKGRAY,
GOLD,
MAROON,
)
SCREEN_WIDTH = 800 SCREEN_WIDTH = 800
@ -50,17 +43,17 @@ while not pyray.window_should_close(): #// Detect window close button or ESC ke
#// Draw #// Draw
#//---------------------------------------------------------------------------------- #//----------------------------------------------------------------------------------
pyray.begin_drawing() pyray.begin_drawing()
pyray.clear_background(RAYWHITE) pyray.clear_background(pyray.RAYWHITE)
pyray.draw_line(560,0,560,pyray.get_screen_height(),pyray.fade(LIGHTGRAY,0.6)) pyray.draw_line(560,0,560,pyray.get_screen_height(),pyray.fade(pyray.LIGHTGRAY,0.6))
pyray.draw_rectangle(560,0,pyray.get_screen_width()-500,pyray.get_screen_height(),pyray.fade(LIGHTGRAY,0.3)) pyray.draw_rectangle(560,0,pyray.get_screen_width()-500,pyray.get_screen_height(),pyray.fade(pyray.LIGHTGRAY,0.3))
if drawRect: if drawRect:
pyray.draw_rectangle_rec(rec,pyray.fade(GOLD,0.6)) pyray.draw_rectangle_rec(rec,pyray.fade(pyray.GOLD,0.6))
if drawRoundedRect: if drawRoundedRect:
pyray.draw_rectangle_rounded(rec,roundness,segments,pyray.fade(MAROON,0.2)) pyray.draw_rectangle_rounded(rec,roundness,segments,pyray.fade(pyray.MAROON,0.2))
if drawRoundedLines: if drawRoundedLines:
pyray.draw_rectangle_rounded_lines(rec,roundness,segments,lineThick,pyray.fade(MAROON,0.4)) pyray.draw_rectangle_rounded_lines(rec,roundness,segments,pyray.fade(pyray.MAROON,0.4))
#// Draw GUI controls #// Draw GUI controls
#//------------------------------------------------------------------------------ #//------------------------------------------------------------------------------
@ -79,7 +72,7 @@ while not pyray.window_should_close(): #// Detect window close button or ESC ke
# drawRect = pyray.gui_check_box(pyray.Rectangle(640,380,20,20),"DrawRect",drawRect) # drawRect = pyray.gui_check_box(pyray.Rectangle(640,380,20,20),"DrawRect",drawRect)
#//------------------------------------------------------------------------------ #//------------------------------------------------------------------------------
pyray.draw_text( "MANUAL" if segments >= 4 else "AUTO" , 640, 280, 10, MAROON if segments >= 4 else DARKGRAY) pyray.draw_text( "MANUAL" if segments >= 4 else "AUTO" , 640, 280, 10, pyray.MAROON if segments >= 4 else pyray.DARKGRAY)
pyray.draw_fps(10,10) pyray.draw_fps(10,10)
pyray.end_drawing() pyray.end_drawing()
#//------------------------------------------------------------------------------ #//------------------------------------------------------------------------------

View file

@ -5,13 +5,7 @@ raylib [shapes] example - Following Eyes
""" """
from pyray import * from pyray import *
from raylib.colors import (
RAYWHITE,
BROWN,
BLACK,
LIGHTGRAY,
DARKGREEN,
)
from math import ( from math import (
atan2, atan2,
cos, cos,

View file

@ -5,11 +5,6 @@ raylib [shapes] example - Lines Bezier
""" """
from pyray import * from pyray import *
from raylib.colors import (
RAYWHITE,
GRAY,
RED
)
# ------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------

View file

@ -4,11 +4,7 @@ raylib [shapes] example - Logo Raylib
""" """
from pyray import * from pyray import *
from raylib.colors import (
RAYWHITE,
BLACK,
GRAY
)
# Initialization # Initialization
screenWidth = 800 screenWidth = 800

View file

@ -38,9 +38,9 @@ bunnies = []
for i in range(0, MAX_BUNNIES): for i in range(0, MAX_BUNNIES):
bunnies.append(Bunny()) bunnies.append(Bunny())
bunniesCount = 0; # Bunnies counter bunniesCount = 0 # Bunnies counter
SetTargetFPS(60); # Set our game to run at 60 frames-per-second SetTargetFPS(60) # Set our game to run at 60 frames-per-second
#//-------------------------------------------------------------------------------------- #//--------------------------------------------------------------------------------------
#// Main game loop #// Main game loop
@ -63,8 +63,8 @@ while not WindowShouldClose(): #// Detect window close button or ESC key
# // Update bunnies # // Update bunnies
for i in range(0, bunniesCount): for i in range(0, bunniesCount):
bunnies[i].position.x += bunnies[i].speed.x; bunnies[i].position.x += bunnies[i].speed.x
bunnies[i].position.y += bunnies[i].speed.y; bunnies[i].position.y += bunnies[i].speed.y
if ((bunnies[i].position.x + texBunny.width/2) > GetScreenWidth()) or ((bunnies[i].position.x + texBunny.width/2) < 0): if ((bunnies[i].position.x + texBunny.width/2) > GetScreenWidth()) or ((bunnies[i].position.x + texBunny.width/2) < 0):
bunnies[i].speed.x *= -1 bunnies[i].speed.x *= -1
@ -104,7 +104,7 @@ while not WindowShouldClose(): #// Detect window close button or ESC key
#//-------------------------------------------------------------------------------------- #//--------------------------------------------------------------------------------------
UnloadTexture(texBunny); #Unload bunny texture UnloadTexture(texBunny) #Unload bunny texture
CloseWindow() # Close window and OpenGL context CloseWindow() # Close window and OpenGL context
#//-------------------------------------------------------------------------------------- #//--------------------------------------------------------------------------------------

View file

@ -36,9 +36,9 @@ bunnies = []
for i in range(0, MAX_BUNNIES): for i in range(0, MAX_BUNNIES):
bunnies.append(Bunny()) bunnies.append(Bunny())
bunniesCount = 0; # Bunnies counter bunniesCount = 0 # Bunnies counter
SetTargetFPS(60); # Set our game to run at 60 frames-per-second SetTargetFPS(60) # Set our game to run at 60 frames-per-second
#//-------------------------------------------------------------------------------------- #//--------------------------------------------------------------------------------------
#// Main game loop #// Main game loop

View file

@ -4,16 +4,6 @@ raylib [texture] example - Mouse Painting
""" """
from pyray import * from pyray import *
from raylib.colors import *
from raylib import (
KEY_RIGHT,
KEY_LEFT,
MOUSE_BUTTON_LEFT,
KEY_C,
GESTURE_DRAG,
MOUSE_BUTTON_RIGHT,
KEY_S
)
MAX_COLORS_COUNT = 23 # Number of colors available MAX_COLORS_COUNT = 23 # Number of colors available
@ -62,9 +52,9 @@ while not window_should_close(): # Detect window close button or ESC key
mousePos = get_mouse_position() mousePos = get_mouse_position()
# Move between colors with keys # Move between colors with keys
if is_key_pressed(KEY_RIGHT): if is_key_pressed(KeyboardKey.KEY_RIGHT):
colorSelected += 1 colorSelected += 1
elif is_key_pressed(KEY_LEFT): elif is_key_pressed(KeyboardKey.KEY_LEFT):
colorSelected -= 1 colorSelected -= 1
if colorSelected >= MAX_COLORS_COUNT: if colorSelected >= MAX_COLORS_COUNT:
@ -80,7 +70,7 @@ while not window_should_close(): # Detect window close button or ESC key
else: else:
colorMouseHover = -1 colorMouseHover = -1
if colorMouseHover >= 0 and is_mouse_button_pressed(MOUSE_BUTTON_LEFT): if colorMouseHover >= 0 and is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_LEFT):
colorSelected = colorMouseHover colorSelected = colorMouseHover
colorSelectedPrev = colorSelected colorSelectedPrev = colorSelected
@ -89,13 +79,13 @@ while not window_should_close(): # Detect window close button or ESC key
if brushSize < 2: brushSize = 2 if brushSize < 2: brushSize = 2
if brushSize > 50: brushSize = 50 if brushSize > 50: brushSize = 50
if is_key_pressed(KEY_C): if is_key_pressed(KeyboardKey.KEY_C):
# Clear render texture to clear color # Clear render texture to clear color
begin_texture_mode(target) begin_texture_mode(target)
clear_background(colors[0]) clear_background(colors[0])
end_texture_mode() end_texture_mode()
if is_mouse_button_pressed(MOUSE_BUTTON_LEFT) or get_gesture_detected() == GESTURE_DRAG: if is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_LEFT) or get_gesture_detected() == Gesture.GESTURE_DRAG:
# Paint circle into render texture # Paint circle into render texture
# NOTE: To avoid discontinuous circles, we could store # NOTE: To avoid discontinuous circles, we could store
@ -104,7 +94,7 @@ while not window_should_close(): # Detect window close button or ESC key
if mousePos.y > 50: if mousePos.y > 50:
draw_circle(int(mousePos.x), int(mousePos.y), brushSize, colors[colorSelected]) draw_circle(int(mousePos.x), int(mousePos.y), brushSize, colors[colorSelected])
end_texture_mode() end_texture_mode()
if is_mouse_button_down(MOUSE_BUTTON_RIGHT): if is_mouse_button_down(MouseButton.MOUSE_BUTTON_RIGHT):
if not mouseWasPressed: if not mouseWasPressed:
colorSelectedPrev = colorSelected colorSelectedPrev = colorSelected
@ -117,7 +107,7 @@ while not window_should_close(): # Detect window close button or ESC key
if mousePos.y > 50: draw_circle(int(mousePos.x), int(mousePos.y), brushSize, colors[0]) if mousePos.y > 50: draw_circle(int(mousePos.x), int(mousePos.y), brushSize, colors[0])
end_texture_mode() end_texture_mode()
elif is_mouse_button_released(MOUSE_BUTTON_RIGHT) and mouseWasPressed: elif is_mouse_button_released(MouseButton.MOUSE_BUTTON_RIGHT) and mouseWasPressed:
colorSelected = colorSelectedPrev colorSelected = colorSelectedPrev
mouseWasPressed = False mouseWasPressed = False
@ -130,7 +120,7 @@ while not window_should_close(): # Detect window close button or ESC key
# Image saving logic # Image saving logic
# NOTE: Saving painted texture to a default named image # NOTE: Saving painted texture to a default named image
if (btnSaveMouseHover and is_mouse_button_released(MOUSE_BUTTON_LEFT)) or is_key_pressed(KEY_S): if (btnSaveMouseHover and is_mouse_button_released(MouseButton.MOUSE_BUTTON_LEFT)) or is_key_pressed(KeyboardKey.KEY_S):
image = load_image_from_texture(target.texture) image = load_image_from_texture(target.texture)
image_flip_vertical(image) image_flip_vertical(image)
export_image(image, "my_amazing_texture_painting.png") export_image(image, "my_amazing_texture_painting.png")
@ -157,7 +147,7 @@ while not window_should_close(): # Detect window close button or ESC key
# Draw drawing circle for reference # Draw drawing circle for reference
if mousePos.y > 50: if mousePos.y > 50:
if is_mouse_button_down(MOUSE_BUTTON_RIGHT): if is_mouse_button_down(MouseButton.MOUSE_BUTTON_RIGHT):
draw_circle_lines(int(mousePos.x), int(mousePos.y), brushSize, GRAY) draw_circle_lines(int(mousePos.x), int(mousePos.y), brushSize, GRAY)
else: else:
draw_circle(get_mouse_x(), get_mouse_y(), brushSize, colors[colorSelected]) draw_circle(get_mouse_x(), get_mouse_y(), brushSize, colors[colorSelected])

View file

@ -39,6 +39,8 @@ while not window_should_close(): # Detect window close button or ESC key
clear_background(RAYWHITE) clear_background(RAYWHITE)
texture.width
draw_texture(texture, int(screenWidth/2 - texture.width/2), int(screenHeight/2 - texture.height/2), WHITE) draw_texture(texture, int(screenWidth/2 - texture.width/2), int(screenHeight/2 - texture.height/2), WHITE)
draw_text("this IS a texture loaded from an image!", 300, 370, 10, GRAY) draw_text("this IS a texture loaded from an image!", 300, 370, 10, GRAY)

View file

@ -11,11 +11,12 @@ cd ../..
echo "installing raylib headers to /usr/local/include" echo "installing raylib headers to /usr/local/include"
sudo cp ./raylib-c/src/raylib.h /usr/local/include/ sudo cp -v ./raylib-c/src/raylib.h /usr/local/include/
sudo cp ./raylib-c/src/rlgl.h /usr/local/include/ sudo cp -v ./raylib-c/src/rlgl.h /usr/local/include/
sudo cp ./raylib-c/src/raymath.h /usr/local/include/ sudo cp -v ./raylib-c/src/raymath.h /usr/local/include/
sudo cp ./raygui/src/raygui.h /usr/local/include/ sudo cp -v ./raygui/src/raygui.h /usr/local/include/
sudo cp ./physac/src/physac.h /usr/local/include/ sudo cp -v ./physac/src/physac.h /usr/local/include/
sudo cp -rv raylib-c/src/external/glfw/include/GLFW /usr/local/include
echo "building raylib_parser" echo "building raylib_parser"
@ -42,21 +43,19 @@ python3 create_enums.py > dynamic/raylib/enums.py
echo "creating defines.py" echo "creating defines.py"
python3 create_define_consts.py > raylib/defines.py python3 create_define_consts.py | awk '!seen[$0]++' > raylib/defines.py
python3 create_define_consts.py > dynamic/raylib/defines.py python3 create_define_consts.py | awk '!seen[$0]++' > dynamic/raylib/defines.py
echo "creating pyi files" echo "creating pyi files"
python3 create_stub_pyray.py > pyray/__init__.pyi python3 create_stub_pyray.py > pyray/__init__.pyi
python3 create_enums.py >> pyray/__init__.pyi
python3 create_stub_static.py >raylib/__init__.pyi python3 create_stub_static.py >raylib/__init__.pyi
python3 create_stub_static.py >dynamic/raylib/__init__.pyi
echo "installing sphinx modules" echo "installing sphinx modules"
python -m venv venv python3 -m venv venv
source venv/bin/activate source venv/bin/activate
pip3 install sphinx-autoapi myst_parser sphinx_rtd_theme pip3 install sphinx-autoapi myst_parser sphinx_rtd_theme

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -7,17 +7,7 @@ RAYLIB_VERSION: str = "5.0"
PI: float = 3.141592653589793 PI: float = 3.141592653589793
DEG2RAD = PI / 180.0 DEG2RAD = PI / 180.0
RAD2DEG = 180.0 / PI RAD2DEG = 180.0 / PI
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
PI: float = 3.141592653589793
EPSILON: float = 1e-06 EPSILON: float = 1e-06
DEG2RAD = PI / 180.0
RAD2DEG = 180.0 / PI
RLGL_VERSION: str = "4.5" RLGL_VERSION: str = "4.5"
RL_DEFAULT_BATCH_BUFFER_ELEMENTS: int = 8192 RL_DEFAULT_BATCH_BUFFER_ELEMENTS: int = 8192
RL_DEFAULT_BATCH_BUFFERS: int = 1 RL_DEFAULT_BATCH_BUFFERS: int = 1
@ -89,11 +79,6 @@ RL_BLEND_SRC_RGB: int = 32969
RL_BLEND_DST_ALPHA: int = 32970 RL_BLEND_DST_ALPHA: int = 32970
RL_BLEND_SRC_ALPHA: int = 32971 RL_BLEND_SRC_ALPHA: int = 32971
RL_BLEND_COLOR: int = 32773 RL_BLEND_COLOR: int = 32773
RL_SHADER_LOC_MAP_DIFFUSE = raylib.RL_SHADER_LOC_MAP_ALBEDO
RL_SHADER_LOC_MAP_SPECULAR = raylib.RL_SHADER_LOC_MAP_METALNESS
PI: float = 3.141592653589793
DEG2RAD = PI / 180.0
RAD2DEG = 180.0 / PI
GL_SHADING_LANGUAGE_VERSION: int = 35724 GL_SHADING_LANGUAGE_VERSION: int = 35724
GL_COMPRESSED_RGB_S3TC_DXT1_EXT: int = 33776 GL_COMPRESSED_RGB_S3TC_DXT1_EXT: int = 33776
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: int = 33777 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: int = 33777

View file

@ -1 +1 @@
__version__ = "5.0.0.4" __version__ = "5.0.0.5"