Actions

Badge Display Code Documentation

From Convention Master Documentation

In order to generate badges the system uses a series of commands known as badgecode. This badgecode, badge drawing code is documented here.

Badgecode Basics

Badgecode is highly order of operations based, it renders from top to bottom in order.

Generally, when constructing a badge, place your images near the top, then start to render your text, otherwise your images may render on top of your text. However, this can be used to your advantage, you can use PNG's with partial transparency, to overlay color, images, or other features on top of system rendered objects - including other images. Badges can be built up of multiply layers of objects which can be programmatically switched in or out based on the attendees specific system held data.

For example where you place invert_image(); will effect the way it works, you can make it only effect part of the badge, you can even use multiple invert_image();'s in series to invert part of the badge conditionally based on state (underage, UDF, product purchased, membership, what have you).

Badgecode Co-ordinate system.

The system requires co-ordinates, and these co-ordinates can be passed in many ways, the most common way will be to pass the just numbers, and numbers will represent pixels in the image your attempting to draw. However, several other methods are possible, including percentages, inches, cm, mm, points, and pixels. In addition the numbers used can be negative which will make them count from the opposite direction.

Variables

The system has many variables that you can pull from in order to put information on-to the badge. Nearly every variable for a person from the database is available in the draw code. The variables are named as <table name>_<field name> so the fan_name field from the registrant table would be $registrant_fan_name, the current_membership_type from the events_attended table would be $events_attended_current_membership_type. Variables will sometimes need to be followed by a space. This is definatly true in all strings. To get something to read <reg_num>-<uid> you will need to write your string as "$events_attended_reg_num -$uid" or "$events_attended_reg_num\-$uid"

There are some special variables which are populated, here is a list of some of the unique variable names.

Event Variables

Event Variables
Variable Notes
$event_id Event Short Name E.G. RF0
$events_event_title Event Title defined on the Edit Event screen.
$event_membership_types_name The membership group.
$event_membership_types_long_name The membership name as is intended to be printed on the badge.

Registrant Variables

Registrant Variables
$uid Registrant UID
$registrant_first_created Creation date of the person.
$events_attended_reg_num Registration Sequence Number
$registrant_common_name Uses the $registrant_fan_name value if the value is not empty, and uses the $registrant_rl_first and $registrant_rl_last otherwise.
$registrant_fan_name Registrant Fan/Badge Name
$registrant_rl_first Registrant First Name
$registrant_rl_last Registrant Last Name
$registrant_birthday The person's birthday.
$underage true if the person is under the specified of_age. A good example of the use of this could be if($underage|invert_image()|do_nothing());

Special Variables

Special Variables
Special Variable Notes
$staff if $event_membership_types_name contains the word 'staff' this will equal true, this is not case sensitive.

UDF Variables

User Defined Fields - User defined fields can be applied on the badges. Use the following variables.
Variable Notes
$UDF_<num>_title Will display the title of the user defined field. (If the customer has it applied to them) Ex: $UDF_12_title.
$UDF_<num>_value Will display the value of the user defined field. (If the customer has it applied to them) Ex: $UDF_12_value.

Functions

Drawing Functions

All draw functions end in a ;

Geometry Functions
  • draw_line([ulx,uly],[llx,lly]) - Draws a line from [x.y] to [x,y]
  • draw_box([ulx,uly],[llx,lly],Optional Arguments here) - Will draw a box with the top corner being at the first pair, and the lower right being at the second pair. This function always starts drawing from the top or the left.
    • filled=yes - Will Fill the box with black (or the color specified in color)
    • color=r:g:b - Will set the draw color for this function to the specified rgb value.
Image Functions
  • draw_image("filename",[p1x,p1y],[p2x,p2y]) - Draw the specified image with the top left of the image at point 1, and the lower right of the image at point 2. If IMAGE_UID### is specified instead of a filename the image will be pulled from the badge_images table and used instead. There is no space between IMAGE_UID and the Number of the badge_image.
  • flood_fill(r,g,b) - will perform a flood fill on the image at 2,2
Layout Assistance Function
  • draw_measure([x,y],Optional Arguments Here) - Will draw a measurement line for you to help figure out co-ordinates of your drawing.
    • ticks=<integer> - Defaults to 100 (Draw a large tick every <integer> pixels, and a small tick every <integer/2> pixels)
    • type=<horizontal|vertical> - Defaults to Vertical
