eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'HumanReadableImageGenerator':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: HumanReadableImageGenerator


Inheritance:

   Object
   |
   +--HumanReadableImageGenerator

Package:
stx:goodies/webServer
Category:
Net-Communication-HTML-Misc
Version:
rev: 1.17 date: 2019/03/13 20:43:16
user: cg
file: HumanReadableImageGenerator.st directory: goodies/webServer
module: stx stc-classLibrary: webServer
Author:
Claus Gittinger

Description:


Generate a form containing a string for the user to type into a web-form
as confirmation that he is really human.
I.e. the forms image is designed to make it hard for an OCR program to
extract the characters.
At least, we hope that it is so.

Sometimes, the picture is hard to decipher, even for a real human;
therefore, add some 'try another picture' button to the web page.

Caveat: this is a dirty hack

[usage:]
    HumanReadableImageGenerator new generate inspect


Class protocol:

defaults
o  characterMapCharacters

o  numberOfCharMaps

image specs
o  charMapImage1
character bitmaps (needed ebcause the webServer has no Display for drawing)

usage example(s):

     self charMapImage1 inspect
     ImageEditor openOnClass:self andSelector:#charMapImage1
     Icon flushCachedIcons

o  charMapImage1_height

o  charMapImage1_width

o  charMapImage2
character bitmaps (needed because the webServer has no Display for drawing)

usage example(s):

     self charMapImage2 inspect
     ImageEditor openOnClass:self andSelector:#charMapImage2
     Icon flushCachedIcons

o  charMapImage2_height

o  charMapImage2_width

o  charMapImage3
character bitmaps (needed ebcause the webServer has no Display for drawing)

usage example(s):

     self charMapImage3 inspect
     ImageEditor openOnClass:self andSelector:#charMapImage3
     Icon flushCachedIcons

o  charMapImage3_height

o  charMapImage3_width

o  getCharMapImage: idx
self getCharMapImage:1
self getCharMapImage:2
self getCharMapImage:3

instance creation
o  new

support
o  fonts

o  generateFontMaps
generates the methods:
charMapImage1,
charMapImage2,
...
one for each font

usage example(s):

     self generateFontMaps

o  generateImageMethod: selector with: image forFont: aFont
self generateFontMaps


Instance protocol:

accessing
o  characterSet: something

o  colors: aCollectionOfColors

o  extent: aPoint

o  maxAngle: something

o  minAngle: something

o  numberOfRandomDots: anInteger

o  numberOfRandomLines: anInteger

o  string

o  string: something

o  stringLength: something

initialization
o  computeExtent
what a hack

o  generateString

o  initialize
|gen image|

gen := HumanReadableImageGenerator new.
gen numberOfRandomDots:5000.
gen numberOfRandomLines:10.
gen minAngle:-45.
gen maxAngle:45.
image := gen generate.
image inspect.

o  randomCharacter

private
o  generate
HumanReadableImageGenerator new generate inspect

o  generateFormUsingDisplay
ensure that even after rotation, the result still lies inside the charBox.

usage example(s):

     HumanReadableImageGenerator new generateFormUsingDisplay inspect

o  generateImageWithoutUsingDisplay
colors := OrderedCollection new.

usage example(s):

     HumanReadableImageGenerator new generateImageWithoutUsingDisplay inspect

public
o  generateImage


Examples:


    |gen image|

    gen := HumanReadableImageGenerator new.
    gen extent:300@100.
    gen numberOfRandomDots:1000.
    gen numberOfRandomLines:25.
    gen minAngle:-45.
    gen maxAngle:45.
    gen string inspect.
    image := gen generate.
    image inspect.


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Tue, 19 Mar 2024 05:47:55 GMT