Skip to content

Instantly share code, notes, and snippets.

@cortical-iv
cortical-iv / destiny2_stats.txt
Created November 1, 2017 12:28
all raid, pve, and pvp stats available for a single user (json-formatted, slightly modified)
RAID STATS : {
"allTime": {
"activitiesCleared": {
"statId": "activitiesCleared",
"basic": {
"value": 3.0,
"displayValue": "3"
}
},
"activitiesEntered": {
@cortical-iv
cortical-iv / endpoint_classes.py
Last active January 5, 2018 03:49
Endpoint class example for Destiny 2 api
class Endpoint:
"""
Abstract end point class: this is never used directly. Concrete
endpoints inherit from this.
"""
def __init__(self, headers, request_parameters = None, url_arguments = None):
self.url_arguments = url_arguments
self.url_initial = self.make_url()
self.request_params = request_parameters
self.headers = headers
@cortical-iv
cortical-iv / pixel2d testing
Created January 27, 2019 05:34
tryying to get pixel2d to work
"""
panda3d learning
Exploring default scene graphs rooted with render, render2d, pixel2d
"""
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, NodePath #, PTAUchar,
import numpy as np
#Create random numpy array
size = 1024
@cortical-iv
cortical-iv / texture_transform_play.py
Last active January 31, 2019 06:16
Trying to make one texture smaller than card
"""
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
@cortical-iv
cortical-iv / tex_wrapmode.py
Last active January 31, 2019 15:12
Tex wrapping mode workspace
"""
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 / lum_mask.py
Last active February 8, 2019 15:14
Trying to get luminance_alphamask to work
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 / drifting_example.py
Last active February 10, 2019 14:06
Want both sinusoids to be full brightness, not half masked
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 / get_dpi.py
Created February 16, 2019 15:30
Calculate dpi in scale-sensitive way
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 / redcard_problem.py
Last active February 25, 2019 01:45
rgb or bgr?
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 / combine_rgb.py
Last active March 9, 2019 18:26
Attempt to setCombineRgb across cards
"""
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