Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bqplot_gl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Distributed under the terms of the Modified BSD License.

from .figure import FigureGL
from .marks import ScatterGL
from .marks import *
from ._version import __version__, version_info


Expand Down
22 changes: 21 additions & 1 deletion bqplot_gl/marks.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
from traitlets import Unicode

from bqplot import Scatter
from ipywidgets import register

from bqplot import Scatter, Lines

from ._version import __version__


__all__ = ['ScatterGL', 'LinesGL']


@register
class ScatterGL(Scatter):
_view_name = Unicode('ScatterGLView').tag(sync=True)
_model_name = Unicode('ScatterGLModel').tag(sync=True)
_model_module = Unicode('bqplot-gl').tag(sync=True)
_view_module = Unicode('bqplot-gl').tag(sync=True)
_view_module_version = Unicode('^' + __version__).tag(sync=True)
_model_module_version = Unicode('^' + __version__).tag(sync=True)


@register
class LinesGL(Lines):
_view_name = Unicode('LinesGLView').tag(sync=True)
_model_name = Unicode('LinesGLModel').tag(sync=True)
_view_module = Unicode('bqplot-gl').tag(sync=True)
_model_module = Unicode('bqplot-gl').tag(sync=True)
_view_module_version = Unicode('^' + __version__).tag(sync=True)
_model_module_version = Unicode('^' + __version__).tag(sync=True)
186 changes: 0 additions & 186 deletions image-gl/js/lib/linesgl.js

This file was deleted.

9 changes: 9 additions & 0 deletions shaders/lines-fragment.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
precision highp float;
precision highp int;


void main(void) {

gl_FragColor = vec4(1.0, 0., 0., 1.);

}
31 changes: 31 additions & 0 deletions shaders/lines-vertex.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <scales>

uniform mat4 projectionMatrix;
uniform mat4 modelViewMatrix;

uniform vec2 domain_x;
uniform vec2 domain_y;

uniform vec2 range_x;
uniform vec2 range_y;

attribute float x;
// attribute float x_previous;
attribute float y;
// attribute float y_previous;


#define SCALE_X(x) scale_transform_linear(x, range_x, domain_x)
#define SCALE_Y(x) scale_transform_linear(x, range_y, domain_y)
#define SCALE_SIZE(x) scale_transform_linear(x, range_size, domain_size)
#define SCALE_ROTATION(x) scale_transform_linear(x, range_rotation, domain_rotation)
#define SCALE_OPACITY(x) scale_transform_linear(x, range_opacity, domain_opacity)


void main(void) {

vec3 center_pixels = vec3(SCALE_X(x), SCALE_Y(y), 0);

gl_Position = projectionMatrix * modelViewMatrix * vec4(center_pixels, 1.0);

}
25 changes: 24 additions & 1 deletion shaders/scales.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,27 @@ float scale_transform_log_inverse(float range_value, vec2 range, vec2 domain) {
float normalized = (range_value - range[0]) / (range[1] - range[0]);
float domain_value = exp(normalized * (log(domain[1]) - log(domain[0])) + log(domain[0]));
return domain_value;
}
}

#define SCALE_TYPE_LINEAR 1
#define SCALE_TYPE_LOG 2

#ifdef USE_SCALE_X
uniform vec2 domain_x;
uniform vec2 range_x;
#if SCALE_TYPE_x == SCALE_TYPE_LINEAR
#define SCALE_X(x) scale_transform_linear(x, range_x, domain_x)
#elif SCALE_TYPE_x == SCALE_TYPE_LOG
#define SCALE_X(x) scale_transform_log(x, range_x, domain_x)
#endif
#endif

#ifdef USE_SCALE_Y
uniform vec2 domain_y;
uniform vec2 range_y;
#if SCALE_TYPE_y == SCALE_TYPE_LINEAR
#define SCALE_Y(x) scale_transform_linear(x, range_y, domain_y)
#elif SCALE_TYPE_y == SCALE_TYPE_LOG
#define SCALE_Y(x) scale_transform_log(x, range_y, domain_y)
#endif
#endif
40 changes: 40 additions & 0 deletions src/LinesGLModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* Copyright 2015 Bloomberg Finance L.P.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { MODULE_NAME, MODULE_VERSION } from './version';

import { LinesModel } from 'bqplot';


export class LinesGLModel extends LinesModel {
defaults() {
return {
...LinesModel.prototype.defaults(),
_model_name: LinesGLModel.model_name,
_model_module: LinesGLModel.model_module,
_model_module_version: LinesGLModel.model_module_version,
_view_name: LinesGLModel.view_name,
_view_module: LinesGLModel.view_module,
_view_module_version: LinesGLModel.view_module_version
}
}

static model_name = 'LinesGLModel';
static model_module = MODULE_NAME;
static model_module_version = MODULE_VERSION;
static view_name = 'LinesGLView';
static view_module = MODULE_NAME;
static view_module_version = MODULE_VERSION;
}
Loading