예제 #1
0
    def __init__(self, path, scale=1.0):
        widget.Widget.__init__(self)
        self.path = path
        self.rw = rw.RW(path)
        surface_orig = IMG_Load_RW(self.rw.obj, 1)
        if not surface_orig: core.raisesdlerr()

        #hasalpha = (surface_orig.contents.flags & SDL_SRCALPHA) == SDL_SRCALPHA
        #SDL_SetAlpha(surface_orig, SDL_SRCALPHA, SDL_ALPHA_TRANSPARENT)
        #performance increase
        surface_displayformat = SDL_DisplayFormatAlpha(surface_orig)
        if not surface_displayformat: core.raisesdlerr()
        SDL_FreeSurface(surface_orig)

        if scale == 1.0:
            self.surface = surface_displayformat
        else:
            self.surface = rotozoomSurface(surface_displayformat, scale, scale,
                                           1)
            SDL_FreeSurface(surface_displayformat)

        #resetSize are for getSize
        self.resetSize()
        self.setRect()
        self.setScreenRect(0, 0)
예제 #2
0
파일: music.py 프로젝트: pyzzz/zzpysdl
def openAudio():
    global audioDeviceActive
    if audioDeviceActive:
        return
    movie.stop()  # if not call it, Mix_OpenAudio will failed after movie playing finish
    if Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 1024) < 0:
        core.raisesdlerr()
    audioDeviceActive = True
예제 #3
0
 def __init__(self, path):
     self.path = path
     arc_path, res_path = parsePath(path)
     core.logdebug("RW", arc_path, res_path)
     if arc_path:
         self.data = getArchiveData(arc_path, res_path)
         self.obj = SDL_RWFromConstMem(self.data, len(self.data))
     else:
         self.data = None
         self.obj = SDL_RWFromFile(res_path, "rb")
     if not self.obj:
         core.raisesdlerr()
예제 #4
0
파일: rw.py 프로젝트: pyzzz/zzpysdl
	def __init__(self, path):
		self.path = path
		arc_path, res_path = parsePath(path)
		core.logdebug("RW", arc_path, res_path)
		if arc_path:
			self.data = getArchiveData(arc_path, res_path)
			self.obj = SDL_RWFromConstMem(self.data, len(self.data))
		else:
			self.data = None
			self.obj = SDL_RWFromFile(res_path, "rb")
		if not self.obj:
			core.raisesdlerr()
예제 #5
0
파일: music.py 프로젝트: pyzzz/zzpysdl
def openAudio():
    global audioDeviceActive
    if audioDeviceActive:
        return
    movie.stop(
    )  #if not call it, Mix_OpenAudio will failed after movie playing finish
    if Mix_OpenAudio(
            MIX_DEFAULT_FREQUENCY,
            MIX_DEFAULT_FORMAT,
            MIX_DEFAULT_CHANNELS,
            1024,
    ) < 0:
        core.raisesdlerr()
    audioDeviceActive = True
예제 #6
0
파일: label.py 프로젝트: pyzzz/zzpysdl
	def __init__(self, label, font, r=0, g=0, b=0):
		widget.Widget.__init__(self)
		self.label = label
		self.color = SDL_Color(int(r), int(g), int(b))
		#Solid, Quick and Dirty
		#Shaded, Slow and Nice, but with a Solid Box
		#Blended, Slow Slow Slow, but Ultra Nice over another image
		self.surface = TTF_RenderUTF8_Blended(
			font,
			label,
			self.color,
		)
		if not self.surface: core.raisesdlerr()
		
		#didn't need SDL_DisplayFormatAlpha
		self.resetSize()
		self.setRect()
		self.setScreenRect(0, 0)
예제 #7
0
    def __init__(self, label, font, r=0, g=0, b=0):
        widget.Widget.__init__(self)
        self.label = label
        self.color = SDL_Color(int(r), int(g), int(b))
        #Solid, Quick and Dirty
        #Shaded, Slow and Nice, but with a Solid Box
        #Blended, Slow Slow Slow, but Ultra Nice over another image
        self.surface = TTF_RenderUTF8_Blended(
            font,
            label,
            self.color,
        )
        if not self.surface: core.raisesdlerr()

        #didn't need SDL_DisplayFormatAlpha
        self.resetSize()
        self.setRect()
        self.setScreenRect(0, 0)
예제 #8
0
파일: image.py 프로젝트: pyzzz/zzpysdl
	def __init__(self, path, scale=1.0):
		widget.Widget.__init__(self)
		self.path = path
		self.rw = rw.RW(path)
		surface_orig = IMG_Load_RW(self.rw.obj, 1)
		if not surface_orig: core.raisesdlerr()
		
		#hasalpha = (surface_orig.contents.flags & SDL_SRCALPHA) == SDL_SRCALPHA
		#SDL_SetAlpha(surface_orig, SDL_SRCALPHA, SDL_ALPHA_TRANSPARENT)
		#performance increase
		surface_displayformat = SDL_DisplayFormatAlpha(surface_orig)
		if not surface_displayformat: core.raisesdlerr()
		SDL_FreeSurface(surface_orig)
		
		if scale == 1.0:
			self.surface = surface_displayformat
		else:
			self.surface = rotozoomSurface(surface_displayformat, scale, scale, 1)
			SDL_FreeSurface(surface_displayformat)
		
		#resetSize are for getSize
		self.resetSize()
		self.setRect()
		self.setScreenRect(0, 0)