Discuss Scratch

QuillzToxic
Scratcher
1000+ posts

[API] Scratch Image Utlility API

Note:
If you old 1.xers remember the wonderful man sparks! He started the block libary and also this. I might do some work on it if the scratch team and the creators don't mind. All credit goes to him.
Please This Page is a WIP and some of the features wont work.

This API allows Scratch users to show images that change according to events and conditions in their forum posts and signatures. This includes showing whether the user is online or not and displaying their newest project(s).

Create your custom link/image using the creator linked and documented here by comp500 or make it yourself using the uses list below.

Editor wrote:

Currently the other stuff will not work with 2.0

Random
- Random Images
- Random Links
Customise any text return to match your sig
___________________________________________________________________________________
Thanks to MathWizz for help getting the images to display on the fora!

Code:

Editor wrote:

Im sorry! The code has all the old 1.x feature

<?php
#--------------------------------------------------------------------------FUNCTIONS---------------------------------------------------------------------------------
#the function nth_position() helps locate project information.
function nth_position($str, $letter, $n, $offset = 0){
    $str_arr = str_split($str);
    $letter_size = array_count_values(str_split(substr($str, $offset)));
    if( !isset($letter_size[$letter])){
        trigger_error('letter "' . $letter . '" does not exist in ' . $str . ' after ' . $offset . '. position', E_USER_WARNING);
        return false;
    } 
    else if($letter_size[$letter] < $n) {
        trigger_error('letter "' . $letter . '" does not exist ' . $n .' times in ' . $str . ' after ' . $offset . '. position', E_USER_WARNING);
        return false;
    }
    for($i = $offset, $x = 0, $count = (count($str_arr) - $offset); $i < $count, $x != $n; $i++){
        if($str_arr[$i] == $letter){
        $x++;
        }
    }
    return $i - 1;
}
#-------------------------------------------------------------------------------CONVERSION---------------------------------------------------------------------------
#This part converts most of the inputs to the API into lowercase in order to decrease human error
if(isset($_GET['action'])){
    $action = strtolower($_GET['action']);
}
if(isset($_GET['target'])){
    $target = strtolower($_GET['target']);
}
if(isset($_GET['type'])){
    $type = strtolower($_GET['type']);
}
if(isset($_GET['online'])){
    $inOnline = $_GET['online'];
}
if(isset($_GET['offline'])){
    $inOffline = $_GET['offline'];
}
if(isset($_GET['user'])){
    $inUser = $_GET['user'];
}
if(isset($_GET['user2'])){
    $inUser2 = strtolower($_GET['user2']);
}
if(isset($_GET['user3'])){
    $inUser3 = strtolower($_GET['user3']);
}
if(isset($_GET['user4'])){
    $inUser4 = strtolower($_GET['user4']);
}
if(isset($_GET['return'])){
    $inReturn = strtolower($_GET['return']);
}
#---------------------------------------------------------------IMAGE TO TEXT CUSTOM SETTINGS ----------------------------------------------
$extraText = ''; # these are custom commands that can be set to change the appearance of the custom image, such as text size and colour or background colour.
if(isset($_GET['font_size'])){
    $extraText = $extraText . '&font_size=' . $_GET['font_size'];
}
if(isset($_GET['width'])){
    $extraText = $extraText . '&width=' . $_GET['width'];
}
if(isset($_GET['height'])){
    $extraText = $extraText . '&height=' . $_GET['height'];
}
if(isset($_GET['bgr'])){
    $extraText = $extraText . '&bgr=' . $_GET['bgr']; #bgr, bgg, bgb, textr, textg and textb are all RGB values, only set them to numbers from 0 to 255.
}
if(isset($_GET['bgg'])){
    $extraText = $extraText . '&bgg=' . $_GET['bgg'];#If you don't set one of the rgb values it will assume it is 0 though if r, b and g aren't set the default colour for the fora is used.
}
if(isset($_GET['bgb'])){
    $extraText = $extraText . '&bgb=' . $_GET['bgb'];
}
if(isset($_GET['textr'])){
    $extraText = $extraText . '&textr=' . $_GET['textr'];
}
if(isset($_GET['textg'])){
    $extraText = $extraText . '&textg=' . $_GET['textg'];
}
if(isset($_GET['textr'])){
    $extraText = $extraText . '&textb=' . $_GET['textb'];
}
if(isset($_GET['xpos'])){
    $extraText = $extraText . '&xpos=' . $_GET['xpos'];
}
if(isset($_GET['ypos'])){
    $extraText = $extraText . '&ypos=' . $_GET['ypos'];
}
if(isset($_GET['limitstring'])){
    $extraText = $extraText . '&limitstring=' . $_GET['limitstring'];
}
if(isset($_GET['bgimage'])){
    $extraText = $extraText . '&bgimage=' . $_GET['bgimage'];
}
#-------------------------------------------------------------THE API--------------------------------------------------------------------------------------------
if(isset($action)){ #the action attribute tells the API what sort of thing it's going to do, e.g. look at projects or check your online status
    if($action == 'onlinestatus'){
     #target tells this part of the API whether to search in the tbg forum as well as the main one or not. If left blank, only the main fora are searched.
        if($target == 'tbg'){ #search only the text-based-games forum
            $page = ltrim(file_get_contents('http://scratch.mit.edu/tbgforums/'));
            $startpos = strrpos ($page, "Online:&nbsp;</strong></dt>");
            $endpos = strlen(ltrim(file_get_contents('http://scratch.mit.edu/tbgforums/')));
            $refined = substr($page, $startpos, $endpos);
        }
        if($target == 'all'){ #search the main fora as well as the tbg forum
            $page = ltrim(file_get_contents('http://scratch.mit.edu/tbgforums/'));
            $startpos = strrpos ($page, "Online:&nbsp;</strong></dt>");
            $endpos = strlen(ltrim(file_get_contents('http://scratch.mit.edu/tbgforums/')));
            $refined = substr($page, $startpos, $endpos);
            $page = ltrim(file_get_contents('http://scratch.mit.edu/forums/index.php'));
            $startpos = strrpos ($page, "Online:&nbsp;</strong></dt>");
            $endpos = strlen(ltrim(file_get_contents('http://scratch.mit.edu/forums/index.php')));
            $refined = $refined . substr($page, $startpos, $endpos);
        }
        if(!isset($target)){ #search only the main fora.
            $page = ltrim(file_get_contents('http://scratch.mit.edu/forums/index.php'));
            $startpos = strrpos ($page, "Online:&nbsp;</strong></dt>");
            $endpos = strlen(ltrim(file_get_contents('http://scratch.mit.edu/forums/index.php')));
            $refined = substr($page, $startpos, $endpos);
        }
        #set the default online and offline circle images. If no type value is set, they will appear.
        $online = 'http://blocks.scratchr.org/online.gif'; 
        $offline = 'http://blocks.scratchr.org/offline.gif';
        if(isset($type)){
            if($type == 'square'){ #set the images to square indicators
                $online = 'http://blocks.scratchr.org/onlineSquare.gif';
                $offline = 'http://blocks.scratchr.org/offlineSquare.gif';
            }
            if($type == 'text'){ #set the return to the text 'online' or 'offline'
                $online = 'http://blocks.scratchr.org/onlineText.png';
                $offline = 'http://blocks.scratchr.org/offlineText.png';
            }
            if($type == 'customtext'){ #Allow you to choose your own custom online and offline text.
                $online = 'http://www.blocks.scratchr.org/textrender.php?string=' . $inOnline;
                $offline = 'http://www.blocks.scratchr.org/textrender.php?string=' . $inOffline;
            }
        }
        if(!isset($type)){ #if type isn't set then you're either going for the default images or your own custom online/offline images.
            if(isset($inOnline)){ #if the input 'online' is set, display the image linked there when you are online
                $online = $inOnline;
            }
                if(isset($inOffline)){#if the input 'offline' is set, display the image linked there when you are offline
                $offline = $inOffline;
            }
        }
        $isonline = False; #innocent until proven guilty. The user is assumed to be offline until proof of his presence is found.
        if(isset($inUser)){
            $pos = strrpos($refined, $inUser);
            if($pos >= '1'){
                $isonline = True; #the user's name was found so he is online.
            }
        }
        if(isset($inUser2)){
            $pos = strrpos($refined, $inUser2);
            if($pos >= '1'){
                $isonline = True; #users 2 - 4 can also be checked. If they are all offline then isonline will return false, if any one of them are online it will return true.
            }
        }
        if(isset($inUser3)){
            $pos = strrpos($refined, $inUser3);
            if($pos >= '1'){
                $isonline = True;
            }
        }
        if(isset($inUser4)){
            $pos = strrpos($refined, $inUser4);
            if($pos >= '1'){
                $isonline = True;
            }
        }
        
        
        if(!$isonline){
        #the return attribute indicates what sort of thing is being sent back to the requester, e.g. an image or an URL.
            if($inReturn == 'link'){ #the user asked for this link to be given if they are online
                echo "<meta http-equiv='REFRESH' content='0;url=" . $inOnline .  "'>"; #auto-redirect to requested page.
            }
            if($inReturn != 'link'){ #the user didn't want a link, rather an image.
                echo file_get_contents($offline);  #the image they specified above is returned to the requestee.
                header("Content-Type: image/gif");
            }
        }
        if($isonline){
            if($inReturn == 'link'){
                echo "<meta http-equiv='REFRESH' content='0;url=" . $inOffline .  "'>";
            }
            if($inReturn != 'link'){
                echo file_get_contents($online);
                header("Content-Type: image/gif");
            }
        }
    }
    if($action == 'projects'){ #the following API section looks at a user's projects and return information about them.
        if($type == 'newest'){ #looking at the n'th newest project
            $page = ltrim(file_get_contents('http://scratch.mit.edu/api/getprojectsbyusername/' . $inUser)); #this pulls all the project id's belonging to a user into the API.
            $count = '0';
            $placeholder = '0';
            while ($count < $_GET['num'] - '1'){ #this finds the project id for the n'th newest project. n'th being set by the num parameter.
                $placeholder = strpos($page, ':', $placeholder + '1');
                $count ++;
            }
            if($count > 0){
                $placeholder++;
            }
            $endplaceholder = strpos($page, ':', $placeholder + 1);
            if($inReturn == 'image'){ #the user wants a thumbnail of their project returned.
            #echo "<img src = 'http://scratch.mit.edu/static/projects/" . $inUser . "/" . substr($page, $placeholder, $endplaceholder - $placeholder) . "_sm.png' />"; < this echoes the image rather than the file. For glitch testing.
            echo file_get_contents('http://scratch.mit.edu/static/projects/' . $inUser . '/' . substr($page, $placeholder, $endplaceholder - $placeholder) . '_sm.png');
            header("Content-Type: image/gif");
            }
            if($inReturn == 'link'){ # the user wants a link to their n'th project.
                $user = $inUser;
                $project = substr($page, $placeholder, $endplaceholder - $placeholder);
                echo "<meta http-equiv='REFRESH' content='0;url=http://scratch.mit.edu/projects/" . $user . "/" . $project .  "'>"; #auto-redirect to requested project page.
            }
            if($inReturn == 'text'){ #the user wants the name of their n'th project.
                $project = substr($page, $placeholder, $endplaceholder - $placeholder);
                $page = ltrim(file_get_contents('http://scratch.mit.edu/api/getprojectinfobyid/' . $project)); #getinfobyprojectid is a page on the Scratch site that lists everything about a chosen project.
                $text = strpos($page, ':', 1);
                $text ++;
                $text = substr($page, $text, strpos($page, ':', $text + 1) - 7); #each piece of information is seperated by a : (colon) so all this is just filtering through the colons until it reaches the right one.
                $text = str_replace("%20","_",$text);
                echo file_get_contents('http://www.blocks.scratchr.org/textrender.php?string=' . $text . $extraText);
                header("Content-Type: image/gif");
            }
            if($inReturn == 'loves'){ # the user wants the number of loves of their n'th project
                $project = substr($page, $placeholder, $endplaceholder - $placeholder);
                $page = ltrim(file_get_contents('http://scratch.mit.edu/api/getprojectinfobyid/' . $project));
                $startlove = nth_position($page, ':', 6) + 1;
                $page = substr($page, $startlove, strlen($page));
                $startlove = nth_position($page, ':', 1) + 1;
                $page =  substr($page, 0, $startlove - 1);
                echo file_get_contents('http://www.blocks.scratchr.org/textrender.php?string=' . $page . $extraText);
                header("Content-Type: image/gif");
            }
            if($inReturn == 'faves'){ #the user wants the number of favouriters of their n'th project
                $project = substr($page, $placeholder, $endplaceholder - $placeholder);
                $page = ltrim(file_get_contents('http://scratch.mit.edu/api/getprojectinfobyid/' . $project));
                $startlove = nth_position($page, ':', 7) + 1;
                $page = substr($page, $startlove, strlen($page));
                $startlove = nth_position($page, ':', 1) + 1;
                $page =  substr($page, 0, $startlove - 1);
                echo file_get_contents('http://www.blocks.scratchr.org/textrender.php?string=' . $page . $extraText);
                header("Content-Type: image/gif");
            }
            if($inReturn == 'comments'){ #the user wants the number of comments of their n'th project
                $project = substr($page, $placeholder, $endplaceholder - $placeholder);
                $page = ltrim(file_get_contents('http://scratch.mit.edu/api/getprojectinfobyid/' . $project));
                $startlove = nth_position($page, ':', 12) + 1;
                $page = substr($page, $startlove, strlen($page));
                $startlove = nth_position($page, ':', 1) + 1;
                $page =  substr($page, 0, $startlove - 1);
                echo file_get_contents('http://www.blocks.scratchr.org/textrender.php?string=' . $page . $extraText);
                header("Content-Type: image/gif");
            }
            if($inReturn == 'remixes'){ #the user wants the number of remixes of their n'th project
                $project = substr($page, $placeholder, $endplaceholder - $placeholder);
                $page = ltrim(file_get_contents('http://scratch.mit.edu/api/getprojectinfobyid/' . $project));
                $startlove = nth_position($page, ':', 8) + 1;
                $page = substr($page, $startlove, strlen($page));
                $startlove = nth_position($page, ':', 1) + 1;
                $page =  substr($page, 0, $startlove - 1);
                echo file_get_contents('http://www.blocks.scratchr.org/textrender.php?string=' . $page . $extraText);
                header("Content-Type: image/gif");
            }
            if($inReturn == 'downloads'){ # the user wants the number of downloads of their n'th project
                $project = substr($page, $placeholder, $endplaceholder - $placeholder);
                $page = ltrim(file_get_contents('http://scratch.mit.edu/api/getprojectinfobyid/' . $project));
                $startlove = nth_position($page, ':', 13) + 1;
                $page = substr($page, $startlove, strlen($page));
                echo file_get_contents('http://www.blocks.scratchr.org/textrender.php?string=' . $page . $extraText);
                header("Content-Type: image/gif");
            }
            if($inReturn == 'views'){ # The user wants the number of views for their n'th project
                $project = substr($page, $placeholder, $endplaceholder - $placeholder);
                $page = ltrim(file_get_contents('http://scratch.mit.edu/projects/' . $_GET['user'] . '/' . $project));
                $viewStart = strrpos($page, '<!-- ::: Begin viewers, lovers, taggers and favoriters ::: -->') + 71;
                $viewEnd = strrpos($page, 'views, <a href') - 1;
                $page = substr($page, $viewStart, $viewEnd - $viewStart);
                echo file_get_contents('http://www.blocks.scratchr.org/textrender.php?string=' . $page . $extraText);
                header("Content-Type: image/gif");
            }
        }
        if($type == 'least'){ #this type will return the project witth the least number of.... loves/faves/views etc.
            $page = 'http://scratch.mit.edu/api/getprojectsbyusername/' . $_GET['user'];
            $numberOfProjects = substr_count(file_get_contents($page), ':', 0) + 1;
            $projectcount = 1;
            if($inReturn == 'views'){
                $start = nth_position($page, ':', $count) + 1;
                $end = nth_position($page, ':', $count + 1) + 1;
                
            }
        }
    }
    if($action == 'friends'){ #Thanks to SeptimusHeap for this section
        if($type == 'newest'){
            $page = ltrim(file_get_contents('http://scratch.mit.edu/api/getfriendsbyusername/' . $inUser));
            $count = '0';
            $placeholder = '0';
            while ($count < $_GET['num'] - '1'){
                $placeholder = strpos($page, ':', $placeholder + '1');
                $count ++;
            }
            if($count > 0){
                $placeholder++;
            }
            $endplaceholder = strpos($page, ':', $placeholder + 1);
            if($inReturn == 'image'){
            #echo "<img src = 'http://scratch.mit.edu/static/icons/buddy/" . substr($page, $placeholder, $endplaceholder - $placeholder) . "_sm.png' />"; < this echoes the image rather than the file. For glitch testing.
            echo file_get_contents('http://scratch.mit.edu/static/icons/buddy/' . substr($page, $placeholder, $endplaceholder - $placeholder) . '_sm.png');
            header("Content-Type: image/gif");
        }
            if($inReturn == 'link'){
                $user = $inUser;
                $userguy = substr($page, $placeholder, $endplaceholder - $placeholder);
                echo "<meta http-equiv='REFRESH' content='0;url=http://scratch.mit.edu/api/getuser/" . $userguy .  "'>";
            }
        }
    }
    if($action == 'text'){
        echo file_get_contents('http://blocks.scratchr.org/textrender.php?string=' . $_GET['string'] . $extraText);
        header("Content-Type: image/gif");
    }
    if($action == 'random'){
        $numberOfLinks = 0;
        if(isset($_GET['link1'])){
            $numberOfLinks ++;
        }
        if(isset($_GET['link2'])){
            $numberOfLinks ++;
        }
        if(isset($_GET['link3'])){
            $numberOfLinks ++;
        }
        if(isset($_GET['link4'])){
            $numberOfLinks ++;
        }
        if(isset($_GET['link5'])){
            $numberOfLinks ++;
        }
        if(isset($_GET['link6'])){
            $numberOfLinks ++;
        }
        if(isset($_GET['link7'])){
            $numberOfLinks ++;
        }
        if(isset($_GET['link8'])){
            $numberOfLinks ++;
        }
        if(isset($_GET['link9'])){
            $numberOfLinks ++;
        }
        if(isset($_GET['link10'])){
            $numberOfLinks ++;
        }
        if($numberOfLinks > 0){
            $url = rand(1, $numberOfLinks);
            if($inReturn == 'image'){
                echo file_get_contents($_GET['link' . $url]);
                header("Content-Type: image/gif");
            }
            if($inReturn == 'link'){
                echo "<meta http-equiv='REFRESH' content='0;url=" . $_GET['link' . $url] .  "'>";
            }
        }
    }
}
if(!isset($action)){
echo "<p>Sorry, you've not set the action parameter, I don't know what to do! For documentation on this API look <a href = 'http://scratch.mit.edu/forums/viewtopic.php?id=69113&p=1'>here</a>";
}
?>

