Exemple #1
0
	def run(self):
		ol.init()
		params = ol.RenderParams()
		params.render_flags = ol.RENDER_NOREORDER | ol.RENDER_GRAYSCALE
		ol.setRenderParams(params)

		while not self.die:
			ol.loadIdentity()
			for x,y in self.dots:
				ol.dot((x,y), 30, ol.C_WHITE)

			ol.renderFrame(100)
		ol.shutdown()
Exemple #2
0
    def run(self):
        ol.init()
        params = ol.RenderParams()
        params.render_flags = ol.RENDER_NOREORDER | ol.RENDER_GRAYSCALE
        ol.setRenderParams(params)

        while not self.die:
            ol.loadIdentity()
            for x, y in self.dots:
                ol.dot((x, y), 30, ol.C_WHITE)

            ol.renderFrame(100)
        ol.shutdown()
Exemple #3
0
	def run(self):
		while self.trace is None and not self.die:
			time.sleep(0.1)

		if self.die:
			return

		if ol.init(4) < 0:
			return
		print "OL Initialized"
		params = ol.RenderParams()
		params.render_flags = ol.RENDER_GRAYSCALE
		params.on_speed = 2/120.0
		params.off_speed = 2/30.0
		params.flatness = 0.000001
		params.max_framelen = 48000 / 25
		params.min_length = 30
		params.snap = 0.04
		ol.setRenderParams(params)
		ol.loadIdentity()
		ol.scale((2, -2))
		ol.translate((-0.5, -0.5))
		ol.scale((1/640.0, 1/640.0))
		ol.translate((0, (640-480)/2))

		while not self.die:
			#ol.rect((100, 100), (640-100, 480-100), ol.C_WHITE)
			objects = self.trace
			for o in objects:
				ol.begin(ol.POINTS)
				for point in o[::2]:
					ol.vertex(point, ol.C_WHITE)
				ol.end()
			ftime = ol.renderFrame(60)
		ol.shutdown()
def play_ugo(size, frames, meta):
    frame_pts = []
    total_time = 0
    for frame_meta in meta['frames']:
        frame_pts.append(total_time)
        total_time += frame_meta['delay'] / 1000.0

    if ol.init(3) < 0:
        return

    width, height = size

    params = ol.RenderParams()
    params.render_flags = ol.RENDER_GRAYSCALE
    params.on_speed = 2 / 60.0
    params.off_speed = 2 / 30.0
    params.flatness = 0.000001
    params.max_framelen = 48000 / 25
    params.min_length = 30
    params.snap = 0.04
    ol.setRenderParams(params)
    ol.loadIdentity()
    ol.scale((2, -2))
    ol.translate((-0.5, -0.5))
    mw = float(max(width, height))
    print width, height, mw
    ol.scale((1 / mw, 1 / mw))
    ol.translate(((mw - width) / 2, (mw - height) / 2))

    frame = 0
    time = 0

    DECIMATE = 2

    while True:
        while time > total_time:
            time -= total_time
            frame = 0

        while (frame + 1) < len(frames) and frame_pts[frame + 1] < time:
            frame += 1

        print "t=%.02f frame=%d" % (time, frame)

        objects = frames[frame]
        points = 0
        for o in objects:
            ol.begin(ol.POINTS)
            for point in o[::DECIMATE]:
                ol.vertex(point, ol.C_WHITE)
                points += 1
            ol.end()
        print "%d objects, %d points" % (len(objects), points)
        time += ol.renderFrame(60)

    ol.shutdown()
def play_ugo(size, frames, meta):
    frame_pts = []
    total_time = 0
    for frame_meta in meta['frames']:
        frame_pts.append(total_time)
        total_time += frame_meta['delay'] / 1000.0

    if ol.init(3) < 0:
        return

    width, height = size

    params = ol.RenderParams()
    params.render_flags = ol.RENDER_GRAYSCALE
    params.on_speed = 2/60.0
    params.off_speed = 2/30.0
    params.flatness = 0.000001
    params.max_framelen = 48000 / 25
    params.min_length = 30
    params.snap = 0.04
    ol.setRenderParams(params)
    ol.loadIdentity()
    ol.scale((2, -2))
    ol.translate((-0.5, -0.5))
    mw = float(max(width, height))
    print width, height, mw
    ol.scale((1/mw, 1/mw))
    ol.translate(((mw-width)/2, (mw-height)/2))

    frame = 0
    time = 0

    DECIMATE = 2

    while True:
        while time > total_time:
            time -= total_time
            frame = 0

        while (frame+1) < len(frames) and frame_pts[frame+1] < time:
            frame += 1

        print "t=%.02f frame=%d" % (time, frame)

        objects = frames[frame]
        points = 0
        for o in objects:
            ol.begin(ol.POINTS)
            for point in o[::DECIMATE]:
                ol.vertex(point, ol.C_WHITE)
                points += 1
            ol.end()
        print "%d objects, %d points" % (len(objects), points)
        time += ol.renderFrame(60)

    ol.shutdown()
