Exemple #1
0
    def __init__(self, config):
        self.name = "Frequency Domain"
        self.config = config

        self.audio_buffer = []
        self.wave_points = [rl.Vector2(0, 0) for i in range(400)]
        self.background_color = rl.Color(0, 0, 0, 255)
Exemple #2
0
    def __init__(self, config):
        self.name = "Basic Sound Wave"
        self.config = config

        self.wave_points = [
            rl.Vector2(0, 0) for i in range(config.audio_sample_size)
        ]
        self.wave_thickness = 1
        self.background_color = rl.Color(255, 0, 255, 255)
Exemple #3
0
    def on_draw(self, debug_mode):
        rl.clear_background(self.background_color)

        # Wave color should be the inverse of the background color
        wave_color = rl.Color(255 - self.background_color.r, 0,
                              255 - self.background_color.b, 255)
        for i in range(self.config.audio_sample_size - 1):
            rl.draw_line_v(self.wave_points[i], self.wave_points[i + 1],
                           wave_color)
Exemple #4
0
def lerp_color(db):
    t = db % 10 / 10
    if db == 0:
        return raylibpy.Color(raylibpy.BLACK)
    elif db < 10:
        return color_lerp(raylibpy.WHITE, raylibpy.BLUE, t)
    elif db < 20:
        return color_lerp(raylibpy.BLUE, raylibpy.GREEN, t)
    elif db < 30:
        return color_lerp(raylibpy.GREEN, raylibpy.YELLOW, t)
    elif db < 40:
        return color_lerp(raylibpy.YELLOW, raylibpy.ORANGE, t)
    elif db < 50:
        return color_lerp(raylibpy.ORANGE, raylibpy.RED, t)
    elif db < 60:
        return color_lerp(raylibpy.RED, raylibpy.PURPLE, t)
    else:
        return raylibpy.Color(raylibpy.PURPLE)
    def __init__(self, config):
        self.name = "Frequency and Wave"
        self.config = config

        self.audio_buffer = []
        self.freq_points = [rl.Vector2(0, 0) for i in range(400)]
        self.wave_points = [
            rl.Vector2(0, 0) for i in range(config.audio_sample_size)
        ]
        self.background_color = rl.Color(0, 0, 0, 255)
Exemple #6
0
import os

os.environ["RAYLIB_BIN_PATH"] = "raylib-2.0.0-Win64-mingw/lib/"
import raylibpy

raylibpy.init_window(900, 500, "Hello")
ball = raylibpy.Vector2(100, 100)

raylibpy.set_target_fps(60)

while not raylibpy.window_should_close():

    if raylibpy.is_key_down(raylibpy.KEY_RIGHT):
        ball.x += 5
    if raylibpy.is_key_down(raylibpy.KEY_DOWN):
        ball.y += 5

    raylibpy.begin_drawing()
    raylibpy.clear_background(raylibpy.Color(0, 0, 255, 255))
    raylibpy.draw_circle(ball.x, ball.y, 10.0, raylibpy.BLACK)
    raylibpy.end_drawing()

raylibpy.close_window()
        dat = data_np[i]
        dat2 = data_np[i + 1]
        raylibpy.draw_line(i, 300 - dat, i + 4, 300 - dat2, raylibpy.GREEN)
        raylibpy.draw_pixel(i, 256 - dat, raylibpy.BLUE)

    # column totals
    for i in range(len(ln_cols)):
        line = ln_cols[i]
        col_total = 0
        for x in line:
            col_total = col_total + y_data[x + ln_offset]
        col_ave = col_total / (1.0 * len(line))
        #print(col_total, "/ ", len(line), " = ", col_ave)

        raylibpy.draw_rectangle(i * col_width, 580 - col_ave * 2000, col_width,
                                580, raylibpy.Color(0, 100, 100, 150))

    # green column lines
    for i in range(0, num_cols):
        x = int(i * (W / num_cols))
        #raylibpy.draw_line(x, 330, x, H, raylibpy.GREEN)

    # purple line
    for i in range(0, max_ln - 1):
        dat = y_data[i + ln_offset]
        dat2 = y_data[i + 1 + ln_offset]
        x = int(ln_x[i])
        x2 = int(ln_x[i + 1])
        y = y2 = 580 * (1 - err)
        if dat > err:
            y = int(y - dat * 256 * 2)
