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.21 date: 2021/11/26 17:58:20
user: cg
file: HumanReadableImageGenerator.st directory: goodies/webServer
module: stx stc-classLibrary: webServer

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

copyright

COPYRIGHT (c) 2008 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

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
(comment from inherited method)
return an instance of myself without indexed variables

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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Thu, 21 Nov 2024 13:02:47 GMT