Exemple #6
0
    def run(self):
        if ol.init(10) < 0:
            return
        params = ol.RenderParams()
        params.render_flags = ol.RENDER_NOREORDER | ol.RENDER_GRAYSCALE
        params.on_speed = 2 / 120.0
        params.off_speed = 2 / 30.0
        params.flatness = 0.000001
        ol.setRenderParams(params)
        ol.setPixelShader(self.shade)
        time = 0
        frames = 0
        cur_tweets = self.tweets
        xpos = 0
        idx = 0
        startpos = 1.3
        while not self.die:
            ol.loadIdentity3()
            ol.loadIdentity()

            if cur_tweets is None and self.tweets is not None:
                cur_tweets = self.tweets
                idx = 0
                xpos = startpos

            w = 0
            #print cur_tweets
            if cur_tweets is not None:
                font = ol.getDefaultFont()
                w = ol.getStringWidth(font, 0.4, cur_tweets[idx])
                col = ol.C_WHITE
                #print "Render %f %s 0x%x"%(xpos, cur_tweets[idx], col)
                ol.drawString(font, (xpos, 0.1), 0.4, col, cur_tweets[idx])

            #print "render"
            ftime = ol.renderFrame(60)
            #print "done"
            xpos -= 0.6 * ftime
            if xpos < (-w - 1) and cur_tweets is not None:
                xpos = startpos
                idx += 1
                idx %= len(cur_tweets)
                if self.tweets != cur_tweets:
                    idx = 0
                    cur_tweets = self.tweets
                    print("Reset and update")
                print("Finished, new idx: %d" % idx)
            frames += 1
            time += ftime
        ol.shutdown()
Exemple #7
0
	def run(self):
		if ol.init(10) < 0:
			return
		params = ol.RenderParams()
		params.render_flags = ol.RENDER_NOREORDER | ol.RENDER_GRAYSCALE
		params.on_speed = 2/120.0
		params.off_speed = 2/30.0
		params.flatness = 0.000001
		ol.setRenderParams(params)
		ol.setPixelShader(self.shade)
		time = 0
		frames = 0
		cur_tweets = self.tweets
		xpos = 0
		idx = 0
		startpos = 1.3
		while not self.die:
			ol.loadIdentity3()
			ol.loadIdentity()

			if cur_tweets is None and self.tweets is not None:
				cur_tweets = self.tweets
				idx = 0
				xpos = startpos

			w = 0
			#print cur_tweets
			if cur_tweets is not None:
				font = ol.getDefaultFont()
				w = ol.getStringWidth(font, 0.4, cur_tweets[idx])
				col = ol.C_WHITE
				#print "Render %f %s 0x%x"%(xpos, cur_tweets[idx], col)
				ol.drawString(font, (xpos,0.1), 0.4, col, cur_tweets[idx])
	
			#print "render"
			ftime = ol.renderFrame(60)
			#print "done"
			xpos -= 0.6*ftime
			if xpos < (-w-1) and cur_tweets is not None:
				xpos = startpos
				idx += 1
				idx %= len(cur_tweets)
				if self.tweets != cur_tweets:
					idx = 0
					cur_tweets = self.tweets
					print("Reset and update")
				print("Finished, new idx: %d"%idx)
			frames += 1
			time += ftime
		ol.shutdown()
