scale.table 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # scale.table
  2. !'
  3. "
  4. Scale rendering using the table:
  5. "
  6. $func ('scale.table', 275, 420) + ' 275 / 420'
  7. $func ('scale.table', 400, 420) + ' 400 / 420'
  8. $func ('scale.table', 420, 420) + ' 420 / 420'
  9. $func ('scale.table', 157, 420) + ' 157 / 420'
  10. $func ('scale.table', 42, 420) + ' 42 / 420'
  11. $func ('scale.table', 0, 420) + ' 0 / 420'
  12. '!
  13. !!-----scale.table------
  14. args[0] = args[0] & ! the current value of the parameter
  15. args[1] = args[1] & ! the maximum value
  16. if args[2] = 0:args[2] = 200 & ! Span (tables) pixels. default 350 px
  17. if $ARGS[3] = "":$ARGS[3] = "FF0000" & ! the color of the filled part of the scale in the format RRGGBB. default - red
  18. !! at_first "create" corresponding table
  19. $ARGS['table'] = '<table width="<<args[2]>>" border="0" cellspacing="0" cellpadding="0"><tr>'
  20. !! calculate the width as a percentage of the filled part
  21. args['x'] = (args[0] * 100) / args[1]
  22. !! calculate the percentage widths ullage
  23. args['empty'] = 100 - args['x']
  24. !! If the width of the filled part of more than zero percent, added to the table cell with the specified color (red on-default)
  25. if args['x'] > 0:
  26. $ARGS['table'] += '<td width="<<args['x']>>%" bgcolor="#' + $ARGS[3] + '">&nbsp;</td>'
  27. end
  28. !! If the width of the unfilled part of the scale is greater than zero percent, added to the table cell with another color (gray).
  29. if args['empty'] > 0:
  30. $ARGS['table'] + = "<td width="<<args['empty']>>%" bgcolor="#888888">&nbsp;</td>"
  31. end
  32. !! "close" table
  33. $ARGS['table'] += '</tr></table>'
  34. !! the_result
  35. $result = $ARGS['table']
  36. --- scale.table ---------------------------------