Text and Barcode Functions
  • draw_text("string",[x,y],Optional Arguments here) - Draws text at the x,y co-ordinates, with the following optional arguments which can be passed in any order and must be seperated by a comma.
    • font=<font> - Where <font> is the name of a font file in the shared_php folder, case-sensitive, do not add the .ttf extension.
    • align=<align> - Where <aign> is the alignment you want, left, right or center
    • vertalign=<align> - Where <align> is top, middle or bottom.
    • size=<size> - Where <size> is the size of the text you want
    • angle=<angle> - Where <angle> is the angle of the text
    • border=<true|false|numeric> - Determines if there will be a border on the text If border is a numeric value the value will dictate the thickness of the border.
    • inverted=<true|false> - Determines if the text will be inverted.
    • maxwidth=<width> - Determines the maximum width this text can take, if long names appear they will be automatically reduced in font in order for them to maintain a size no greater than the maximum width.
    • str_pad_value=<value> - Determines the value of the str_pad character if there is a need for one.
    • str_pad_align=<left|center|right> - Determines which side of the string will be padded.
    • str_pad_length=<value> - If this value is numeric, the string length will be padded to this number of characters using 0 (default) or the string specified by str_pad_value and the alignment if specified in str_pad_align.
    • color=r:g:b - If this value is present then the rgb value of the color will be used for the font. Otherwise, black will be used. (Or white if invert is present This setting overrides Invert)
  • draw_barcode("string",[x,y],Optional Arguments here) - Draws a barcode at the x,y co-ordinates with the following optional arguments which can be passed in any order and must be seperated by a comma,
    • format=<code128|code39|codebar> - Defaults to code39
    • align=<left|center|right> - Defaults to Left
    • orientation=<horizontal|vertical> - Defaults to Horizontal
    • height=<value> - Integer value determines the height of the barcode, width is always determined by the string, no scaling option is available.
    • width=<value> - Strech or squash the barcode to this width (Does not maintain aspect ratio, use with height)
    • str_pad_length=<value>, - If this value is numeric, the string length will be padded to this number of characters using 0 (default) or the string specified by str_pad_value and the alignment if specified in str_pad_align.
    • str_pad_value=<value> - Determines the value of the str_pad character if there is a need for one.
    • str_pad_align=<left|center|right> - Determines which side of the string will be padded.
    • color=<r:g:b> - Set the draw color.

Miscellaneous Functions

  • // comment - Using // will add comments to your draw code that won't render.
  • invert_image(); - this function will invert the colors or intensity of all functions which appear after this function.

Logic Functions

  • if("value"|true-action|false-action); - For example if($underage | draw_text("Underage", [82.5%,80%]) | do_nothing());
  • strcmp("somthing"="somthingelse"|true-action|false-action); - this function.
  • do_nothing(); - this function is valuable for the IF statements.
Special Logic Functions
  • ifmembershipgroup("value"|true-action|false-action); - This tools is a IF stament that will allow you to draw things depending on whether or not a person has a specific membership group.
    • Example ifmembershipgroup("patron"|draw_box([50,50],[100,100],color=0:0:255,filled=yes)|draw_box([50,50],[100,100],color=255:00:00,filled=yes));
  • ifproductpurchased("upc"|true-action|false-action); - This tool is a IF statement that will allow you to draw things depending on whether or not a person has a specific product purchased (paid, not just in cart), and not refunded.
    • Example:ifproductpurchased("1000180"|draw_box([50,50],[100,100],color=0:0:255,filled=yes)|draw_box([50,50],[100,100],color=255:00:00,filled=yes));

Badgecode Examples

CR80 Horizontal Example

Rendered Badges
CR80 Horizontal FNO.png
CR80 Horizontal FNO Minor Ada Dealer.png
CR80 Horizontal FNO Media Ada Dealer.png
Badgecode

//Developed for StratosFur 2021

//Begin Common Code Section

//badge image commented out, comment out the invert_image line when restoring - will show a black background for testing without image. //draw_image("IMAGE_UID1", [1,1], [100%,100%]); invert_image();