Exemple #8
0
    def run(self):

        # Run the render loop.  This will repeatedly render frames of the current plugin.
        print '\t--> Starting up LUX Engine.'
        ftime = 0
        frames = 0

        # Initialize OpenLase.  This also creates the lux_engine jack endpoints.
        if (ol.init(3, 96000) != 0):
            raise Exception("Could not initialize openlase")

        # Connect the output engine to the lux_engine.
        self.output_engine.connect_ports("lux_engine:out_x", "lux_output:in_x")
        self.output_engine.connect_ports("lux_engine:out_y", "lux_output:in_y")
        self.output_engine.connect_ports("lux_engine:out_r", "lux_output:in_r")
        self.output_engine.connect_ports("lux_engine:out_g", "lux_output:in_g")
        self.output_engine.connect_ports("lux_engine:out_b", "lux_output:in_b")

        # Turn off the hardware safety interlock.
        self.output_engine.setOutputInitialized(True)

        # Create a local settings object for this thread.
        settings = LuxSettings()
        
        while not self.exiting:
            # Grab local references to these class variables
            self.lock.lock()
            current_plugin = self.current_plugin
            video_engine = self.video_engine
            self.lock.unlock()
            
            # SET PARAMETERS
            #
            # Check to see if the GUI parameter override has been set,
            # and we need to update OL parameters.
            if (self.ol_update_params and settings['calibration'].parameterOverride and current_plugin):
                current_plugin.setParametersToGuiValues()
                self.ol_update_params = False

            if (current_plugin and not settings['calibration'].parameterOverride):
                current_plugin.setParameters();

            # RENDER
            #
            # We call out to the current plugin's draw() method, or
            # the video plugin, depending on the current state of the
            # GUI.
            if (current_plugin):
                if (settings['video'].videoMode):
                    # Cause video color cycling to happen
                    ol.loadIdentity3();
                    ol.loadIdentity();
                    ol.perspective(60, 1, 1, 100);
                    ol.translate3((0, 0, -3));

                    ol.color3(*(self.video_color_drift.color_cycle()))
                    video_engine.draw_lasers()
                else:
                    current_plugin.draw()

                frame_render_time = ol.renderFrame(60)   # Takes max_fps as argument
                frames += 1
                ftime += frame_render_time
                #print "Frame time: %f, FPS:%f"%(frame_render_time, frame_render_time/ftime)
            else:
                # If there is no plugin for some reason, kill time
                # rather than burning CPU in a loop that does nothing.
                time.sleep(0.1)
Exemple #9
0
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 or version 3.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

import pylase as ol
from math import pi

ol.init()

time = 0
frames = 0

while True:
	ol.loadIdentity3()
	ol.loadIdentity()

	font = ol.getDefaultFont()
	s = "Hi!"
	w = ol.getStringWidth(font, 0.2, s)
	ol.drawString(font, (-w/2,0.1), 0.2, ol.C_WHITE, s)

	ol.perspective(60, 1, 1, 100)
	ol.translate3((0, 0, -3))
Exemple #10
0
# the Free Software Foundation, either version 2 or version 3.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

import pylase as ol

import sys

if ol.init(10) < 0:
    sys.exit(1)
params = ol.RenderParams()
params.render_flags = ol.RENDER_NOREORDER | ol.RENDER_GRAYSCALE
params.on_speed = 2 / 120.0
params.off_speed = 2 / 30.0
params.flatness = 0.000001
ol.setRenderParams(params)

lines = sys.argv[1:]

SIZE = 0.4

while True:
    lc = len(lines)
Exemple #11
0
# the Free Software Foundation, either version 2 or version 3.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

import pylase as ol

import sys

if ol.init(10) < 0:
	sys.exit(1)
params = ol.RenderParams()
params.render_flags = ol.RENDER_NOREORDER | ol.RENDER_GRAYSCALE
params.on_speed = 2/120.0
params.off_speed = 2/30.0
params.flatness = 0.000001
ol.setRenderParams(params)

lines = sys.argv[1:]

SIZE = 0.4

while True:
	lc = len(lines)
Exemple #12
0
                  help="Laser Power (20-1000)")
parser.add_option("-x",
                  "--xscale",
                  dest="xscale",
                  default=0.999,
                  help="X Scale for Laser Scan (0.001-0.999)")
parser.add_option("-y",
                  "--yscale",
                  dest="yscale",
                  default=0.999,
                  help="Y Scale for Laser Scan (0.001-0.999)")

(options, args) = parser.parse_args()

if options.laser:
    ol.init()

i = Image.open(options.pngfile)

pixels = i.load()  # this is not a list
width, height = i.size

scaledWidth = int(float(options.xscale) * width)
scaledHeight = int(float(options.yscale) * height)

cur_pixel = pixels[0, 0]
print cur_pixel

if options.vertical:
    rangeA = range(width)
    rangeB = range(height)
