Skip to content

Instantly share code, notes, and snippets.

View GuillaumeFavelier's full-sized avatar

Guillaume Favelier GuillaumeFavelier

View GitHub Profile
@GuillaumeFavelier
GuillaumeFavelier / distinguishable_colors_example.py
Last active March 13, 2019 15:04
Function to generate a set of colors as distinct as possible in VisPy
# Ported from: http://www.mathworks.com/matlabcentral/fileexchange/29702-generate-maximally-perceptually-distinct-colors
import sys
import numpy as np
from vispy import scene
from vispy.color import ColorArray
from vispy.color.color_array import _rgb_to_lab
def distinguishable_colors(ncolors, bg=[0, 0, 0]):
n_grid = 30
#!/usr/bin/python
import sys
import numpy as np
import mne
from mne.preprocessing import ICA
argc = len(sys.argv)
# lists of data sources
@GuillaumeFavelier
GuillaumeFavelier / _VisPy_examples
Last active March 20, 2019 09:30
VisPy dummy testing
This file is here to name the Gist.
import sys
import numpy as np
from vispy import app, gloo, visuals
from vispy.visuals import transforms
N = 100
n = 10
width = 800
height = 600
@GuillaumeFavelier
GuillaumeFavelier / normal_mapping_example.py
Last active April 23, 2019 03:02
This example is a prototype demonstrating normal mapping in VisPy
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This example is a prototype demonstrating normal mapping
by comparison between a reference mesh and its flatten
version.
"""
import numpy as np
from vispy import app, gloo
This file is here to name the Gist.
@GuillaumeFavelier
GuillaumeFavelier / edl.py
Created June 8, 2019 10:15
PyVista Passes in the rendering
# https://github.com/pyvista/pyvista/issues/137
import vtk
sphere = vtk.vtkSphereSource()
sphere.SetCenter(0, 0, 0)
sphere.SetRadius(1)
sphere.Update()
elevation = vtk.vtkElevationFilter()
elevation.SetInputData(sphere.GetOutput())
@GuillaumeFavelier
GuillaumeFavelier / pbr.py
Created December 12, 2019 16:01
Physically Based Rendering (PBR) property for vtkPolyDataMapper
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import vtk
def sphere(center, radius=1.0, color='Gray', metallic=0.5, roughness=1.0):
colors = vtk.vtkNamedColors()
cx, cy, cz = center
@GuillaumeFavelier
GuillaumeFavelier / vtk_radio_button.py
Created December 19, 2019 12:39
Example of vtkButtonWidget and vtkBalloonWidget interactions
import vtk
def CreateButtonOff(image):
white = [255, 255, 255]
CreateImage(image, white, white)
def CreateButtonOn(image):
white = [255, 255, 255]
@GuillaumeFavelier
GuillaumeFavelier / slider.py
Created January 9, 2020 15:56
Hack for vtkSliderWidget with multiple handles
import pyvista as pv
import vtk
def foo(bar):
pass
def disable_tube(slider):
tr = slider.GetEventTranslator()