Skip to content

Instantly share code, notes, and snippets.

cortical-iv

Block or report user

Report or block cortical-iv

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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"""
@cortical-iv
cortical-iv / rotate_ts.py
Created Mar 9, 2019
Rotation of one texture stage seems to go all askew
View rotate_ts.py
"""
Goal: rotate mask so it stays centered on the X.
What happens: it rotates and shifts, as if the origin of the coordinate system is
not at the center of the window.
"""
import numpy as np
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage
from direct.gui.OnscreenText import OnscreenText #for binocular stim
import matplotlib.pyplot as plt
@cortical-iv
cortical-iv / combine_rgb.py
Last active Mar 9, 2019
Attempt to setCombineRgb across cards
View combine_rgb.py
"""
Want to combine (CMModulate) two texture stages from two cards,
but am just seeing the top card's texture stage.
"""
import numpy as np
from scipy import signal #for grating (square wave)
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage
from panda3d.core import TransparencyAttrib
View redcard_problem.py
import numpy as np
import matplotlib.pyplot as plt
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage
def rgb_texture_byte(texture_size = 512, rgb = (0, 0, 0)):
""" Return Could just set card's bg color but this has other uses."""
if not (all([x >= 0 for x in rgb]) and all([x <= 255 for x in rgb])):
raise ValueError("rgb values must lie in [0,255]")
rgb_texture = np.zeros((texture_size, texture_size, 3), dtype = np.uint8)
@cortical-iv
cortical-iv / get_dpi.py
Created Feb 16, 2019
Calculate dpi in scale-sensitive way
View get_dpi.py
import sys
def get_dpi(screen_num = 0):
"""Calculate the dpi of a given monitor, sensitive to
scaling factors they have set."""
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
screen = app.screens()[screen_num]
dpi = screen.physicalDotsPerInch()
app.quit()
return dpi
@cortical-iv
cortical-iv / drifting_example.py
Last active Feb 10, 2019
Want both sinusoids to be full brightness, not half masked
View drifting_example.py
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage, TransparencyAttrib
import numpy as np
from direct.gui.OnscreenText import OnscreenText
from direct.task import Task
#Create sin
texSize = 512
frequency = 8
def sin3d(X, freq = 1):
@cortical-iv
cortical-iv / lum_mask.py
Last active Feb 8, 2019
Trying to get luminance_alphamask to work
View lum_mask.py
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TransparencyAttrib
import numpy as np
#Create texture
texSize = 512
frequency = 8
def sin3d(X, freq = 1):
return np.sin(X*freq)
def sin8bit(X, freq = 1):
@cortical-iv
cortical-iv / tex_wrapmode.py
Last active Jan 31, 2019
Tex wrapping mode workspace
View tex_wrapmode.py
"""
Trying to get repeated texture
"""
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker
import numpy as np
#Create texture
texSize = 64
texture = 210*np.ones((texSize, texSize), dtype = np.uint8)
@cortical-iv
cortical-iv / texture_transform_play.py
Last active Jan 31, 2019
Trying to make one texture smaller than card
View texture_transform_play.py
"""
Want the sine texture to be a little square inside the card, with noise texture filling the card.
"""
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, TextureStage
from direct.gui.OnscreenText import OnscreenText
import numpy as np
#Create matrices for textures
#sin
You can’t perform that action at this time.