Documentation ¶
Index ¶
- Constants
- Variables
- func FilePath(nm string) string
- func FilePaths(nm string) (string, string)
- func RotdirValue(s string) int
- func SpriteAdjustForAge(s Sprite, age float32)
- type Pipeline
- type PlaybackEvent
- type Realtime
- type Sprite
- type SpriteLine
- type SpriteParams
- type SpriteSquare
- type SpriteState
- type SpriteVector
- type Vizlet
- type VizletDrawer
- func (viz *VizletDrawer) AddSprite(s Sprite)
- func (viz *VizletDrawer) AgeSprites()
- func (viz *VizletDrawer) DoVizlet() error
- func (viz *VizletDrawer) DrawSprites()
- func (viz *VizletDrawer) Height() int
- func (viz *VizletDrawer) Name() string
- func (viz *VizletDrawer) OutputTexture() *glhf.Texture
- func (viz *VizletDrawer) SetInputFromVizlet(from Vizlet)
- func (viz *VizletDrawer) SetSpoutIn(spoutin string)
- func (viz *VizletDrawer) SetSpoutOut(spoutout string)
- func (viz *VizletDrawer) Shader() *glhf.Shader
- func (viz *VizletDrawer) Sprites() []Sprite
- func (viz *VizletDrawer) Width() int
- type VizletISF
- func (viz *VizletISF) DoVizlet() error
- func (viz *VizletISF) Height() int
- func (viz *VizletISF) Name() string
- func (viz *VizletISF) OutputTexture() *glhf.Texture
- func (viz *VizletISF) SetInputFromVizlet(from Vizlet)
- func (viz *VizletISF) SetSpoutIn(spoutin string)
- func (viz *VizletISF) SetSpoutOut(spoutout string)
- func (viz *VizletISF) Shader() *glhf.Shader
- func (viz *VizletISF) Width() int
Constants ¶
const ( RadToDeg = 180 / math.Pi DegToRad = math.Pi / 180 )
RadToDeg and DegToRad are conversion factors
Variables ¶
var DebugISF = true
DebugISF xxx
var DebugShader = false
DebugShader xxx
var DefaultFragmentShader = `
#version 330
uniform sampler2D tex;
uniform vec2 tjt;
in vec2 fragTexCoord;
in vec4 finalcolor;
in vec2 finaldebug;
in vec2 finaltjt;
out vec4 outputColor;
void main() {
outputColor = finalcolor;
// if ( finaldebug.x < 0.5 ) {
// outputColor = texture(tex, fragTexCoord);
// } else if ( finaldebug.x > 0.5 ) {
outputColor.r = 0.0;
outputColor.g = 0.8;
outputColor.b = 0.0;
outputColor = texture(tex, fragTexCoord);
outputColor.r = 1.0;
// }
}
` + "\x00"
DefaultFragmentShader xxx
var DefaultVertexShader = `
#version 330
uniform mat4 projection;
uniform vec4 color;
uniform vec4 misc;
uniform vec2 debug;
in vec3 vert;
in vec2 vertTexCoord;
out vec2 fragTexCoord;
out vec4 finalcolor;
out vec4 finalvert;
out int finaltype;
out vec2 finaldebug;
vec3 hsl2rgb( in vec3 c )
{
vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );
return c.z + c.y * (rgb-0.5)*(1.0-abs(2.0*c.z-1.0));
}
vec3 HueShift (in vec3 Color, in float Shift)
{
vec3 P = vec3(0.55735)*dot(vec3(0.55735),Color);
vec3 U = Color-P;
vec3 V = cross(vec3(0.55735),U);
Color = U*cos(Shift*6.2832) + V*sin(Shift*6.2832) + P;
return vec3(Color);
}
vec3 rgb2hsl( in vec3 c ){
float h = 0.0;
float s = 0.0;
float l = 0.0;
float r = c.r;
float g = c.g;
float b = c.b;
float cMin = min( r, min( g, b ) );
float cMax = max( r, max( g, b ) );
l = ( cMax + cMin ) / 2.0;
if ( cMax > cMin ) {
float cDelta = cMax - cMin;
//s = l < .05 ? cDelta / ( cMax + cMin ) : cDelta / ( 2.0 - ( cMax + cMin ) ); Original
s = l < .0 ? cDelta / ( cMax + cMin ) : cDelta / ( 2.0 - ( cMax + cMin ) );
if ( r == cMax ) {
h = ( g - b ) / cDelta;
} else if ( g == cMax ) {
h = 2.0 + ( b - r ) / cDelta;
} else {
h = 4.0 + ( r - g ) / cDelta;
}
if ( h < 0.0) {
h += 6.0;
}
h = h / 6.0;
}
return vec3( h, s, l );
}
vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main() {
float angle = misc.x;
float invsize = 1.0 / misc.y;
float size = misc.y;
float x = misc.z;
float y = misc.w;
fragTexCoord = vertTexCoord;
finalvert = vec4(size*vert.x,size*vert.y,vert.z,1);
if (angle != 0.0) {
mat4 rotation = mat4(mat2(
cos(angle), -sin(angle),
sin(angle), cos(angle)));
finalvert = finalvert * rotation;
}
finalvert.x += x;
finalvert.y += y;
gl_Position = projection * finalvert;
vec4 mycolor = vec4(hsl2rgb(vec3(color.x,color.y,color.z)), color.a);
finalcolor = mycolor;
finaltype = 1;
finaldebug = debug;
}
` + "\x00"
DefaultVertexShader xxx
var FragmentShader2 = `
#version 330
uniform sampler2D tex;
uniform vec2 tjt;
in vec2 fragTexCoord;
in vec4 finalcolor;
in vec2 finaldebug;
in vec2 finaltjt;
out vec4 outputColor;
void main() {
outputColor = finalcolor;
// if ( finaldebug.x < 0.5 ) {
// outputColor = texture(tex, fragTexCoord);
// } else if ( finaldebug.x > 0.5 ) {
outputColor.r = 0.0;
outputColor.g = 0.0;
outputColor.b = 0.8;
outputColor = texture(tex, fragTexCoord);
outputColor.g = 1.0;
// }
}
` + "\x00"
FragmentShader2 xxx
var LineVerticesForLines = []float32{
0.0, 0.0, 1.0, 0.0, 0.0,
1.0, 0.0, 1.0, 1.0, 0.0,
}
LineVerticesForLines xxx
var LineVerticesForLines2 = []float32{
0.0, 0.0, 1.0, 0.0, 0.0,
1.0, 0.0, 1.0, 1.0, 0.0,
}
LineVerticesForLines2 xxx
var SquareVerticesForLines = []float32{
-1.0, -1.0, 1.0, 0.0, 0.0,
1.0, -1.0, 1.0, 1.0, 0.0,
1.0, -1.0, 1.0, 1.0, 0.0,
1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0,
-1.0, 1.0, 1.0, 0.0, 1.0,
-1.0, 1.0, 1.0, 0.0, 1.0,
-1.0, -1.0, 1.0, 0.0, 0.0,
}
SquareVerticesForLines xxx
var SquareVerticesForLines2 = []float32{
-1.0, -1.0, 1.0, 0.0, 0.0,
1.0, -1.0, 1.0, 1.0, 0.0,
1.0, -1.0, 1.0, 1.0, 0.0,
1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0,
-1.0, 1.0, 1.0, 0.0, 1.0,
-1.0, 1.0, 1.0, 0.0, 1.0,
-1.0, -1.0, 1.0, 0.0, 0.0,
}
SquareVerticesForLines2 xxx
var SquareVerticiesForTriangles = []float32{
-1.0, -1.0, 1.0, 1.0, 0.0,
1.0, -1.0, 1.0, 0.0, 0.0,
-1.0, 1.0, 1.0, 1.0, 1.0,
1.0, -1.0, 1.0, 0.0, 0.0,
1.0, 1.0, 1.0, 0.0, 1.0,
-1.0, 1.0, 1.0, 1.0, 1.0,
}
SquareVerticiesForTriangles xxx
var SquareVerticiesForTriangles2 = []float32{
-1.0, -1.0, 1.0, 1.0, 0.0,
1.0, -1.0, 1.0, 0.0, 0.0,
-1.0, 1.0, 1.0, 1.0, 1.0,
1.0, -1.0, 1.0, 0.0, 0.0,
1.0, 1.0, 1.0, 0.0, 1.0,
-1.0, 1.0, 1.0, 1.0, 1.0,
}
SquareVerticiesForTriangles2 xxx
var VertexShader2 = `
#version 330
uniform mat4 projection;
uniform vec4 color;
uniform vec4 misc;
uniform vec2 debug;
in vec3 vert;
in vec2 vertTexCoord;
out vec2 fragTexCoord;
out vec4 finalcolor;
out vec4 finalvert;
out int finaltype;
out vec2 finaldebug;
vec3 hsl2rgb( in vec3 c )
{
vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );
return c.z + c.y * (rgb-0.5)*(1.0-abs(2.0*c.z-1.0));
}
vec3 HueShift (in vec3 Color, in float Shift)
{
vec3 P = vec3(0.55735)*dot(vec3(0.55735),Color);
vec3 U = Color-P;
vec3 V = cross(vec3(0.55735),U);
Color = U*cos(Shift*6.2832) + V*sin(Shift*6.2832) + P;
return vec3(Color);
}
vec3 rgb2hsl( in vec3 c ){
float h = 0.0;
float s = 0.0;
float l = 0.0;
float r = c.r;
float g = c.g;
float b = c.b;
float cMin = min( r, min( g, b ) );
float cMax = max( r, max( g, b ) );
l = ( cMax + cMin ) / 2.0;
if ( cMax > cMin ) {
float cDelta = cMax - cMin;
//s = l < .05 ? cDelta / ( cMax + cMin ) : cDelta / ( 2.0 - ( cMax + cMin ) ); Original
s = l < .0 ? cDelta / ( cMax + cMin ) : cDelta / ( 2.0 - ( cMax + cMin ) );
if ( r == cMax ) {
h = ( g - b ) / cDelta;
} else if ( g == cMax ) {
h = 2.0 + ( b - r ) / cDelta;
} else {
h = 4.0 + ( r - g ) / cDelta;
}
if ( h < 0.0) {
h += 6.0;
}
h = h / 6.0;
}
return vec3( h, s, l );
}
vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main() {
float angle = misc.x;
float invsize = 1.0 / misc.y;
float size = misc.y;
float x = misc.z;
float y = misc.w;
fragTexCoord = vertTexCoord;
finalvert = vec4(size*vert.x,size*vert.y,vert.z,1);
if (angle != 0.0) {
mat4 rotation = mat4(mat2(
cos(angle), -sin(angle),
sin(angle), cos(angle)));
finalvert = finalvert * rotation;
}
finalvert.x += x;
finalvert.y += y;
gl_Position = projection * finalvert;
vec4 mycolor = vec4(hsl2rgb(vec3(color.x,color.y,color.z)), color.a);
finalcolor = mycolor;
finaltype = 1;
finaldebug = debug;
}
` + "\x00"
VertexShader2 xxx
Functions ¶
func SpriteAdjustForAge ¶
SpriteAdjustForAge updates a SpriteState's values to reflect a given age
Types ¶
type PlaybackEvent ¶
type PlaybackEvent struct {
// contains filtered or unexported fields
}
PlaybackEvent is a time-tagged cursor or API event
type Realtime ¶
type Realtime struct {
// contains filtered or unexported fields
}
Realtime takes events and routes them
type Sprite ¶
type Sprite interface { Draw(*glhf.Shader) ID() string SpriteState() *SpriteState SpriteParams() *SpriteParams AdjustForAge(age float32) }
Sprite xxx
type SpriteLine ¶
type SpriteLine struct { Sprite State *SpriteState Params *SpriteParams }
SpriteLine xxx
func NewSpriteLine ¶
func NewSpriteLine(x, y, z float32, params *engine.ParamValues) *SpriteLine
NewSpriteLine xxx
func (*SpriteLine) SpriteParams ¶
func (s *SpriteLine) SpriteParams() *SpriteParams
SpriteParams xxx
type SpriteParams ¶
type SpriteParams struct {
// contains filtered or unexported fields
}
SpriteParams xxx
func NewSpriteParams ¶
func NewSpriteParams(params *engine.ParamValues) *SpriteParams
NewSpriteParams xxx
type SpriteSquare ¶
type SpriteSquare struct { Sprite State *SpriteState Params *SpriteParams }
SpriteSquare xxx
func NewSpriteSquare ¶
func NewSpriteSquare(x, y, z float32, params *engine.ParamValues) *SpriteSquare
NewSpriteSquare xxx
func (*SpriteSquare) SpriteParams ¶
func (s *SpriteSquare) SpriteParams() *SpriteParams
SpriteParams xxx
func (*SpriteSquare) SpriteState ¶
func (s *SpriteSquare) SpriteState() *SpriteState
SpriteState xxx
type SpriteState ¶
type SpriteState struct { NoAging bool // if true, the Sprite doesn't age // contains filtered or unexported fields }
SpriteState xxx
type SpriteVector ¶
type SpriteVector struct {
// contains filtered or unexported fields
}
SpriteVector xxx
type Vizlet ¶
type Vizlet interface { Name() string DoVizlet() error OutputTexture() *glhf.Texture SetSpoutIn(string) SetSpoutOut(string) SetInputFromVizlet(Vizlet) AddSprite(Sprite) // Eventually this should go elsewhere, when cursor handling gets put into Vizlet interface AgeSprites() // Ditto, when Vizlet interface starts handling click advance }
Vizlet xxx
func NewVizletDrawer ¶
NewVizletDrawer xxx
type VizletDrawer ¶
type VizletDrawer struct { Vizlet // contains filtered or unexported fields }
VizletDrawer is one Drawer shader within a Pipeline
func (*VizletDrawer) OutputTexture ¶
func (viz *VizletDrawer) OutputTexture() *glhf.Texture
OutputTexture xxx
func (*VizletDrawer) SetInputFromVizlet ¶
func (viz *VizletDrawer) SetInputFromVizlet(from Vizlet)
SetInputFromVizlet xxx
func (*VizletDrawer) SetSpoutIn ¶
func (viz *VizletDrawer) SetSpoutIn(spoutin string)
SetSpoutIn xxx
func (*VizletDrawer) SetSpoutOut ¶
func (viz *VizletDrawer) SetSpoutOut(spoutout string)
SetSpoutOut xxx
type VizletISF ¶
type VizletISF struct { Vizlet // contains filtered or unexported fields }
VizletISF is one ISF shader within a Pipeline
func (*VizletISF) OutputTexture ¶
OutputTexture xxx
func (*VizletISF) SetInputFromVizlet ¶
SetInputFromVizlet xxx