update examples

This commit is contained in:
Richard Smith 2024-11-16 20:11:08 +00:00 committed by Richard Smith
parent 4071263a59
commit a33f4fcc9a
40 changed files with 232 additions and 321 deletions

View file

@ -1,19 +1,4 @@
import pyray
from raylib.colors import (
RAYWHITE,
DARKGRAY,
DARKBLUE,
SKYBLUE,
MAROON,
ORANGE,
RED,
VIOLET,
BEIGE,
BROWN,
BLACK,
GREEN,
GOLD
)
# Initialization
@ -33,37 +18,37 @@ while not pyray.window_should_close():
# Draw
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
pyray.draw_circle(screenWidth // 5, 120, 35, DARKBLUE)
pyray.draw_circle_gradient(screenWidth // 5, 220, 60, GREEN, SKYBLUE)
pyray.draw_circle_lines(screenWidth // 5, 340, 80, DARKBLUE)
pyray.draw_circle(screenWidth // 5, 120, 35, pyray.DARKBLUE)
pyray.draw_circle_gradient(screenWidth // 5, 220, 60, pyray.GREEN, pyray.SKYBLUE)
pyray.draw_circle_lines(screenWidth // 5, 340, 80, pyray.DARKBLUE)
# Rectangle shapes and lines
pyray.draw_rectangle(screenWidth // 4 * 2 - 60, 100, 120, 60, RED)
pyray.draw_rectangle_gradient_h(screenWidth // 4 * 2 - 90, 170, 180, 130, MAROON, GOLD)
pyray.draw_rectangle_lines(screenWidth // 4 * 2 - 40, 320, 80, 60, ORANGE)
pyray.draw_rectangle(screenWidth // 4 * 2 - 60, 100, 120, 60, pyray.RED)
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, pyray.ORANGE)
# Triangle shapes and lines
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), 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.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
pyray.draw_poly(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 80, rotation, BROWN)
pyray.draw_poly_lines(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 90, rotation, BROWN)
pyray.draw_poly_lines_ex(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 85, rotation, 6, BEIGE)
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, pyray.BROWN)
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,
# 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()

View file

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

View file

@ -12,13 +12,6 @@
#********************************************************************************************/
import pyray
from raylib.colors import (
RAYWHITE,
LIGHTGRAY,
DARKGRAY,
GOLD,
MAROON,
)
SCREEN_WIDTH = 800
@ -50,17 +43,17 @@ while not pyray.window_should_close(): #// Detect window close button or ESC ke
#// Draw
#//----------------------------------------------------------------------------------
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_rectangle(560,0,pyray.get_screen_width()-500,pyray.get_screen_height(),pyray.fade(LIGHTGRAY,0.3))
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(pyray.LIGHTGRAY,0.3))
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:
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:
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
#//------------------------------------------------------------------------------
@ -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)
#//------------------------------------------------------------------------------
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.end_drawing()
#//------------------------------------------------------------------------------

View file

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

View file

@ -5,11 +5,6 @@ raylib [shapes] example - Lines Bezier
"""
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 raylib.colors import (
RAYWHITE,
BLACK,
GRAY
)
# Initialization
screenWidth = 800