Skip to content

Instantly share code, notes, and snippets.

@cortical-iv
cortical-iv / keyboard_toggle_working.py
Created Feb 19, 2020
keyboard toggle of complex stim...working!
View keyboard_toggle_working.py
import numpy as np
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage
from panda3d.core import WindowProperties, ColorBlendAttrib, TransformState
from direct.showbase import ShowBaseGlobal
def sin_byte(X, freq = 1):
"""
Creates unsigned 8 bit representation of sin (T_unsigned_Byte).
"""
@cortical-iv
cortical-iv / keyboard_toggle.py
Last active Feb 19, 2020
dual card acting funny
View keyboard_toggle.py
import numpy as np
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage
from panda3d.core import WindowProperties, ColorBlendAttrib, TransformState
from direct.showbase import ShowBaseGlobal
def sin_byte(X, freq = 1):
"""
Creates unsigned 8 bit representation of sin (T_unsigned_Byte).
"""
@cortical-iv
cortical-iv / keyboard_texture_toggle.py
Created Feb 10, 2020
correct keyboard toggle of textures
View keyboard_texture_toggle.py
# fixed using rdb suggestion
import sys
import numpy as np
from direct.showbase.ShowBase import ShowBase
from direct.showbase import ShowBaseGlobal #global vars defined by p3d
from panda3d.core import Texture, CardMaker, TextureStage, KeyboardButton
from panda3d.core import WindowProperties
from direct.task import Task
@cortical-iv
cortical-iv / superimposed_textures.py
Created Feb 10, 2020
two textures superimposing rather than showing in series with 0/1 key press
View superimposed_textures.py
import sys
import numpy as np
from direct.showbase.ShowBase import ShowBase
from direct.showbase import ShowBaseGlobal #global vars defined by p3d
from panda3d.core import Texture, CardMaker, TextureStage, KeyboardButton
from panda3d.core import WindowProperties
from direct.task import Task
View How to show alternating stimuli that inherit from ShowBase?
import numpy as np
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage
from panda3d.core import WindowProperties
def rgb_texture(texture_size = 512, rgb = (0, 0, 0)):
x = np.linspace(-texture_size/2, texture_size/2, texture_size)
y = np.linspace(-texture_size/2, texture_size/2, texture_size)
X, Y = np.meshgrid(x, y)
@cortical-iv
cortical-iv / tex_cube_panda.py
Created Jul 17, 2019
Interpolation Matplotlib, nonmoving panda3d, and moving panda3d
View tex_cube_panda.py
"""
cube of concentric sinusoids: one shown in matplotlib, then in panda3d statically, then
in task manager in sequence when they turn dark.
"""
import numpy as np
import matplotlib.pyplot as plt
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage
from direct.task import Task
from direct.showbase import ShowBaseGlobal #global vars defined by p3d
View tex_scaling_working.py
"""
texture that scales over time.
Thanks go rdb for help
"""
import numpy as np
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage
from direct.task import Task
from panda3d.core import TransformState
@cortical-iv
cortical-iv / tex_scaling.py
Last active Jul 13, 2019
Trying to get single circle to shrink or dilate in middle of screen
View tex_scaling.py
import numpy as np
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage
from direct.task import Task
def make_circle_tex(texture_size = 512, circle_center = (0, 0), circle_radius = 50):
x = np.linspace(-texture_size/2, texture_size/2, texture_size)
y = np.linspace(-texture_size/2, texture_size/2, texture_size)
X, Y = np.meshgrid(x, y)
circle_texture = np.zeros((texture_size, texture_size), dtype = np.uint8)
@cortical-iv
cortical-iv / trs_texture_stage.py
Last active Mar 12, 2019
translate rotate scale attempt not quite working
View trs_texture_stage.py
"""
Why is this mask not rotating around the X? It is rotating in a circle around the origin.
Problem with trs_transform(), where trs = translate, rotate, scale.
With mask_position = (0, 0) it works fine. Once we move from the origin...yikes.
"""
import numpy as np
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage, TransformState
from direct.gui.OnscreenText import OnscreenText #for binocular stim
@cortical-iv
cortical-iv / ts_playtime.py
Last active Mar 11, 2019
Working with changing scale, position, rotation of texture stages
View ts_playtime.py
import numpy as np
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage, TransformState
from direct.gui.OnscreenText import OnscreenText #for binocular stim
import matplotlib.pyplot as plt
class CombineStages(ShowBase):
"""Trying to draw a mask stage over a stim stage and combine them (modulate)
Note debug variable is 1 to print vars, 2 to print vars and display mask from
matplotlib"""
You can’t perform that action at this time.