___________________________________________________________________________________
Generator
The current source code for comp500's generator can be downloaded here.
___________________________________________________________________________________
Text renderer
V 1.1
~Added “_” to “ ”(space) converter.
V 1.2
~ Added complete text image control for current settings.
V2.0
~ Added background-image options (thanks to LS97 for the help there)
Code:

Editor wrote:

Again. This might have the not working code in

<?PHP
//parser in spaces
$count = 1;
$string = str_replace("_"," ",$_GET['string']);
if(isset($_GET['bgimage']) && strstr($_GET['bgimage'], ".png")){ #thanks to LS97 for making most of the bgimage attribute!
    // create the background
    $img = imagecreatefrompng($_GET['bgimage']);
    
    //chooses the text color
        if(isset($_GET['textr']) | isset($_GET['textg']) | isset($_GET['textb'])){
        $red = (int)$_GET['textr'];
        $green = (int)$_GET['textg'];
        $blue = (int)$_GET['textb'];
        $text_colour = imagecolorallocate($img, $red, $blue, $green);
    }
    else{
        $text_colour = imagecolorallocate($img, 0, 0, 0);
    }
    
    // get the font
    $font = realpath('Trebuchet_MS.ttf');
    
    // print the string
    $xpos = 5;
    if(isset($_GET['xpos'])){
        $xpos = $_GET['xpos'];
    }
    $ypos = 20;
    if(isset($_GET['ypos'])){
        $ypos = $_GET['ypos'];
    }
    imagettftext($img, 13, 0, $xpos, $ypos, $text_colour, $font, $string);
    
    // tell browser about content type
    header( 'Content-type: image/png' );
    // create image
    imagepng( $img );
}
if(!isset($_GET['bgimage'])){
    // Set font size
    $font_size = 2;
    if(isset($_GET['font_size'])){
        $font_size = $_GET['font_size'];
    }
    $font = '/fonts/Trebuchet_MS.ttf';
    if(isset($_GET['font'])){
        $font = $_GET['font'];
    }
    // Create image width dependant on width of the string
    $width  = imagefontwidth($font_size)*strlen($string);
    if(isset($_GET['width'])){
        $width = $_GET['width'];
    }
    // Set height to that of the font
    $height = imagefontheight($font_size);
    if(isset($_GET['height'])){
        $height = $_GET['height'];
    }
    // Create the image pallette
        $img = imagecreate($width,$height);
        if(isset($_GET['bgr']) | isset($_GET['bgg']) | isset($_GET['bgb'])){
            $red = (int)$_GET['bgr'];
            $blue = (int)$_GET['bgg'];
            $green = (int)$_GET['bgb'];
            $bg    = imagecolorallocate($img, $red, $blue, $green);
        }
        else{
            $bg    = imagecolorallocate($img, 222, 223, 223);
        }
    // Font color
    if(isset($_GET['textr']) | isset($_GET['textg']) | isset($_GET['textb'])){
        $red = (int)$_GET['textr'];
        $green = (int)$_GET['textg'];
        $blue = (int)$_GET['textb'];
        $color = imagecolorallocate($img, $red, $blue, $green);
    }
    else{
        $color = imagecolorallocate($img, 0, 0, 0);
    }
    // Length of the string
    if(isset($_GET['limitstring'])){
        if(strlen($string) > $_GET['limitstring']){
            $string= substr($string, 0, $_GET['limitstring']);
        }
    }
    $len = strlen($string);
    // Y-coordinate of character, X changes, Y is static
    $ypos = 0;
    if(isset($_GET['ypos'])){
        $ypos = $_GET['ypos'];
    }
    // Loop through the string
    for($i=0;$i<$len;$i++){
        // Position of the character horizontally
        if(isset($_GET['xpos'])){
            $xpos = $i * imagefontwidth($font_size) + $_GET['xpos'];
        }
        else{
            $xpos = $i * imagefontwidth($font_size);
        }
        // Draw character
        imagechar($img, $font_size, $xpos, $ypos, $string, $color);
        // Remove character from string
        $string = substr($string, 1);   
    
    }
    // Return the image
    header("Content-Type: image/gif");
    imagegif($img);
}
// Remove image
imagedestroy($img);
?>