Exemple #8
0
def main():

    # Initialization
    # ---------------------------------------------------------------
    screen_width = 800
    screen_height = 450

    rl.init_window(screen_width, screen_height, "raylib [core] example - 3d camera 1st person")

    # Define the camera to look into our 3d world (position, target, up vector)
    camera = rl.Camera(
        rl.Vector3(4.0, 2.0, 4.0),
        rl.Vector3(0.0, 1.8, 0.0),
        rl.Vector3(0.0, 1.0, 0.0),
        60.0,
        rl.CAMERA_PERSPECTIVE
    )

    # Generates some random columns
    heights = []
    positions = []
    colors = []

    for i in range(MAX_COLUMNS):
        heights.append(rl.get_random_value(1, 12))
        positions.append(rl.Vector3(
                rl.get_random_value(-15, 15),
                heights[-1] / 2,
                rl.get_random_value(-15, 15)
            )
        )
        colors.append(rl.Color(
                rl.get_random_value(20, 255),
                rl.get_random_value(10, 55),
                30,
                255
            )
        )

    rl.set_camera_mode(camera, rl.CAMERA_FIRST_PERSON)

    rl.set_target_fps(60)
    # ---------------------------------------------------------------

    # Main game loop
    while not rl.window_should_close():

        # Update
        # -----------------------------------------------------------
        rl.update_camera(byref(camera))
        # -----------------------------------------------------------

        # Draw
        # -----------------------------------------------------------
        rl.begin_drawing()

        rl.clear_background(rl.RAYWHITE)

        rl.begin_mode3d(camera)

        rl.draw_plane(rl.Vector3(0.0, 0.0, 0.0), rl.Vector2(32.0, 32.0), rl.LIGHTGRAY)
        rl.draw_cube(rl.Vector3(-16.0, 2.5, 0.0), 1.0, 5.0, 32.0, rl.BLUE)
        rl.draw_cube(rl.Vector3(16.0, 2.5, 0.0), 1.0, 5.0, 32.0, rl.LIME)
        rl.draw_cube(rl.Vector3(0.0, 2.5, 16.0), 32.0, 5.0, 1.0, rl.GOLD)

        # Draw some cubes around
        for i, position in enumerate(positions):
            rl.draw_cube(position, 2.0, heights[i], 2.0, colors[i])
            rl.draw_cube_wires(position, 2.0, heights[i], 2.0, rl.MAROON)

        rl.draw_rectangle(camera.target.x, -500, 1, screen_height * 4, rl.GREEN)
        rl.draw_rectangle(-500, camera.target.y, screen_width * 4, 1, rl.GREEN)

        rl.end_mode3d()

        # rl.draw_text(b"SCREEN AREA", 640, 10, 20, rl.RED)

        rl.draw_rectangle(10, 10, 220, 70, rl.fade(rl.SKYBLUE, 0.5))
        rl.draw_rectangle_lines(10, 10, 220, 70, rl.BLUE)
        
        rl.draw_text("First person camera default controls:", 20, 20, 10, rl.BLACK)
        rl.draw_text("- Move with keys: W, A, S, D", 40, 40, 10, rl.DARKGRAY)
        rl.draw_text("- Mouse move to look around", 40, 60, 10, rl.DARKGRAY)

        rl.end_drawing()
        # -----------------------------------------------------------

    # De-Initialization
    # ---------------------------------------------------------------
    rl.close_window()       # Close window and OpenGL context
Exemple #9
0
def color_lerp(ca, cb, t):
    r = ca.r * (1 - t) + cb.r * t
    g = ca.g * (1 - t) + cb.g * t
    b = ca.b * (1 - t) + cb.b * t
    return raylibpy.Color(r, g, b, 255)