// Lets draw the Event and Membership draw_text("$events_event_title - $uid",[95.5%,600],size=30,align=right,color=255:255:255,font="gayatri");

// draw minor warning - Draws in Red - overlaps with Media Flag, cannot be a media minor. if($underage | draw_text("Minor",[95.5%,25.5%],size=150,align=right,color=255:0:0,font="gayatri")|do_nothing());

// Max Width must change for Membership type because of size of minor warning.

if($underage|draw_text("$event_membership_types_name",[50,15.5%],size=60,align=left,color=255:255:255,maxwidth=450,font="gayatri")|draw_text("$event_membership_types_name",[50,15.5%],size=60,align=left,color=255:255:255,maxwidth=1000,font="gayatri"));

//Show marker for ADA - Yellow if ($UDF_6_value | draw_text("ADA",[95.5%,39.5%],size=60,align=right,color=240:240:0,font="gayatri")|do_nothing());

//Show marker Media - Green - Cannot be Media/Minor, they occupy the same space if ($UDF_7_value | draw_text("Media",[95.5%,25.5%],size=150,align=right,color=0:255:0,font="gayatri")|do_nothing());

//Show marker Dealers - Draws in Magenta. if ($UDF_8_value |draw_text("Dealers",[95.5%,50.5%],size=60,align=right,color=255:0:255,font="gayatri")|do_nothing());

//End Common Code

//Begin FNOT

// Lets draw the Fan name. draw_text("$registrant_fan_name",[50,530],font="gayatri",size=85,align=left,valign=bottom,maxwidth=1000,color=255:255:255);

// Next lets draw the furry name under the main name draw_text("$registrant_rl_first $registrant_rl_last ",[50,600],,font="gayatri",size=50,align=left,maxwidth=540,color=255:255:255);

//End FNOT

//Begin FNO

// Lets draw the Fan name. draw_text("$registrant_fan_name",[50,600],font="gayatri",size=85,align=left,valign=bottom,maxwidth=600,color=255:255:255;

//END FNO

//Begin FNOB

// Next lets draw the real name draw_text("$registrant_rl_first $registrant_rl_last ",[50,530],font="andlso",size=85,align=left,maxwidth=550,color=255:255:255,font="gayatri");

// Lets draw the Fan name. draw_text("$registrant_fan_name",[50,600],font="gayatri",size=50,align=left,valign=bottom,maxwidth=600,color=255:255:255);

//End FNOB

CR80 Vertical Example

Zebra 4x1 Example

Rendered Badges
Zebra 4x1 FNO.jpg
Zebra 4x1 FNO Minor.jpg
Badgecode

//Developed for TTFC 2021

//Begin Common Code Section

// Lets draw the EVENT ID if($underage | draw_text("$events_event_id",[10,92.5%],inverted=true,size=40,align=left,border=5,font="blackadd") |draw_text("$events_event_id",[10,92.5%],size=40,align=left,border=5,font="blackadd"));

// If underage, draw "UNDER AGE", else draw optional value (nominally species) if($underage | draw_text("UNDER AGE", [150,-15],inverted=true,font="andlso",size=40,align=left) | draw_text("$UDF_1_value",[190,-9],size=28,font="andlso",maxwidth=320));

// Draw membership type and UID draw_text("$event_membership_types_long_name",[-128,-15],size=28,align=right,font="andlso")); draw_text("$uid",[-120,-15],size=28,align=left,font="andlso", str_pad_length=4,str_pad_align=left,str_pad_value="0"));

//End Common Code

//Begin FNOT

draw_text("$registrant_rl_first $registrant_rl_last ",[480,36],font="andlso",size=72,align=center,valign=middle,maxwidth=500); draw_text("$registrant_fan_name ", [480,120],font="andlso",size=42,align=center,valign=middle,maxwidth=500);

//End FNOT

//Begin FNO

draw_text("$registrant_fan_name",[480,120],font="andlso",size=85,align=center,valign=bottom,maxwidth=500);

//END FNO

//Begin FNOB

draw_text("$registrant_rl_first $registrant_rl_last ",[480,36],font="andlso",size=72,align=center,valign=middle,maxwidth=500); draw_text("$registrant_fan_name ", [480,120],font="andlso",size=42,align=center,valign=middle,maxwidth=500);

//End FNOB