Created
September 24, 2012 19:35
-
-
Save weslly/3777870 to your computer and use it in GitHub Desktop.
Generate line numbers to Sublime VintageLines plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Set the content-type | |
header('Content-Type: image/png'); | |
// Replace with your own font and font-size | |
$font = 'UbuntuMono-R.ttf'; | |
$fontsize = 11; | |
// Create the numbers directory if it doesn't exist | |
if(!is_dir(dirname(__FILE__) . '/numbers/')) { | |
mkdir(dirname(__FILE__) . '/numbers/', 777); | |
} | |
for ($i = 0; $i <= 80; $i++) { | |
$text = ($i <= 9)? ' ' . $i : $i; | |
$im = imagecreatetruecolor(16, 16); | |
imagealphablending($im, true); | |
// Create some colors | |
$white = imagecolorallocatealpha($im, 255, 255, 255, 0); | |
$transp = imagecolorallocatealpha($im, 0, 0, 0, 127); | |
// $grey = imagecolorallocate($im, 128, 128, 128); | |
// $black = imagecolorallocate($im, 0, 0, 0); | |
imagefill($im, 0, 0, $transp); | |
imagesavealpha($im, true); | |
imagettftext($im, $fontsize, 0, 1, 11, $white, $font, $text); | |
$imagepath = 'numbers/' . $i . '.png'; | |
imagepng($im, $imagepath); | |
readfile($imagepath); | |
imagedestroy($im); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example (using ubuntu mono):