The New Style Codes Are Written!
2 posters
Page 1 of 1
Re: The New Style Codes Are Written!
HOOWSSS it going bros.. its me again with something cool, again..
so now, I have installed Panda Syntax Highlighting on this forum!!
Q : Dafuq is that?
A : As you can see, the code tags, those have the lame text, and doesn't really look much like, CODES, you see? It helps with changing its style
Q : Uhm okay, how to use it?
A : Pretty easy, for it when you used the "code" tags, just put [ panda = stylenamehere ] (no spaces please) inside the code tags and then write the code, no need to be close the tag with [ / panda ], there's no need for it.
Q : Nice! Which all languages are supported?!
A : For now, there are CSS and Python scripting style available, more will be added upon user's need
codes:
css - css
python - py
Example :
The code I used :
How it looks
You can try for Python too (added it for you A-MAN), but since I know nothing, I can't write anything as an example
so now, I have installed Panda Syntax Highlighting on this forum!!
Q : Dafuq is that?
A : As you can see, the code tags, those have the lame text, and doesn't really look much like, CODES, you see? It helps with changing its style
Q : Uhm okay, how to use it?
A : Pretty easy, for it when you used the "code" tags, just put [ panda = stylenamehere ] (no spaces please) inside the code tags and then write the code, no need to be close the tag with [ / panda ], there's no need for it.
Q : Nice! Which all languages are supported?!
A : For now, there are CSS and Python scripting style available, more will be added upon user's need
codes:
css - css
python - py
Example :
The code I used :
- Code:
[ code ] [ panda = css ] stuff here [ / code ]
(obviously no spaces)
How it looks
- Code:
[panda=css] .rhino{
awesomeness: 100;
lameness: 0;
}
You can try for Python too (added it for you A-MAN), but since I know nothing, I can't write anything as an example
Last edited by Rhino.Freak on 19th February 2014, 7:17 am; edited 1 time in total
Re: The New Style Codes Are Written!
Reaaaaaaaaaaaaally cool stuff you did man!!! You're just.... AWESOME! Thanks for Python's tags specially. Would love it if we can add an A-Script tag in the future.
Example:
How about supporting the C family languages syntax? That would be cool! Keep it up XD!
Example:
- Code:
[panda=py]
import pygame
import numpy
import os
import threading
import sys
import time
from ctypes import *
from pygame.locals import *
inputpath="input"
outputpath="output"
def MessageBox(hwid,lpText,lpCaption,uType):
user32 = windll.LoadLibrary('user32')
user32.MessageBoxA(hwid,lpText,lpCaption,uType)
return None
nameah=0
dateah=0
try:
filenames=os.listdir(os.path.join(os.getcwd(), inputpath))
except WindowsError, e:
MessageBox(0,str(e),'Runtime error!',0x00L|0x0010L)
sys.exit()
ifilenames=os.listdir(os.path.join(os.getcwd(), inputpath))
try:
ofilenames=os.listdir(os.path.join(os.getcwd(), outputpath))
except WindowsError, e:
MessageBox(0,str(e),'Runtime error!',0x00L|0x0010L)
sys.exit()
imgsnames=[]
datnames =[]
for a in filenames:
if a.endswith(".dat"):
datnames.append(a)
elif a.endswith(".bmp"):
imgsnames.append(a)
Done=False
def MessageBox(hwid,lpText,lpCaption,uType):
user32 = windll.LoadLibrary('user32')
user32.MessageBoxA(hwid,lpText,lpCaption,uType)
return None
def decrypt_lf2(edata):
key="odBearBecauseHeIsVeryGoodSiuHungIsAGo"
pos=0
ddata=''
for a in range(123, len(edata)-1):
try:
ddata+=chr(ord(edata[a])-ord(key[pos]))
except ValueError:
pass
pos+=1
if pos==len(key):
pos=0
return ddata
def encrypt_lf2(ddata):
key="odBearBecauseHeIsVeryGoodSiuHungIsAGo"
pos=0
edata=''
for a in range(0, len(ddata)-1):
edata+=chr(ord(ddata[a])+ord(key[pos]))
pos+=1
if pos==len(key):
pos=0
return (" "*123)+edata
def getarg(frame, tag, exceptions):
if exceptions==None:
exceptionscase=False
tagpos=frame.find(tag)+len(tag)
temp=""
for a in range(tagpos, len(frame)):
if exceptions!=None:
exceptionscase=frame[a] in exceptions
if frame[a].isdigit() or exceptionscase:
while True:
if (not frame[a].isdigit() and exceptions==None) or (exceptions!=None and (not frame[a] in exceptions) and (not frame[a].isdigit())):
return temp
temp+=frame[a]
a+=1
if a==len(frame):
return temp
if not frame[a].isspace():
return 0
def savegrid(pixels, outputpath):
try:
surf = pygame.surfarray.make_surface(pixels)
except IndexError:
(width, height, colours) = pixels.shape
surf = pygame.display.set_mode((width, height))
pygame.surfarray.blit_array(surf, pixels)
pygame.image.save(surf, os.path.join(os.getcwd(), outputpath))
def combinesfas(source, dest, pos):
destination=dest
for x in range(len(source)):
for y in range(len(source[x])):
destination[pos[0]+x, pos[1]+y]=source[x, y]
return destination
pygame.init()
A_Surf = pygame.display.set_mode((500, 100))
pygame.display.set_caption("The A-Grid Clipper")
filenoh=0
currentdatname=''
datimgsdata=[]
nofiles=False
currentbmpname=''
def main():
global A_Surf, filenames, inputpath, outputpath, Running, Done, dateah,currentbmpname, nameah, datimgsdata, currentdatname,datnames,nofiles
try:
for filno in range(len(datnames)):
dateah=filno
datimgsdata=[]
if len(datnames) == 0:
nofiles=True
else:
currentdatname= datnames[filno]
imgs=[]
tempdfil=open(os.path.join(os.getcwd(),inputpath,datnames[filno]))
dattxt=decrypt_lf2(tempdfil.read())
imgsargs=[]
for asdf in dattxt[:dattxt.find("<bmp_end>")].split("\n"):
if "file(" in asdf:
imgsargs.append(asdf)
tempdfil.close()
for a in range(len(imgsargs)):
datimgsdata.append([imgsargs[a][imgsargs[a].rfind("\\")+1:imgsargs[a].find(".bmp")+4],
getarg(imgsargs[a],"file(", "-"),
[int(getarg(imgsargs[a], "w:", None)), int(getarg(imgsargs[a], "h:", None)),int(getarg(imgsargs[a], "row:", None)),int(getarg(imgsargs[a], "col:", None))]
])
for name in range(len(datimgsdata)):
nameah=name
currentbmpname=datimgsdata[name][0]
if currentbmpname in ifilenames:
imgs=pygame.image.load(os.path.join(os.getcwd(),inputpath,datimgsdata[name][0]))
sqprop=[datimgsdata[name][2][0], datimgsdata[name][2][1], datimgsdata[name][2][2], datimgsdata[name][2][3]]
filenoh=filno
if Running:
pixels=pygame.surfarray.array3d(imgs)
allwidth=pixels.shape[0]
allheight=pixels.shape[1]
mehwidth=allwidth/sqprop[2]
mehheight=allheight/sqprop[3]
widtharray=[]
heightarray=[]
clip=[]
pureclip=[]
wval1,hval1,wval2,hval2=None,None, None, None
xarrax=[]
yarray=[]
for row in range(sqprop[3]):
for col in range(sqprop[2]):
clip.append(pixels[col*mehwidth:(col*mehwidth)+sqprop[0], row*mehheight:(row*mehheight)+sqprop[1], :])
for w in range(len(clip)):
for y in range(sqprop[1]):
for x in range(sqprop[0]):
if tuple(clip[w][x][y])!=(0, 0, 0) and hval1==None:
hval1=y
if tuple(clip[w][sqprop[0]-x-1][sqprop[1]-y-1])!=(0, 0, 0) and hval2==None:
hval2=sqprop[1]-y-1
for x in range(sqprop[0]):
for y in range(sqprop[1]):
if tuple(clip[w][x][y])!=(0, 0, 0) and wval1==None:
wval1=x
if tuple(clip[w][sqprop[0]-x-1][sqprop[1]-y-1])!=(0, 0, 0) and wval2==None:
wval2=sqprop[0]-x-1
if wval1!=None and hval1!=None and wval2!=None and hval2!=None:
xarrax.append([wval1, wval2])
yarray.append([hval1, hval2])
widtharray.append(wval2-wval1)
heightarray.append(hval2-hval1)
wval1,hval1,wval2,hval2=None,None, None, None
else:
xarrax.append([54321, 54321])
yarray.append([54321, 54321])
widtharray.append(0)
heightarray.append(0)
widtharraynotsorted=widtharray[:]
heightarraynotsorted=heightarray[:]
widtharray=sorted(widtharray)[::-1]
heightarray=sorted(heightarray)[::-1]
newgrid=numpy.copy(pixels[:((widtharray[0]+2)*sqprop[2]), :((heightarray[0]+2)*sqprop[3]), :])
newsqprop=[(widtharray[0]+2), (heightarray[0]+2), sqprop[2], sqprop[3]]
for g in range(sqprop[2]*sqprop[3]):
if xarrax[g][0]!=54321:
pureclip.append(clip[g][xarrax[g][0]:xarrax[g][1],yarray[g][0]:yarray[g][1]+1, :])
else:
pureclip.append(None)
for a in range(len(newgrid)):
newgrid[a]= (0, 0, 0)
for a in range(sqprop[2]):
newgrid[a*(widtharray[0]+2) +(widtharray[0])+1]=(0, 255, 0)
for b in range(sqprop[3]):
newgrid[:, b*(heightarray[0]+2)+(heightarray[0])+1]=(0, 255, 0)
for y in range(newsqprop[3]):
for x in range(newsqprop[2]):
if pureclip[(x+(newsqprop[2]*y))]!=None:
newgrid=combinesfas(pureclip[(x+(newsqprop[2]*y))],
newgrid,
[((x*newsqprop[0])+(newsqprop[0]/2))-(widtharraynotsorted[(x+(newsqprop[2]*y))]/2)-1,
((y*newsqprop[1])+newsqprop[1])-heightarraynotsorted[(x+(newsqprop[2]*y))]-2])
savegrid(newgrid, os.path.join(os.getcwd(), outputpath, datimgsdata[name][0]))
datsplitted=dattxt.split("\n")
picval=None
for qw in range(len(datsplitted)):
if datimgsdata[name][0] in datsplitted[qw]:
datsplitted[qw]=datsplitted[qw][:datsplitted[qw].find("w:")]+datsplitted[qw][datsplitted[qw].find("w:"):].replace(str(sqprop[0]), str(newsqprop[0]-1),1)
datsplitted[qw]=datsplitted[qw][:datsplitted[qw].find("h:")]+datsplitted[qw][datsplitted[qw].find("h:"):].replace(str(sqprop[1]), str(newsqprop[1]-1),1)
if "pic:" in datsplitted[qw]:
picval=int(getarg(datsplitted[qw], "pic:", None))
if picval!=None and picval in range(int(datimgsdata[name][1].split("-")[0]), int(datimgsdata[name][1].split("-")[1])+1):
if "centerx:" in datsplitted[qw]:
cxval=int(getarg(datsplitted[qw], "centerx:", None))
cxdelta=cxval-(xarrax[picval-int(datimgsdata[name][1].split("-")[0])][0])
datsplitted[qw]=datsplitted[qw][:datsplitted[qw].find("centerx:")]+datsplitted[qw][datsplitted[qw].find("centerx:"):].replace(str(cxval), str(cxdelta+(((newsqprop[0])/2)-(widtharraynotsorted[picval-int(datimgsdata[name][1].split("-")[0])]/2))),1)
if " x:" in datsplitted[qw]:
xval=int(getarg(datsplitted[qw], " x:", None))
xdelta=xval-(xarrax[picval-int(datimgsdata[name][1].split("-")[0])][0])
datsplitted[qw]=datsplitted[qw][:datsplitted[qw].find(" x:")]+datsplitted[qw][datsplitted[qw].find(" x:"):].replace(str(xval), str(xdelta+(((newsqprop[0])/2)-(widtharraynotsorted[picval-int(datimgsdata[name][1].split("-")[0])]/2))),1)
if "centery:" in datsplitted[qw]:
cyval=int(getarg(datsplitted[qw], "centery:", None))
cydelta=cyval-(yarray[picval-int(datimgsdata[name][1].split("-")[0])][0])
datsplitted[qw]=datsplitted[qw][:datsplitted[qw].find("centery:")]+datsplitted[qw][datsplitted[qw].find("centery:"):].replace(str(cyval), str(cydelta-1+(((newsqprop[1]))-(heightarraynotsorted[picval-int(datimgsdata[name][1].split("-")[0])]))),1)
if " y:" in datsplitted[qw]:
yval=int(getarg(datsplitted[qw], " y:", None))
ydelta=yval-(yarray[picval-int(datimgsdata[name][1].split("-")[0])][0])
datsplitted[qw]=datsplitted[qw][:datsplitted[qw].find(" y:")]+datsplitted[qw][datsplitted[qw].find(" y:"):].replace(str(yval), str(ydelta-1+(((newsqprop[1]))-(heightarraynotsorted[picval-int(datimgsdata[name][1].split("-")[0])]))),1)
dattxt="\n".join(datsplitted)
newdat=open(os.path.join(os.getcwd(), outputpath,datnames[filno]), 'w')
finaldatfile=encrypt_lf2(dattxt)
del dattxt
newdat.write(finaldatfile)
newdat.close()
nameah+=1
dateah+=1
Done=True
except Exception, e:
MessageBox(0,str(e),'Runtime error!',0x00L|0x0010L)
Done="failed"
sys.exit()
mainthread=threading.Thread(target=main)
mainthread.start()
Running=True
MainFont = pygame.font.SysFont(None, 20)
l_text=" "
while Running:
if l_text==" ":
l_text="A-xecuting: |"
elif l_text=="A-xecuting: |":
l_text="A-xecuting: /"
elif l_text=="A-xecuting: /":
l_text="A-xecuting: --"
elif l_text=="A-xecuting: --":
l_text="A-xecuting: \\"
elif l_text=="A-xecuting: \\":
l_text="A-xecuting: |"
L_text= MainFont.render(l_text, 1, (0, 255, 0))
L_textbdy=L_text.get_rect()
L_textbdy.top=10
L_textbdy.left=10
A_Surf.fill((0, 0, 0))
for event in pygame.event.get():
if event.type == QUIT or (event.type==KEYDOWN and (Done==True or Done=="failed")):
Running=False
pygame.quit()
sys.exit()
if Done==True and len(datnames)!=0:
A_Surf.blit(MainFont.render("Operation Succeeded!!", 1, (255, 255, 0)), (80,80, 0,0))
if Done=="failed" and len(datnames)!=0:
A_Surf.blit(MainFont.render("Operation Failed~ =(", 1, (255, 50, 50)), (80,80, 0,0))
if len(datnames)!=0:
A_Surf.blit(MainFont.render("Current dat file: "+str(currentdatname)+" =>", 1, (255, 255, 255)), (10,30, 0,0))
A_Surf.blit(MainFont.render(str(dateah)+"/"+str(len(datnames)), 1, (255, 0, 0)), (300,30, 0,0))
A_Surf.blit(MainFont.render("Current bmp file: "+str(currentbmpname)+" =>", 1, (255, 255, 255)), (10,50, 0,0))
A_Surf.blit(MainFont.render(str(nameah)+"/"+str(len(datimgsdata)), 1, (255, 0, 0)), (300,50, 0,0))
else:
A_Surf.blit(MainFont.render("No dat files found!", 1, (255, 0, 0)), (10,30, 0,0))
if Done!="failed" and Done!=True and len(datnames)!=0:
A_Surf.blit(L_text, L_textbdy)
pygame.display.update()
time.sleep(0.1)
How about supporting the C family languages syntax? That would be cool! Keep it up XD!
The New Style Codes Are Written!
We can definitely add A-script tag and C thingy.. (with effort ofcourse, as I would have to create it myself... will try adding C soonish.. anothe cool update coming soon
Similar topics
» What is your drawing style?
» Unlocking Codes shop
» Custom BB Codes : LGBB
» Unlocking codes Shop (1.8)
» Baby5 custom sprite - GB Style
» Unlocking Codes shop
» Custom BB Codes : LGBB
» Unlocking codes Shop (1.8)
» Baby5 custom sprite - GB Style
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|