Exemple #13
0
    def run(self):

        # Run the render loop.  This will repeatedly render frames of the current plugin.
        print '\t--> Starting up LUX Engine.'
        ftime = 0
        frames = 0

        # Initialize OpenLase.  This also creates the lux_engine jack endpoints.
        if (ol.init(3, 96000) != 0):
            raise Exception("Could not initialize openlase")

        # Connect the output engine to the lux_engine.
        self.output_engine.connect_ports("lux_engine:out_x", "lux_output:in_x")
        self.output_engine.connect_ports("lux_engine:out_y", "lux_output:in_y")
        self.output_engine.connect_ports("lux_engine:out_r", "lux_output:in_r")
        self.output_engine.connect_ports("lux_engine:out_g", "lux_output:in_g")
        self.output_engine.connect_ports("lux_engine:out_b", "lux_output:in_b")

        # Turn off the hardware safety interlock.
        self.output_engine.setOutputInitialized(True)

        # Create a local settings object for this thread.
        settings = LuxSettings()

        while not self.exiting:
            # Grab local references to these class variables
            self.lock.lock()
            current_plugin = self.current_plugin
            video_engine = self.video_engine
            self.lock.unlock()

            # SET PARAMETERS
            #
            # Check to see if the GUI parameter override has been set,
            # and we need to update OL parameters.
            if (self.ol_update_params
                    and settings['calibration'].parameterOverride
                    and current_plugin):
                current_plugin.setParametersToGuiValues()
                self.ol_update_params = False

            if (current_plugin
                    and not settings['calibration'].parameterOverride):
                current_plugin.setParameters()

            if (self.reset_plugin_on_next_frame):
                current_plugin.reset()
                self.reset_plugin_on_next_frame = False

            # RENDER
            #
            # We call out to the current plugin's draw() method, or
            # the video plugin, depending on the current state of the
            # GUI.
            if (current_plugin):
                if (settings['video'].videoMode):
                    # Cause video color cycling to happen
                    ol.loadIdentity3()
                    ol.loadIdentity()
                    ol.perspective(60, 1, 1, 100)
                    ol.translate3((0, 0, -3))

                    ol.color3(*(self.video_color_drift.color_cycle()))
                    video_engine.draw_lasers()
                else:
                    current_plugin.draw()

                frame_render_time = ol.renderFrame(
                    60)  # Takes max_fps as argument
                frames += 1
                ftime += frame_render_time
                #print "Frame time: %f, FPS:%f"%(frame_render_time, frame_render_time/ftime)
            else:
                # If there is no plugin for some reason, kill time
                # rather than burning CPU in a loop that does nothing.
                time.sleep(0.1)
Exemple #14
0
	def ScanLayer(self, png_file, vertical, preview, laser, power, xscale, yscale):
		#png_file = path of png file to scan
		#vertical = True | False (Scan Direction)
		#laser = True | False (Should we laser??)
		#power = Laser Power ( 1-1000)
		#xscale = (float) 0.0-1.0 Scale of X
		#yscale = (float) 0.0-1.0 Scale of X
		
		if laser:
			pylase.init()

		i = Image.open(png_file)

		pixels = i.load() # this is not a list
		width, height = i.size

		scaledWidth=int(float(xscale)*width)
		scaledHeight=int(float(yscale)*height)

		cur_pixel = pixels[0, 0]
		print cur_pixel

		if vertical:
			rangeA = range(width)
			rangeB = range(height)
		else:
			rangeA = range(height)
			rangeB = range(width)
		 
		print "Computing the scanlines...."
		scanlines=[]
		for dirA in rangeA:
			scanline=[]
			scanning_on = False
			pixel_on =[0, 0]
			if laser:
				x = 0
				y = 0
			for dirB in rangeB:
				if vertical:
					x = dirA
					y = dirB
				else:
					x = dirB
					y = dirA
				if self.IsPixelOn(pixels[x, y]):
					if scanning_on == False:
						pixel_on = self.PixelCoordToGalvoCoord(x, y, width, height)
						scanning_on = True
				else:
					if scanning_on:
						scanline.append([pixel_on, self.PixelCoordToGalvoCoord(x, y, width, height)])
						scanning_on = False
			if scanning_on:
				scanline.append([pixel_on, self.PixelCoordToGalvoCoord(x, y, width, height)])
				scanning_on = False
			if len(scanline) > 0:
				scanlines.append(scanline)
			scanlines.append(scanline)

		if preview:
			pygame.init() 
			#create the screen
			window = pygame.display.set_mode((scaledWidth, scaledHeight)) 

		print "Found ",len(scanlines),"non blank scan lines... scanning now..."
		for l in scanlines:
			if laser:
				pylase.loadIdentity()
				pylase.scale((float(xscale), float(yscale)))
			for s in l: 
				if preview:
					pygame.draw.line(window, (0, 255, 0), self.GalvoCoordToPixelCoord(s[0], scaledWidth, scaledHeight), self.GalvoCoordToPixelCoord(s[1], scaledWidth, scaledHeight))
				if laser:
					pylase.line((s[0][0],s[0][1]), (s[1][0],s[1][1]), pylase.C_WHITE)	
			if preview:
				pygame.display.flip()
			if laser:
				pylase.renderFrame(int(power))