How to use the ursina.color.red function in ursina

To help you get started, we’ve selected a few ursina examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pokepetter / ursina / ursina / mesh.py View on Github external
    def colorize(self, left=color.white, right=color.blue, down=color.red, up=color.green, back=color.white, forward=color.white, smooth=True, world_space=True):
        colorize(self, left, right, down, up, back, forward, smooth, world_space)
github pokepetter / ursina / ursina / internal_scripts / colorize.py View on Github external
def colorize(model, left=color.white, right=color.blue, down=color.red, up=color.green, back=color.white, forward=color.white):
    if model.normals == None:
        model.generate_normals()

    cols = list()
    for i, n in enumerate(model.normals):
        c = color.rgb((n[0]/2)+.5, (n[1]/2)+.5, (n[2]/2)+.5)
        c = lerp(up, down, (n[1]/2 +.5))

        if n[0] < 0:
            c = lerp(c, right, -(n[0]/2))
        else:
            c = lerp(c, left, (n[0]/2))
        c = (c[0], c[1], c[2], c[3])
        cols.append(c)

    model.colors = cols
github pokepetter / ursina / ursina / scripts / colorize.py View on Github external
def colorize(model, left=color.white, right=color.blue, down=color.red, up=color.green, back=color.white, forward=color.white, smooth=True, world_space=True):

    if not model.normals:
        print('generating normals for', model)
        model.generate_normals(smooth=smooth)

    if world_space:
        normals = get_world_normals(model)
    else:
        normals = model.normals

    cols = list()
    prev_col = color.white
    for n in normals:
        # c = color.rgb((n[0]/2)+.5, (n[1]/2)+.5, (n[2]/2)+.5)
        c = lerp(down, up, (n[1]/2 +.5))
github pokepetter / ursina / ursina / window.py View on Github external
def make_editor_gui(self):     # called by main after setting up camera and application.development_mode
        from ursina import camera, Text, Button, ButtonList, Func
        import time

        if not application.development_mode:
            return
        self.editor_ui = Entity(parent=camera.ui, eternal=True)
        self.exit_button = Button(parent=self.editor_ui, eternal=True, origin=(.5, .5), position=self.top_right, z=-999, scale=(.05, .025), color=color.red.tint(-.2), text='x', on_click=application.quit)

        def _exit_button_input(key):
            from ursina import held_keys, mouse
            if held_keys['shift'] and key == 'q' and not mouse.right:
                self.exit_button.on_click()
        self.exit_button.input = _exit_button_input

        self.fps_counter = Text(parent=self.editor_ui, eternal=True, position=(.5*self.aspect_ratio, .47, -999), origin=(.8,.5), text='60', ignore=False, i=0)

        def _fps_counter_update():
            if self.fps_counter.i > 60:
                self.fps_counter.text = str(int(1//time.dt))
                self.fps_counter.i = 0
            self.fps_counter.i += 1
        self.fps_counter.update = _fps_counter_update
github pokepetter / ursina / ursina / light.py View on Github external
cubes.append(Entity(model='cube', color=color.red, position=(-4,3,0)))
    cubes.append(Entity(model='cube', color=color.green, position=(0,3,0)))
    cubes.append(Entity(model='cube', color=color.blue, position=(4,3,0)))

    # add a light for all subsequent entities
    Light(type='ambient', color=(0.3,0.3,0.3,1))  # full spectrum

    cubes.append(Entity(model='cube', color=color.red, position=(-4,0,0)))
    cubes.append(Entity(model='cube', color=color.green, position=(0,0,0)))
    cubes.append(Entity(model='cube', color=color.blue, position=(4,0,0)))

    # add a light for all subsequent entities
    Light(type='directional', color=(0.3,0.3,0.3,1), direction=(1,1,1))  # dim full spectrum

    cubes.append(Entity(model='cube', color=color.red, position=(-4,-3,0)))
    cubes.append(Entity(model='cube', color=color.green, position=(0,-3,0)))
    cubes.append(Entity(model='cube', color=color.blue, position=(4,-3,0)))


    def update():
        for i in cubes:
            i.rotation_x += .3
            i.rotation_y += .3
            i.rotation_z += .2


    app.run()   # opens a window and starts the game.
github pokepetter / ursina / ursina / entity.py View on Github external
def __init__(self, **kwargs):
            super().__init__()
            self.model='cube'
            self.color = color.red
            self.scale_y = 2

            for key, value in kwargs.items():
                setattr(self, key, value)