Giter VIP home page Giter VIP logo

pyshiva's Introduction

pyShiva

The pyShiva project is an experiment in bringing lightning fast high quality 2d graphics to python via the pyshiva module. It aims to provide a simple vector-based API on top of the OpenGL-powered ShivaVG library.

Demo

This is how easy it is to write a complete pyShiva program!

#
# Rose Curves Demo
#

# Import the python module
import pyshiva as ps
import math, random

# Create a window with the title "Rose Curves"
w = ps.Window(title = "Rose Curves")

all_rects = list()

# Create 1000 squares with different colors
for i in range(1000):
	r = random.random()
	a = abs(math.cos(i))*0.5
	side_length = abs(math.sin(i))*50
	r = ps.Rect(0,0,side_length,side_length,(r,math.sin(i),math.cos(i),a))
	w.add(r) # Add the rectangles to the window...
	all_rects.append(r) # and keep track of them with a list

k = 0.25
while w.is_open():
	t = w.s_since_open()*2 # Use a scaled time since program start as the parametric time value
	radius = abs(math.sin(w.s_since_open()))
	if radius < 0.01: # Every time the curve collapses...
		k = random.random() # Randomize the k value to change the type of the curve
	# Place every rectangle along a rose curve, offset by its index
	for (i,r) in enumerate(all_rects):
		r.x = radius*math.cos(k*(t+i))*math.sin(t+i)*w.width/2+w.width/2
		r.y = radius*math.sin(k*(t+i))*math.sin(t+i)*w.height/2+w.height/2

	# Update the screen
	w.refresh()

##Status

Currently under heavy development.

##Full Documentation and Implementation Spec

Read it here. You can edit if if you are a collaborator.

##Compiling ShivaVG and GLFW on Ubuntu

sudo apt-get install libx11-dev
sudo apt-get install mesa-common-dev
sudo apt-get install libglu1-mesa-dev

cd glfw-2.7.7
make x11

sudo apt-get install cmake
sudo apt-get install freeglut3-dev # Required for the examples in ShivaVG
sudo apt-get install libjpeg-dev # Required for the examples in ShivaVG
sudo apt-get install libxmu-dev libxi-dev
sudo apt-get install g++ # Currently required until the CMake system is improved

cd ..

cd ShivaVG
cmake .
make

##Building the python wrapper on Ubuntu

Without this, you won't be able to run the python demos, make your own projects, or contribute to pyShiva's development.

sudo apt-get install python-dev
sudo apt-get install cython

cd wrapper
python setup.py install

##Testing the python wrapper

This demo creates animated circles in a flower-like arrangement.

cd wrapper
python rose_curves2.py

##License: GNU Lesser General Public License

Copyright (C) 2012 Julian Ceipek, Berit Johnson, Diana Vermilya, Charles Gwennap

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library in the file COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

###Note

pyShiva depends on and is distributed alongside several 3rd party libraries that are distributed with compatible licenses.

pyshiva's People

Contributors

jceipek avatar chazzz avatar dianavermilya avatar landswellsong avatar ileben avatar

Stargazers

James Brown avatar Adrien Demarez avatar Omran Jamal avatar Ted Feng avatar martin.z avatar Ionut Stoica avatar  avatar Mohammad Efazati avatar  avatar

Watchers

 avatar  avatar Berit avatar James Cloos avatar  avatar

pyshiva's Issues

Context is Backwards!

2D windowing systems almost always make the top left of the window (0,0).

In pyShiva, object positioning is relative to the bottom left corner, which is confusing since it is different from the way that window positioning works. However, it is in agreement to the standard cartesian coordinate system.

Add input handling

Mouse and keyboard input are important for interactivity in most types of applications that we want to support. GLFW should make it easy for us to implement input handling and expose it to python.

We should start by implementing a query based system and then implement a more robust callback system for users that want to make input handling more robust to rapid key presses and releases.

Compilation fails on Ubuntu

Following the tutorial I try to compile "ShivaVG" with "make". This is the result:

[  2%] Building C object src/CMakeFiles/OpenVG.dir/shExtensions.c.o
In file included from /usr/include/GL/glx.h:333:0,
                 from /home/woodoo/DevOS/Experiments/PythonGUI/pyShiva/ShivaVG/src/shDefs.h:170,
                 from /home/woodoo/DevOS/Experiments/PythonGUI/pyShiva/ShivaVG/src/shExtensions.c:23:
/usr/include/GL/glxext.h:508:143: error: unknown type name ‘GLintptr’
 typedef void ( *PFNGLXCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLint
                                                                                                                                               ^
/usr/include/GL/glxext.h:508:164: error: unknown type name ‘GLintptr’
 f void ( *PFNGLXCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr wr
                                                                                                                                                              ^
/usr/include/GL/glxext.h:508:186: error: unknown type name ‘GLsizeiptr’
 FFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr 
                                                                                                                                                              ^
/usr/include/GL/glxext.h:509:148: error: unknown type name ‘GLintptr’
 typedef void ( *PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, 
                                                                                                                                                    ^
/usr/include/GL/glxext.h:509:169: error: unknown type name ‘GLintptr’
 d ( *PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr wr
                                                                                                                                                              ^
/usr/include/GL/glxext.h:509:191: error: unknown type name ‘GLsizeiptr’
 FFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr 
                                                                                                                                                              ^
src/CMakeFiles/OpenVG.dir/build.make:62: recipe for target 'src/CMakeFiles/OpenVG.dir/shExtensions.c.o' failed
make[2]: *** [src/CMakeFiles/OpenVG.dir/shExtensions.c.o] Error 1
CMakeFiles/Makefile2:85: recipe for target 'src/CMakeFiles/OpenVG.dir/all' failed
make[1]: *** [src/CMakeFiles/OpenVG.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Very likely that's not what you intended.

I'm looking for a library I can use for implementing simple (and lightning fast) GUIs. I'd like to try out your library for that purpose. If you want to get in contact with me, please send an EMail to pubsrc (@) binary-overflow.de

Optimize refresh

With 10000 colored rectangles on the screen, it takes 0.379 seconds to call refresh once on my computer. That is very bad.

Note: The limiting factor does not appear to be the window size.

Add text support

Text is important for data visualization, debug information, games, and more.

Objects are never deallocated!

The amount of memory leaks in the C code and the Cython wrapper is truly terrible. This will get harder and harder to fix the more stuff we add.

Sample Code for Drawing Paths?

Is this project capable of drawing vector lines, bezziers or the like? If so, could some documentation for this functionality be added?

Thanks!

Make time accessible for smooth animations

Smooth animations require the ability to get the time since the last frame was drawn as well as the time that has elapsed since the window was last opened. GLFW will make this relatively trivial to implement.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.