Best JavaScript code snippet using taiko
ComicVisorGui.py
Source:ComicVisorGui.py
1import zipfile2from tkinter import *3from PIL import Image, ImageTk4from tkinter import Tk,ttk5from tkinter import filedialog6import Entidades.Init7from Entidades.ComicBooks.ComicBook import ComicBook8from Entidades.ComicBooks.ComicBookDetail import ComicBookDetails9class ComicVisorGui(Toplevel):10 def __init__(self,master,comicBook=None, session = None,cnf={},**kw):11 Toplevel.__init__(self,master,cnf,**kw)12 if session is None:13 self.session = Entidades.Init.Session()14 else:15 self.session = session16 if not comicBook:17 self.comicBook = ComicBook('BabelComics.cbz')18 else:19 self.comicBook = comicBook20 self.idImagen = None21 self.tipoAjuste = IntVar()22 self.tipoAjuste.set(3)23 self.title('Babel Comic Visor')24 self.crearMenu()25 self.mainframe = ttk.Frame(self)26 self.scrollbarY = Scrollbar(self.mainframe)27 self.scrollbarX = Scrollbar(self.mainframe)28 self.canvas = Canvas(self.mainframe, yscrollcommand=self.scrollbarY.set, xscrollcommand=self.scrollbarX.set)29 self.comicBook.openCbFile()30 #self.fImage= self.comicBook.getImagePage()31 self.im = self.comicBook.getImagePage()32 self.myimg = ImageTk.PhotoImage(self.im)33 self.contadorFondo = 034 self.cargarPagina()35 self.update()36 self.ajustarAncho()37 ##canvas.create_image(0,0,image=myimg)38 self.canvas.bind('<MouseWheel>', self.scrollupMouse)39 self.bind('<Up>', self.scrollupKeyboard)40 self.bind('<Down>', self.scrollupKeyboard)41 self.bind('<Left>', self.scrollupKeyboard)42 self.bind('<Right>', self.scrollupKeyboard)43 self.bind('<Prior>', self.scrollupKeyboard)44 self.bind('<Next>', self.scrollupKeyboard)45 self.bind('<Key>', self.scrollupKeyboard)46 self.bind('<Key>', self.scrollupKeyboard)47 self.bind('<space >', self.scrollupKeyboard)48 self.scrollbarY.config(command=self.canvas.yview)49 self.scrollbarX.config(command=self.canvas.xview)50 self.bind("<Button-1>",self.click)51 self.canvas.pack(side=BOTTOM, expand=YES, fill=BOTH)52 ##Tener cuidado cuando se hace el pack no se puede hacer en cualquier orden53 self.mainframe.pack(side=BOTTOM, expand=YES, fill=BOTH)54 self.canvas.config(scrollregion=self.canvas.bbox(ALL))55 def click(self,event):56 if (event.x>self.winfo_width()/2):57 event.keycode=11758 self.scrollupKeyboard(event)59 else:60 event.keycode=11261 self.scrollupKeyboard(event)62 print(self.winfo_width())63 print("clicked: "+str(event.x))64 def abrirComic(self):65 global comic,indicePaginaActual,paginas66 cbz = filedialog.askopenfile('r',initialdir='/home/pedro/Descargas/ftp/',filetypes = [("comic","*.cbz")])67 ## cbz = filedialog.askopenfile('r',initialdir='.',filetypes = [("comic","*.cbz")])68 print(cbz)69 if cbz:70 comic = zipfile.ZipFile(cbz.name,'r')71 paginas.clear()72 paginas = [x for x in comic.namelist() if(x[-3:]=='jpg' or x[-3:]=='png')]73 indicePaginaActual=074 self.cargarPagina()75 def salir(self):76 comic.close()77 root.destroy()78 def ajustarAncho(self):79 #global tipoAjuste80 self.tipoAjuste.set(1)81 self.cargarPagina()82 def ajustarAlto(self):83 #global tipoAjuste84 self.tipoAjuste.set(2)85 self.cargarPagina()86 def ajustarNormal(self):87 #global tipoAjuste88 self.tipoAjuste.set(3)89 self.cargarPagina()90 def crearMenu(self):91 #global tipoAjuste92 self.menu = Menu(self)93 self.submenuArchivo = Menu(self.menu, tearoff=0)94 self.submenuArchivo.add_command(label = 'Abrir Comic', command = self.abrirComic, accelerator = 'o')95 self.submenuArchivo.add_command(label = 'Salir', command = self.salir, accelerator = 'q')96 self.submenuImagen = Menu(self.menu, tearoff=0)97 self.submenuImagen.add('radiobutton',variable=self.tipoAjuste,label='ajustar al ancho',command=self.ajustarAncho,accelerator = 'w',value=1)98 self.submenuImagen.add('radiobutton',variable=self.tipoAjuste,label='ajustar al alto',command=self.ajustarAlto,accelerator = 'h',value=2)99 self.submenuImagen.add('radiobutton',variable=self.tipoAjuste,label='tamaño normal',command=self.ajustarNormal,accelerator = 'n',value=3)100 self.menu.add_cascade(label = 'Archivo',menu=self.submenuArchivo)101 self.menu.add_cascade(label = 'Imagen',menu=self.submenuImagen)102 self.config(menu=self.menu)103 def scrollupMouse(self,event):104 self.canvas.yview_scroll(-1*(int)(event.delta/120), "units")105 def scrollupKeyboard(self,event):106 print(event.keycode)107 #si es spacebar108 print(self.scrollbarY.get()[1])109 if((event.keycode== 65 or event.keycode==116) and self.scrollbarY.get()[1]==1):110 print(self.contadorFondo)111 self.contadorFondo+=1112 if self.contadorFondo>2:113 print('cambiamos el event')114 event.keycode = 117115 print('cambiamos el event')116 if (event.keycode== 111)|(event.keycode== 38):117 self.canvas.yview_scroll(-1, "units")118 self.contadorFondo = 0119 elif (event.keycode== 116)|(event.keycode== 40)|(event.keycode== 65):120 self.canvas.yview_scroll(1, "units")121 elif (event.keycode== 113)|(event.keycode== 37):122 self.canvas.xview_scroll(-1, "units")123 self.contadorFondo = 0124 elif (event.keycode== 114)|(event.keycode== 39):125 self.canvas.xview_scroll(1, "units")126 elif (event.keycode == 117)|(event.keycode == 34):127 #pag down128 self.contadorFondo = 0129 self.comicBook.indicePaginaActual+=1130 self.comicBook.goto(self.comicBook.indicePaginaActual)131 self.cargarPagina()132 elif (event.keycode == 112)|(event.keycode == 33):133 # pag up134 self.comicBook.indicePaginaActual-=1135 self.comicBook.goto(self.comicBook.indicePaginaActual)136 self.cargarPagina()137 ## q Key normal138 elif (event.keysym == 'q'):139 self.salir()140 ## w Key ancho141 elif (event.keysym == 'w'):142 self.ajustarAncho()143 ## h Key altura144 elif (event.keysym == 'h'):145 self.ajustarAlto()146 ## n Key quit147 elif (event.keysym == 'n'):148 self.ajustarNormal()149 ## o Key open150 elif (event.keysym == 'o'):151 self.abrirComic()152 ## g Key open153 elif (event.keycode == 1):154 print(event.keycode)155 elif (event.keysym == 'c'):156 self.setCover()157 print(event.keysym)158 def setCover(self):159 self.session.query(ComicBookDetails).filter(ComicBookDetails.comicId==self.comicBook.comicId).filter(ComicBookDetails.tipoPagina==ComicBookDetails.COVER).delete()160 self.session.commit()161 comicBookDetail = ComicBookDetails()162 comicBookDetail.comicId = self.comicBook.comicId163 comicBookDetail.indicePagina = self.comicBook.indicePaginaActual164 comicBookDetail.tipoPagina = ComicBookDetails.COVER165 self.session.add(comicBookDetail)166 self.session.commit()167 def cargarPagina(self):168 # global canvas,myimg,idImagen,mainframe169 alturaImagen=anchoImagen=0170 self.canvas.update()171 self.alturaFrame=self.winfo_height()172 self.anchoFrame=self.winfo_width()173 print('indice pagina:',self.comicBook.indicePaginaActual)174 fImage = self.comicBook.getImagePage()175 im = self.comicBook.getImagePage()176 tasa = 1177 if (self.tipoAjuste.get()==2):178 tasa= self.alturaFrame/im.height179 elif (self.tipoAjuste.get()==1):180 tasa= self.anchoFrame/im.width181 elif (self.tipoAjuste.get()==3):182 tasa=1183 size = (int)(im.width*tasa),(int)(im.height*tasa)184 im=im.resize(size,Image.BICUBIC)185 self.myimg = ImageTk.PhotoImage(im)186 if self.idImagen:187 self.canvas.delete(self.idImagen)188 self.idImagen = self.canvas.create_image(0,0,image=self.myimg,anchor=CENTER)189 ##cuidado cuando seteamos esto. Si lo ponemodes despues de cargar una imagen,190 ##es como que el box se fija al tamañio de la imagen191 self.canvas.config(scrollregion=self.canvas.bbox(ALL))192 self.canvas.yview_moveto(0.0)193if __name__=='__main__':194 root = Tk()195 path='E:\\Comics\\All Elseworlds\\Batman Elseworlds\\Batman_ Scar of the Bat V1996 #1 (1996).cbz'196 session = Entidades.Init.Session()197 comicBook = session.query(ComicBook).filter(ComicBook.path==path).first()198 visor = ComicVisorGui(root,comicBook,session=session)199 visor.title = ('Babel Comics Visor')...
toolbox.py
Source:toolbox.py
1ICON_SIZE = (16,16)2TOOLBOX_TITLEHEIGHT = 5+FONT_SIZE[1]3TOOLBOX_LINE = (17+TOOLBOX_RADAR[0],6+TOOLBOX_TITLEHEIGHT)4TOOLBOX_LINES = int((TOOLBOX_RADAR[1]-2) / TOOLBOX_LINEHEIGHT)5TOOLBOX_LINEHEIGHT = max(ICON_SIZE[0],FONT_SIZE[1])6TOOLBOX_LINEWIDTH = FONT.size('W' * 15)[0]7TOOLBOX_AMMOWIDTH = FONT.size('999')[0]8TOOLBOX_LINESDIM = (ICON_SIZE[0]+TOOLBOX_LINEWIDTH[0]+TOOLBOX_AMMOWIDTH[0],TOOLBOX_LINEHEIGHT*TOOLBOX_LINES)9TOOLBOX_RADAR = (100,100)10TOOLBOX_DIALLENGTH = 2011TOOLBOX_DIAL = (8+TOOLBOX_DIALLENGTH,12+TOOLBOX_TITLEHEIGHT+TOOLBOX_RADAR[1]+TOOLBOX_DIALLENGTH)12TOOLBOX_DIALWIDTH = FONT.size('90')[0] + 613TOOLBOX_POWERDIM = (40,10)14TOOLBOX_POWER = (20+TOOLBOX_DIAL[0]+TOOLBOX_DIALLENGTH+TOOLBOX_DIALWIDTH,12+TOOLBOX_TITLEHEIGHT+TOOLBOX_RADAR[1]+(TOOLBOX_DIALLENGTH/2)-(TOOLBOX_POWERDIM[1]/2))15TOOLBOX_POWERBAR = (12,TOOLBOX_TITLEHEIGHT+TOOLBOX_LINESIZE*3+1)16TOOLBOX_POWERWIDTH = FONT.size('1000/1000')[0]17TOOLBOX_SCROLBUTTON = (10,10)18TOOLBOX_SCROLLUP = (3+TOOLBOX_LINE[0]+ICON_SIZE[0]+TOOLBOX_LINEWIDTH[0]+TOOLBOX_AMMOWIDTH[0],TOOLBOX_LINE[1]+1)19TOOLBOX_SCROLLDOWN = (TOOLBOX_SCROLLUP[0],TOOLBOX_SCROLLUP[1]+TOOLBOX_LINEHEIGHT*TOOLBOX_LINES-TOOLBOX_SCROLLDIM[1])20TOOLBOX_SCROLL = (TOOLBOX_SCROLLUP[0],TOOLBOX_SCROLLUP[1]+TOOLBOX_SCROLLDIM[1])21TOOLBOX_SCROLLDIM = (TOOLBOX_SCROLLDOWN[0],TOOLBOX_SCROLLDOWN[1]-TOOLBOX_SCROLL[1]-1)22TOOLBOX_SIZE = (9+TOOLBOX_SCROLLUP[0]+TOOLBOX_SCROLLDIM[0],8+TOOLBOX_DIAL[1])23class Toolbox(Object,pygame.Rect):24 def __init__(self, screen, player):25 self.player = player26 self.topweapon = 027 Object.__init__(self, screen, 0, player.toolboxposition, -1, 0, 0)28 self.listbox = pygame.Rect(gwglob.TOOLBOX_LINE,gwglob.TOOLBOX_LINESDIM)29 self.up = pygame.Rect(gwglob.TOOLBOX_SCROLLUP,gwglob.TOOLBOX_SCROLLBUTTON)30 self.down = pygame.Rect(gwglob.TOOLBOX_SCROLLDOWN,gwglob.TOOLBOX_SCROLLBUTTON)31 self.scroll = pygame.Rect(gwglob.TOOLBOX_SCROLL,gwglob.TOOLBOX_SCROLLDIM)32 self.update_static()33 pygame.Rect.__init__(self, list(self.position), gwglob.TOOLBOX_SIZE)34 def click(self, point):35 if self.collidepoint(point):36 if self.listbox.collidepoint(point):37 self.player.weapon = self.topweapon + (point[1]-self.listbox.topleft[1])/gwglob.TOOLBOX_LINEHEIGHT38 return39 if self.up.collidepoint(point):40 self.topweapon = max(0,self.topweapon-1)41 return42 if self.down.collidepoint(point):43 self.topweapon = min(len(self.player.weapons)-3,self.topweapon+1)44 return45 if self.scroll.collidepoint(point):46 self.topweapon = min(len(self.player.weapons)-3,int(len(self.player.weapons) * ((point[1] - self.scroll.topleft[1]) / float(self.scroll.height))))47 return48 return True49 def move(self, position):50 self.position = position51 self.player.toolboxposition = list(position)52 self.topleft = list(position)53 self.listbox.topleft = (self.position[0]+gwglob.TOOLBOX_LINE[0],self.position[1]+gwglob.TOOLBOX_LINE[1])54 self.up.topleft = (self.position[0]+gwglob.TOOLBOX_SCROLLUP[0],self.position[1]+ggwglob.TOOLBOX_SCROLLUP[1])55 self.down.topleft = (self.position[0]+gwglob.TOOLBOX_SCROLLDOWN[0],self.position[1]+gwglob.TOOLBOX_SCROLLDOWN[1])56 self.scroll.topleft = (self.position[0]+gwglob.TOOLBOX_SCROLL[0],self.position[1]+gwglob.TOOLBOX_SCROLL[1])57 def update_static(self, player=None):58 self.player.topweapon = self.topweapon59 if player:60 self.player = player61 if self.player.toolbox:62 self.static = self.player.toolbox63 self.topweapon = self.player.topweapon64 self.move(list(self.player.toolboxposition))65 else:66 self.topweapon = 067 self.static = pygame.Surface(gwglob.TOOLBOX_SIZE)68 self.static.lock()69 self.static.fill(self.player.color)70 pygame.draw.circle(self.static, (0,0,0), gwglob.TOOLBOX_DIAL, 20, 0)71 pygame.draw.rect(self.static, self.player.color, ((gwglob.TOOLBOX_DIAL[0]-gwglob.TOOLBOX_DIALLENGTH,gwglob.TOOLBOX_DIAL[1]),(gwglob.TOOLBOX_DIALLENGTH*2,gwglob.TOOLBOX_DIALLENGTH)), 0)72 pygame.draw.rect(self.static, (0,0,0), ((1,1),(gwglob.TOOLBOX_SIZE[0]-2,gwglob.TOOLBOX_SIZE[1]-2)), 1)73 pygame.draw.line(self.static, (0,0,0), (1,gwglob.TOOLBOX_TITLEHEIGHT), (gwglob.TOOLBOX_SIZE[0]-2,gwglob.TOOLBOX_TITLEHEIGHT), 1)74 pygame.draw.rect(self.static, (0,0,0), ((gwglob.TOOLBOX_POWERBAR[0]-1,gwglob.TOOLBOX_POWERBAR[1]-1),(gwglob.TOOLBOX_POWERDIM[0]+2,gwglob.TOOLBOX_POWERDIM[1]+2)), 0)75 pygame.draw.rect(self.static, (0,0,0), ((gwglob.TOOLBOX_LINE[0]-1,gwglob.TOOLBOX_LINE[1]-1),(gwglob.TOOLBOX_LINESDIM[0]+gwglob.TOOLBOX_SCROLLBUTTON[0]+2,gwglob.TOOLBOX_LINESDIM[0]+2)), 1)76 # pygame.draw.rect(self.static, (0,0,0), ((gwglob.TOOLBOX_SIZE[0]-24,gwglob.TOOLBOX_TITLEHEIGHT+11),(12,gwglob.TOOLBOX_LINESIZE*3+2)), 1)77 # pygame.draw.rect(self.static, (0,0,0), ((gwglob.TOOLBOX_SIZE[0]-24,gwglob.TOOLBOX_TITLEHEIGHT+22),(12,gwglob.TOOLBOX_LINESIZE*3-20)), 0)78 self.static.unlock()79 self.static.blit(gwglob.FONT.render(self.player.name, gwglob.ANTI_ALIAS, (0,0,0), self.player.color), (3,3))80 self.player.toolbox = self.static81 self.move([gwglob.SIZE[0]-50-gwglob.TOOLBOX_SIZE[0],50])82 def draw(self):83 self.screen.screen.blit(self.static, self.position)84 # v = Vector(magnitude=20, angle=self.player.aiming-pi/2.0)85 # dial = (gwglob.TOOLBOX_DIAL[0]+self.position[0],gwglob.TOOLBOX_DIAL[1]+self.position[1])86 # pygame.draw.line(self.screen.screen, (255,255,255), dial, v.project(dial))87 # size = gwglob.FONT.size('%d' % degrees(self.player.aiming))88 # degree = (dial[0]+25,dial[1]-10-gwglob.FONT_SIZE[1]/2)89 # self.screen.screen.blit(gwglob.FONT.render('%d' % degrees(self.player.aiming), gwglob.ANTI_ALIAS, (0,0,0), self.player.color), degree)90 # pygame.draw.circle(self.screen.screen, (0,0,0), (degree[0]+size[0]+3,degree[1]+3), 2, 1)91 # powerbar = (gwglob.TOOLBOX_POWERBAR[0]+1+self.position[0],gwglob.TOOLBOX_POWERBAR[1]+1+self.position[1])92 # power,maxpower = int(38 * (self.player.power / gwglob.PLAYER_MAXPOWER)),int(38 * (self.player.maxpower / gwglob.PLAYER_MAXPOWER))93 # if power < maxpower:94 # pygame.draw.rect(self.screen.screen, self.player.color, (powerbar, (maxpower,8)), 1)95 # pygame.draw.rect(self.screen.screen, self.player.color, (powerbar, (power,8)), 0)96 # self.screen.screen.blit(gwglob.FONT.render('%d/%d' % (self.player.power,self.player.maxpower), gwglob.ANTI_ALIAS, (0,0,0), self.player.color), (powerbar[0]+45,powerbar[1]+4-gwglob.FONT_SIZE[1]/2))97 # if len(self.player.weapons) > 3:98 # n = gwglob.TOOLBOX_SCROLLHEIGHT / float(len(self.player.weapons))99 # pygame.draw.rect(self.screen.screen, self.player.color, ((self.position[0]+gwglob.TOOLBOX_SIZE[0]-23,self.position[1]+gwglob.TOOLBOX_TITLEHEIGHT+23+n*self.topweapon),(10,n*3)), 0)100 # for n,d in enumerate(zip(self.player.weapons[self.topweapon:self.topweapon+3],self.player.ammo[self.topweapon:self.topweapon+3])):101 # w,a = d102 # h = gwglob.FONT.size(str(a))[0]103 # p = (gwglob.TOOLBOX_WEAPONS[0]+self.position[0]+1,gwglob.TOOLBOX_WEAPONS[1]+self.position[1]+1+gwglob.TOOLBOX_LINESIZE*n)104 # self.screen.screen.blit(weapons[w][0].icon, p)105 # self.screen.screen.blit(weapons[w][2], (p[0]+17,p[1]), ((0,0),(gwglob.TOOLBOX_WEAPONS_WIDTH-3-h,p[1])))106 # self.screen.screen.blit(gwglob.FONT.render(str(a), gwglob.ANTI_ALIAS, (0,0,0)), (p[0]+gwglob.TOOLBOX_WEAPONS_WIDTH-3-h,p[1]))107 # if self.topweapon + n == self.player.weapon:...
smooth-scroll-up.js
Source:smooth-scroll-up.js
1jQuery(document).ready(2 function($){3 jQuery('#scrollup_upload_image_preview').attr('src', jQuery('#scrollup_upload_image').val());4 if(jQuery('#scrollup_type').val()=="image") {5 jQuery('#scrollup_custom_image_section').parent().parent().show();6 jQuery('#scrollup_custom_text_section').parent().parent().hide();7 jQuery('.scrollup_custom_icon_section').parent().parent().hide();8 }9 else if(jQuery('#scrollup_type').val()=="icon") {10 jQuery('#scrollup_custom_image_section').parent().parent().hide();11 jQuery('#scrollup_custom_text_section').parent().parent().hide();12 jQuery('.scrollup_custom_icon_section').parent().parent().show();13 }14 else{15 jQuery('#scrollup_custom_image_section').parent().parent().hide();16 jQuery('#scrollup_custom_text_section').parent().parent().show();17 jQuery('.scrollup_custom_icon_section').parent().parent().hide();18 }19 $('#scrollup_custom_icon_button').click(function() {20 $('#scrollup_custom_icon_dialog').dialog({21 title: 'Select Icon',22 modal: true,23 width: 800,24 height: 40025 });26 return false;27 });28 $('.scrollup-custom-icon-list-icon').click(function() {29 jQuery('#scrollup_custom_icon').attr('value', $(this).attr('name'));30 jQuery('#scrollup_custom_icon_preview').attr('class', 'fa ' + jQuery( "#scrollup_custom_icon" ).val() +' ' + jQuery( "#scrollup_custom_icon_size option:selected" ).val());31 $('#scrollup_custom_icon_dialog').dialog('close')32 return false;33 });34 jQuery('#scrollup_type').change(35 function(){36 var i= jQuery('#scrollup_type').val();37 if(i=="image") {38 jQuery('#scrollup_custom_image_section').parent().parent().fadeIn(100);39 jQuery('#scrollup_custom_text_section').parent().parent().fadeOut(100);40 jQuery('.scrollup_custom_icon_section').parent().parent().fadeOut(100);41 }42 else if(i=="icon") {43 jQuery('#scrollup_custom_image_section').parent().parent().fadeOut(100);44 jQuery('#scrollup_custom_text_section').parent().parent().fadeOut(100);45 jQuery('.scrollup_custom_icon_section').parent().parent().fadeIn(100);46 }47 else48 {49 jQuery('#scrollup_custom_image_section').parent().parent().fadeOut(100);50 jQuery('#scrollup_custom_text_section').parent().parent().fadeIn(100);51 jQuery('.scrollup_custom_icon_section').parent().parent().fadeOut(100);52 }53 }54 );55 jQuery('#scrollup_custom_icon_size').change(56 function(){57 jQuery('#scrollup_custom_icon_preview').attr('class', 'fa ' + jQuery( "#scrollup_custom_icon" ).val() +' ' + jQuery( "#scrollup_custom_icon_size option:selected" ).val());58 }59 );60 61 jQuery('.scrollup_upload_image_button').click(62 function(e) {63 e.preventDefault();64 var image = wp.media(65 { 66 title: 'Upload Image',67 // mutiple: true if you want to upload multiple files at once68 multiple: false69 }70 ).open()71 .on(72 'select', function(e){73 // This will return the selected image from the Media Uploader, the result is an object74 var uploaded_image = image.state().get('selection').first();75 // We convert uploaded_image to a JSON object to make accessing it easier76 var image_url = uploaded_image.toJSON().url;77 // Let's assign the url value to the input field78 jQuery('#scrollup_upload_image').val(image_url);79 jQuery('#scrollup_upload_image_preview').attr('src', image_url);80 }81 );82 }83 );84 }...
gwglob.py
Source:gwglob.py
1import pygame,os2BASE_DIR = os.path.abspath(os.path.dirname(__file__))3try:4 SETTINGS = eval(file(os.path.join(BASE_DIR,'settings.txt'), 'r').read().strip().replace('\n',''))5except IOError, e:6 if e.args[0] == 2:7 SETTINGS = {}8 else:9 raise10VERSION = (0,-1,-5)11LONG_VERSION = 'v%s.%s.%s' % VERSION12SIZE = (800,600)13MOVE_SIZE = 5014SCREEN_RECT = pygame.Rect((0,0),SIZE)15FULLSCREEN = True16FONT = pygame.font.Font(None,16)17MID_FONT = pygame.font.Font(None,24)18BIG_FONT = pygame.font.Font(None,32)19FONT_SIZE = FONT.size(''.join([chr(x) for x in range(256)]))20MID_FONT_SIZE = MID_FONT.size(''.join([chr(x) for x in range(256)]))21BIG_FONT_SIZE = BIG_FONT.size(''.join([chr(x) for x in range(256)]))22ANTI_ALIAS = True23CACHE_IMAGES = True24REPEAT_DELAY = 10025REPEAT_INTERVAL = 1026FPS_MAX = 3027CLOCK = pygame.time.Clock()28GRAV_CONST = 3.347529MASS_MAX = 75030MASS_HABITABLE = 60031EXPLOSION_RANGE = (0.16666666666666666,0)32PARTICLES = 10033PARTICLE_AMOUNTS = {34 'debry':10,35 'star fields':2,36 'stars per field':100,37}38def particles(type):39 return int(PARTICLE_AMOUNTS[type] * (PARTICLES / 100.0))40DEBRY_LIFE = 15.041STAR_COLORS = [42 (255,255,255),43 (255,255,0),44 (255,200,200),45 (200,255,255),46 (150,150,150)47]48PLAYER_MAX = 849PLAYER_MAXNAME = 1550PLAYER_MAXPOWER = 1000.051PLAYER_COLORS = [52 (255,0,0),53 (0,0,255),54 (0,255,0),55 (255,255,0),56 (0,255,255),57 (255,255,255),58 (255,0,255),59 (128,0,255),60 (192,192,192),61 (128,64,0),62]63PLAYER = [(0,-7),(5,-7),(8,-4),(8,4),(5,7),(0,7)]64PLAYER_TURRET_BASE = (8,0)65SHOT_VELOCITY = 1566SHOT_OUTSIDE_LIFE = 25067# TOOLBOX_TITLEHEIGHT = 5+FONT_SIZE[1]68# TOOLBOX_LINESIZE = max(16,FONT_SIZE[1])69# TOOLBOX_SIZE = [200+FONT.size('1000/1000')[0],24+TOOLBOX_TITLEHEIGHT+TOOLBOX_LINESIZE*3]70# TOOLBOX_WEAPONS = (TOOLBOX_SIZE[0]-138,TOOLBOX_TITLEHEIGHT+11)71# TOOLBOX_WEAPONS_WIDTH = 11572# TOOLBOX_DIAL = (32,TOOLBOX_TITLEHEIGHT+31)73# TOOLBOX_POWERBAR = (12,TOOLBOX_TITLEHEIGHT+TOOLBOX_LINESIZE*3+1)74# TOOLBOX_SCROLLHEIGHT = TOOLBOX_LINESIZE*3-2275# ICON_SIZE = (16,16)76ICON_SIZE = (16,16)77TOOLBOX_TITLEHEIGHT = 5+FONT_SIZE[1]78TOOLBOX_RADAR = (8,TOOLBOX_TITLEHEIGHT+6)79TOOLBOX_RADARDIM = (100,100)80TOOLBOX_LINE = (17+TOOLBOX_RADARDIM[0],7+TOOLBOX_TITLEHEIGHT)81TOOLBOX_LINEHEIGHT = max(ICON_SIZE[1],FONT_SIZE[1])82TOOLBOX_LINES = int((TOOLBOX_RADARDIM[1]-2) / TOOLBOX_LINEHEIGHT)83TOOLBOX_LINEWIDTH = FONT.size('W' * 15)[0]84TOOLBOX_AMMOWIDTH = FONT.size('999')[0]85TOOLBOX_LINESDIM = (ICON_SIZE[0]+TOOLBOX_LINEWIDTH+TOOLBOX_AMMOWIDTH,TOOLBOX_LINEHEIGHT*TOOLBOX_LINES)86TOOLBOX_DIALLENGTH = 2087TOOLBOX_DIAL = (8+TOOLBOX_DIALLENGTH,12+TOOLBOX_TITLEHEIGHT+TOOLBOX_RADARDIM[1]+TOOLBOX_DIALLENGTH)88TOOLBOX_DIALTEXT = (5+TOOLBOX_DIAL[0]+TOOLBOX_DIALLENGTH,TOOLBOX_DIAL[1]-TOOLBOX_DIALLENGTH/2-FONT_SIZE[1]/2)89TOOLBOX_DIALWIDTH = FONT.size('90')[0] + 690TOOLBOX_POWERDIM = (40,10)91TOOLBOX_POWER = (20+TOOLBOX_DIAL[0]+TOOLBOX_DIALLENGTH+TOOLBOX_DIALWIDTH,12+TOOLBOX_TITLEHEIGHT+TOOLBOX_RADARDIM[1]+(TOOLBOX_DIALLENGTH/2)-(TOOLBOX_POWERDIM[1]/2))92TOOLBOX_POWERTEXT = (TOOLBOX_POWER[0]+TOOLBOX_POWERDIM[0]+5,12+TOOLBOX_TITLEHEIGHT+TOOLBOX_RADARDIM[1]+(TOOLBOX_DIALLENGTH/2)-(FONT_SIZE[1]/2))93TOOLBOX_POWERWIDTH = FONT.size('1000/1000')[0]94TOOLBOX_SCROLLBUTTON = (10,10)95TOOLBOX_SCROLLUP = (1+TOOLBOX_LINE[0]+TOOLBOX_LINESDIM[0],TOOLBOX_LINE[1])96TOOLBOX_SCROLLDOWN = (TOOLBOX_SCROLLUP[0],TOOLBOX_SCROLLUP[1]+TOOLBOX_LINEHEIGHT*TOOLBOX_LINES-TOOLBOX_SCROLLBUTTON[1])97TOOLBOX_SCROLLBAR = (TOOLBOX_SCROLLUP[0],TOOLBOX_SCROLLUP[1]+TOOLBOX_SCROLLBUTTON[1]+1)98TOOLBOX_SCROLL = (TOOLBOX_SCROLLUP[0],TOOLBOX_SCROLLUP[1]+TOOLBOX_SCROLLBUTTON[1])99TOOLBOX_SCROLLDIM = (TOOLBOX_SCROLLBUTTON[0],TOOLBOX_SCROLLDOWN[1]-TOOLBOX_SCROLLUP[1]-TOOLBOX_SCROLLBUTTON[1]-2)100TOOLBOX_SIZE = (9+TOOLBOX_SCROLLUP[0]+TOOLBOX_SCROLLBUTTON[0],8+TOOLBOX_DIAL[1])101TOOLBOX_MINIMIZEDIM = (10,10)102TOOLBOX_MINIMIZE = (TOOLBOX_SIZE[0]-8-TOOLBOX_MINIMIZEDIM[0],(TOOLBOX_TITLEHEIGHT+1)/2-TOOLBOX_MINIMIZEDIM[1]/2)...
plugins.js
Source:plugins.js
1// Avoid `console` errors in browsers that lack a console.2(function() {3 var method;4 var noop = function () {};5 var methods = [6 'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',7 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',8 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',9 'timeline', 'timelineEnd', 'timeStamp', 'trace', 'warn'10 ];11 var length = methods.length;12 var console = (window.console = window.console || {});13 while (length--) {14 method = methods[length];15 // Only stub undefined methods.16 if (!console[method]) {17 console[method] = noop;18 }19 }20}());21// Place any jQuery/helper plugins in here.22/*!23 * scrollup v2.4.124 * Url: http://markgoodyear.com/labs/scrollup/25 * Copyright (c) Mark Goodyear â @markgdyr â http://markgoodyear.com26 * License: MIT27 */...
scroll-top.js
Source:scroll-top.js
1/*=============================================2= Scrollup =3=============================================*/4/*!5 * scrollup v2.4.16 *7 * Url: http://markgoodyear.com/labs/scrollup/8 * Copyright (c) Mark Goodyear ââ¬â @markgdyr ââ¬â http://markgoodyear.com9 * License: MIT10 */11!(function(l, o, e) {12 'use strict';13 (l.fn.scrollUp = function(o) {14 l.data(e.body, 'scrollUp') || (l.data(e.body, 'scrollUp', !0), l.fn.scrollUp.init(o));15 }),16 (l.fn.scrollUp.init = function(r) {17 var s,18 t,19 c,20 i,21 n,22 a,23 d,24 p = (l.fn.scrollUp.settings = l.extend({}, l.fn.scrollUp.defaults, r)),25 f = !1;26 switch (((d = p.scrollTrigger ? l(p.scrollTrigger) : l('<a/>', { id: p.scrollName, href: '#top' })),27 p.scrollTitle && d.attr('title', p.scrollTitle),28 d.appendTo('body'),29 p.scrollImg || p.scrollTrigger || d.html(p.scrollText),30 d.css({ display: 'none', position: 'fixed', zIndex: p.zIndex }),31 p.activeOverlay &&32 l('<div/>', { id: p.scrollName + '-active' })33 .css({34 position: 'absolute',35 top: p.scrollDistance + 'px',36 width: '100%',37 borderTop: '1px dotted' + p.activeOverlay,38 zIndex: p.zIndex39 })40 .appendTo('body'),41 p.animation)) {42 case 'fade':43 (s = 'fadeIn'), (t = 'fadeOut'), (c = p.animationSpeed);44 break;45 case 'slide':46 (s = 'slideDown'), (t = 'slideUp'), (c = p.animationSpeed);47 break;48 default:49 (s = 'show'), (t = 'hide'), (c = 0);50 }51 (i = 'top' === p.scrollFrom ? p.scrollDistance : l(e).height() - l(o).height() - p.scrollDistance),52 (n = l(o).scroll(function() {53 l(o).scrollTop() > i ? f || (d[s](c), (f = !0)) : f && (d[t](c), (f = !1));54 })),55 p.scrollTarget56 ? 'number' == typeof p.scrollTarget57 ? (a = p.scrollTarget)58 : 'string' == typeof p.scrollTarget && (a = Math.floor(l(p.scrollTarget).offset().top))59 : (a = 0),60 d.click(function(o) {61 o.preventDefault(), l('html, body').animate({ scrollTop: a }, p.scrollSpeed, p.easingType);62 });63 }),64 (l.fn.scrollUp.defaults = {65 scrollName: 'scrollUp',66 scrollDistance: 300,67 scrollFrom: 'top',68 scrollSpeed: 300,69 easingType: 'linear',70 animation: 'fade',71 animationSpeed: 200,72 scrollTrigger: !1,73 scrollTarget: !1,74 scrollText: 'Scroll to top',75 scrollTitle: !1,76 scrollImg: !1,77 activeOverlay: !1,78 zIndex: 214748364779 }),80 (l.fn.scrollUp.destroy = function(r) {81 l.removeData(e.body, 'scrollUp'),82 l('#' + l.fn.scrollUp.settings.scrollName).remove(),83 l('#' + l.fn.scrollUp.settings.scrollName + '-active').remove(),84 l.fn.jquery.split('.')[1] >= 7 ? l(o).off('scroll', r) : l(o).unbind('scroll', r);85 }),86 (l.scrollUp = l.fn.scrollUp);...
Using AI Code Generation
1const { scrollUp } = require('taiko');2(async () => {3 await scrollUp();4})();5const { scrollDown } = require('taiko');6(async () => {7 await scrollDown();8})();9const { scrollRight } = require('taiko');10(async () => {11 await scrollRight();12})();13const { scrollLeft } = require('taiko');14(async () => {15 await scrollLeft();16})();17const { scrollTo } = require('taiko');18(async () => {19 await scrollTo('text');20})();21const { scrollLeft } = require('taiko');22(async () => {23 await scrollLeft();24})();25const { scrollTo } = require('taiko');26(async () => {27 await scrollTo('text');28})();29const { scrollLeft } = require('taiko');30(async () => {31 await scrollLeft();32})();33const { scrollTo } = require('taiko');34(async () => {35 await scrollTo('text');36})();37const { scrollLeft } = require('taiko');38(async () => {39 await scrollLeft();40})();41const { scrollTo } = require('taiko');42(async () => {43 await scrollTo('text');44})();45const { scrollLeft } = require('taiko');46(async () => {47 await scrollLeft();48})();49const { scrollTo } = require('taiko');50(async () => {51 await scrollTo('text');52})();53const { scrollLeft } = require('ta
Using AI Code Generation
1const { scrollUp } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await goto("google.com");6 await scrollUp();7 await closeBrowser();8 } catch (e) {9 console.error(e);10 } finally {11 }12})();13const { scrollDown } = require('taiko');14(async () => {15 try {16 await openBrowser();17 await goto("google.com");18 await scrollDown();19 await closeBrowser();20 } catch (e) {21 console.error(e);22 } finally {23 }24})();25const { scrollRight } = require('taiko');26(async () => {27 try {28 await openBrowser();29 await goto("google.com");30 await scrollRight();31 await closeBrowser();32 } catch (e) {33 console.error(e);34 } finally {35 }36})();37const { scrollLeft } = require('taiko');38(async () => {39 try {40 await openBrowser();41 await goto("google.com");42 await scrollLeft();43 await closeBrowser();44 } catch (e) {45 console.error(e);46 } finally {47 }48})();49const { scrollRight } = require('taiko');50(async () => {51 try {52 await openBrowser();53 await goto("google.com");54 await scrollRight();55 await closeBrowser();56 } catch (e) {57 console.error(e);58 } finally {59 }60})();61const { scrollTo } = require('taiko');62(async () => {63 try {64 await openBrowser();65 await goto("google.com");66 await scrollTo("Google Search");67 await closeBrowser();
Using AI Code Generation
1const { openBrowser, goto, click, scrollUp } = require('taiko');2(async () => {3 try {4 await openBrowser({headless:false});5 await scrollUp(100);6 } catch (e) {7 console.error(e);8 } finally {9 await closeBrowser();10 }11})();12const { openBrowser, goto, click, scrollDown } = require('taiko');13(async () => {14 try {15 await openBrowser({headless:false});16 await scrollDown(100);17 } catch (e) {18 console.error(e);19 } finally {20 await closeBrowser();21 }22})();23const { openBrowser, goto, click, scrollLeft } = require('taiko');24(async () => {25 try {26 await openBrowser({headless:false});27 await scrollLeft(100);28 } catch (e) {29 console.error(e);30 } finally {31 await closeBrowser();32 }33})();34const { openBrowser, goto, click, scrollRight } = require('taiko');35(async () => {36 try {37 await openBrowser({headless:false});38 await scrollRight(100);39 } catch (e) {40 console.error(e);41 } finally {42 await closeBrowser();43 }44})();45const { openBrowser, goto, click, scrollTo } = require('taiko');46(async () => {47 try {48 await openBrowser({headless:false});49 await scrollTo(100,100);50 } catch (e) {51 console.error(e);52 } finally {53 await closeBrowser();54 }55})();56const { openBrowser, goto, click, scrollRight } = require('taiko');57(async () => {58 try {59 await openBrowser({headless:false});60 await goto("https
Using AI Code Generation
1const { scrollUp } = require('taiko');2scrollUp();3const { scrollDown } = require('taiko');4scrollDown();5const { scrollRight } = require('taiko');6scrollRight();7const { scrollLeft } = require('taiko');8scrollLeft();9const { scrollHorizontallyTo } = require('taiko');10scrollHorizontallyTo(100);11const { scrollVerticallyTo } = require('taiko');12scrollVerticallyTo(100);13const { scrollTo } = require('taiko');14scrollTo(100, 100);15const { scrollRight } = require('taiko');16scrollRight();17const { scrollLeft } = require('taiko');18scrollLeft();19const { scrollHorizontallyTo } = require('taiko');20scrollHorizontallyTo(100);
Using AI Code Generation
1scrollUp();2scrollDown();3scrollRight();4scrollLeft();5scrollTo("google");6click("google");7doubleClick("google");8rightClick("google");9focus("google");10hover("google");11dragAndDrop("google", "drop");12write("google");13clear("google");
Using AI Code Generation
1scrollUp();2scrollDown(200);3scrollTo("element");4scrollRight(200);5scrollLeft(200);6mouseAction("click", "element");7focus("element");8hover("element");9dragAndDrop("element1", "element2");10tap("element");11doubleClick("element");12write("text", into("element"));13clear("element");
Using AI Code Generation
1const { scrollUp } = require('taiko');2const { scrollDown } = require('taiko');3const { scrollTo } = require('taiko');4const { scrollRight } = require('taiko');5const { scrollLeft } = require('taiko');6const { scrollElementRight } = require('taiko');7const { scrollElementLeft } = require('taiko');8const { scrollElementUp } = require('taiko');9scrollElementUp('text', { speed
Using AI Code Generation
1await scrollUp(3);2await scrollUp(3, {speed: 100});3await scrollUp({speed: 100});4await scrollUp(3, {speed: 100, selector: '#mydiv'});5await scrollUp({speed: 100, selector: '#mydiv'});6await scrollUp(3, {selector: '#mydiv'});7await scrollUp({selector: '#mydiv'});8await scrollDown(3);9await scrollDown(3, {speed: 100});10await scrollDown({speed: 100});11await scrollDown(3, {speed: 100, selector: '#mydiv'});12await scrollDown({speed: 100, selector: '#mydiv'});13await scrollDown(3, {selector: '#mydiv'});14await scrollDown({selector: '#mydiv'});15await scrollLeft(3);16await scrollLeft(3, {speed: 100});17await scrollLeft({speed: 100});18await scrollLeft(3, {speed: 100, selector: '#mydiv'});19await scrollLeft({speed: 100, selector: '#mydiv'});20await scrollLeft(3, {selector: '#mydiv'});21await scrollLeft({selector: '#mydiv'});22await scrollRight(3);23await scrollRight(3, {speed: 100});24await scrollRight({speed:
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!