Random

Random images
This API randomly selects one of up to ten images to display with every page refresh. This works very well for sigs where a user wants a random message or picture shown. For example, this image will randomly change whenever you refresh the page:

Action value:

random

Return value:

image

Parameters:

link1

Code:

[img]http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=IMAGELINK1&link2=IMAGELINK2[/img]

___________________________________________________________________________________
Random links
This API attribute will link randomly to one of up to ten pages. You can follow the link more than once without refreshing the page and you will still be taken randomly to a different page each time. for example, this link will either take you to the google homepage or the Scratch homepage.

Action value:

random

Return value:

link

Parameters:

link1

Code:

[url=http://www.blocks.scratchr.org/API.php?action=random&return=link&link1=LINK1URL&link2=LINK2URL]LINKTEXT/IMAGE[/url]



Customising text returns

The API text return allows changing information about projects and people to be displayed as an image http://www.blocks.scratchr.org/API.php?action=text&amp;string=like_this!

The standard return above is designed to fit in with the rest of the fora as unobtrusive. However, should you wish to make a text return fit your signature colour scheme at all the grey background and black text simply won't do. This post lists all the additional attributes you can apply to both the text and the background of a text return.

Each attribute is simply added to the URL with an & between each one. For example &width=30&height=30. NEVER use spaces or the image won't show!.

Background attributes

Background size
parameters:

height, width

Notes: Both height and width are set in pixels and may only be whole numbers (integers). If only width is set the height will still snap to that of the font size and visa versa if width is set, not height.
http://www.blocks.scratchr.org/API.php?action=text&amp;string=example&amp;height=60&amp;width=100&amp;bgr=200&amp;bgg=200&amp;bgb=200 (colour slightly changed for clarification).
Code:



Background colour
parameters:

bgr, bgg, bgb

Notes: The background colour can be set using red, green and blue component values. Each can be set to a number from 0 to 255. bgr is red, bgg is green and bgb is blue. A good colour picker that shows you the RGB values of a colour can be found here.

If bgr, bgg and bgb are all unset, the background will revert to the standard forum grey (R=222 G=223 B=223). If you are setting one or two of the three values to 0 you can just leave them unset. So rather than sending &bgr=0&bgg=0&bgb=0 to get black you can just send &bgr=0 as the other two are assumed to be 0 too. In the same way, red can be sent as just &bgr=255.
http://www.blocks.scratchr.org/API.php?action=text&amp;string=example&amp;bgr=255&amp;bgg=255 (R:255 G:255 B:0)
Code:

Last edited by QuillzToxic (Feb. 17, 2014 11:00:01)

QuillzToxic
Scratcher
1000+ posts

[API] Scratch Image Utlility API

This is reserved
QuillzToxic
Scratcher
1000+ posts

[API] Scratch Image Utlility API

And so is this
QuillzToxic
Scratcher
1000+ posts

[API] Scratch Image Utlility API

The Last Reserved Post
QuillzToxic
Scratcher
1000+ posts

[API] Scratch Image Utlility API

Bump
scimonster
Scratcher
1000+ posts

[API] Scratch Image Utlility API

The code is messed up; please use the [code] tag instead of [quote].

Retired Community Moderator
BTW, i run Google Chrome 41.0.2272.101 on a Linux system - Ubuntu 14.04. NEW: iPad 4th gen. w/retina.

418 I'm a teapot (original - to be read by bored computer geeks)
THE GAME (you just lost)
; THE SEMICOLON LIVES ON IN OUR SIGS
QuillzToxic
Scratcher
1000+ posts

[API] Scratch Image Utlility API

scimonster wrote:

The code is messed up; please use the [code] tag instead of [quote].
It existes?
gravtest
Scratcher
100+ posts

[API] Scratch Image Utlility API

QuillzToxic wrote:

scimonster wrote:

The code is messed up; please use the [code] tag instead of [quote].
It existes?
Yup, also, you can use
code=php
to enable syntax highlighting for PHP.

Last edited by gravtest (Feb. 17, 2014 10:54:43)


QuillzToxic
Scratcher
1000+ posts

[API] Scratch Image Utlility API

gravtest wrote:

QuillzToxic wrote:

scimonster wrote:

The code is messed up; please use the [code] tag instead of [quote].
It existes?
Yup, also, you can use
code=php
to enable syntax highlighting for PHP.
Im doin dat Now!

Powered by DjangoBB