Can you read the text in the pictue?
- Easy.
- With effort.
- Barely.
- No, it is unintelligible.
0 voters
Due to incessant spammage on the forums, I wrote an improved CAPTCHA script using Panda3D. It might take some tweaking to make it work on a webhost so I’m releasing it under a zlib-style license.
It requires the following truetype fonts:
Barred Out.ttf
Schizm.ttf
Scratch my back.ttf
SF Wasabi.ttf
Shattered.ttf
Spotted Fever.ttf
Staccatissmo.ttf
They are available for free on the internet and should be easy to find.
Also the environment.egg file (at least the last time I checked) has some improperly applied textures. Change
<Texture> Tex975 {
"maps/envir-mountain2.png"
<Scalar> format { rgba }
<Scalar> wrapu { repeat }
<Scalar> wrapv { repeat }
<Scalar> minfilter { linear_mipmap_linear }
<Scalar> magfilter { linear }
}
To
<Texture> Tex975 {
"maps/envir-mountain2.png"
<Scalar> format { rgba }
<Scalar> wrapu { CLAMP }
<Scalar> wrapv { CLAMP }
<Scalar> minfilter { linear_mipmap_linear }
<Scalar> magfilter { linear }
}
Same for “maps/envir-mountain1.png”, “maps/envir-groundcover1.png”, “maps/envir-reeds.png”, and “maps/envir-bamboo.png”. Things will look much better without the stray lines.
# Copyright (c) 2006 Cyan
#
# This software is provided 'as-is', without any express or implied warranty.
# In no event will the author(s) be held liable for any damages arising from
# the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
#
# 2. Altered source versions must be plainly marked as such, and must not
# be misrepresented as being the original software.
#
# 3. This notice may not be removed or altered from any source distribution.
from pandac.PandaModules import *
loadPrcFileData("", "window-type offscreen")
loadPrcFileData("", "win-size 400 200")
import sys
import random
from direct.gui.OnscreenText import OnscreenText
import direct.directbase.DirectStart
base.disableMouse()
#store captcha code from 1st command line argument.
ccode = sys.argv[1].upper()#no lowercase glyphs
length = len(ccode) #compute length of ccode
#the FONTS tuple contains tuples of the form ('font name','forbidden glyphs')
#Because not all the glyphs in a font are legible, they can be specified as
# 'forbidden glyphs' wich will never be displayed. Note when trying new fonts:
#If a particular glyph is ambiguous, or unreadable to a human out of context,
# it should be forbidden.
FONTS = (('Schizm.ttf','GNU0'),('SF Wasabi.ttf','GS56910'),
('Scratch my back.ttf','0'),('Scratch my back.ttf','0'),#double chance ;)
('Spotted Fever.ttf','I0'),('Shattered.ttf','EIL10'),
('Staccatissmo.ttf','I0'),('Barred Out.ttf','BI'))
def ChooseGlyph(tNode,char):#chooses an appropriate glyph from among FONTS
tNode.setText(char)#assign the character to the TextNode
choices = list(FONTS) #thaw tuple
while 1:
randy = random.randint(0,len(choices)-1)#Choose from FONTS at random
if choices[randy][1].find(char) == -1:#if absent from forbidden glyphs
font = choices[randy][0]#then use that font
break #success!
choices.pop(randy)#remove forbidden font and try again.
tNode.setFont(loader.loadFont(font))#assign the font
def SavePic():
base.screenshot('captcha.jpg',defaultFilename = False)
sys.exit()#end program after saving image
base.setBackgroundColor(0.25,0.6,0.6)#blue sky
dumnod = aspect2d.attachNewNode("dumnod")#dummynode to parent the TextNodes
dumnod.setScale(3)#scaling blurs the glyphs
for i in range(length):#Create image. One TexNode per character in ccode.
node = TextNode("tn%s" % i)#new TextNode: tn#
ChooseGlyph(node,ccode[i:i+1])#choose a glyph to represent the character
path = dumnod.attachNewNode(node)#attach to the dummynode
path.setScale(0.19)#scale glyph
path.setPos((-length/2+i)*.15,0,(random.random()-1)*.1)#position it
path.setR(random.randint(-10,15))#rotate a little
watermarkText = "Panda3D Forums "*30#this is a bot distraction
watermark = OnscreenText(text = watermarkText,fg=(1,1,0.5,.23),wordwrap=33,
shadow=(1,0,0,.2), pos = (-1,1), scale = 0.25)#render watermark
base.camera.setPos(0,0,5)#put the camera on a tripod
base.camera.setH(random.randint(1,360))#randomize camera angle
environ = loader.loadModel("models/environment")#the built-in panda environment
environ.reparentTo(render)
environ.setScale(0.25,0.25,0.25)
environ.setPos(-8,42,0)
taskMgr.doMethodLater(1, SavePic, 'Save Task',extraArgs = [])#do 1 sec later
run()#run
the line
loadPrcFileData("", "window-type offscreen")
causes errors in Panda-1.2.3 . You must supply a string for display as the first command line argument or it wont work.
Tell me what you think!