Badge Display Code

 

Draw code

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

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 follows $&l;ttable 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.

  • $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());
  • $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.
  • User Defined Fields - User defined fields can be applied on the badges. Use the following variables.
    • $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
  • $event_membership_types_long_name - The membership name as is intended to be printed on the badge.
  • $event_membership_types_name - The membership group
  • $registrant_birthday - The person's birthday
  • $registrant_first_created - Creation date of the person

 

Draw Functions

All draw functions end in a ;

  • draw_line([ulx,uly],[llx,lly]) - Draws a line from [x.y] to [x,y]
  • 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
  • // comment - Using // will add comments to your draw code that won't render.
  • 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.
  • flood_fill(r,g,b) - will perform a flood fill on the image at 2,2
  • 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.
  • 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.
  • 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)
  • do_nothing(); - this function is valuable for the IF statements.
  • invert_image(); - this function will invert the image.
  • strcmp("somthing"="somthingelse"|true-action|false-action); - this function
  • ifmembershipgroup("value"|true-action|false-action); -
  • if("value"|true-action|false-action); - For example if($underage | draw_text("Underage", [82.5%,80%]) | do_nothing());