WebGL:WordPress
From Wiki.cyring.fr
(Difference between revisions)
(→functions.php) |
|||
Line 5: | Line 5: | ||
function gPrimitive( $atts ) { | function gPrimitive( $atts ) { | ||
extract(shortcode_atts(array( | extract(shortcode_atts(array( | ||
- | ' | + | 'id' => 'canvas.00000000', |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
'style' => '', | 'style' => '', | ||
'width' => '640', | 'width' => '640', | ||
Line 42: | Line 16: | ||
$main = '<script type="text/javascript">' | $main = '<script type="text/javascript">' | ||
- | . 'main("' . $ | + | . 'main("' . $id . '",' . $rgba . ');' |
. '</script>'; | . '</script>'; | ||
$output = sprintf( '%s<canvas id="%s" style="%s" width="%s" height="%s"></canvas>%s', | $output = sprintf( '%s<canvas id="%s" style="%s" width="%s" height="%s"></canvas>%s', | ||
- | $output, | + | $output, $id, $style, $width, $height, $main ); |
return($output); | return($output); | ||
} | } |
Revision as of 23:07, 9 February 2013
functions.php
<?php
function gPrimitive( $atts ) {
extract(shortcode_atts(array(
'id' => 'canvas.00000000',
'style' => '',
'width' => '640',
'height' => '540',
'rgba' => '0.0, 0.0, 0.0, 1.0'), $atts));
$output = '<script type="text/javascript" src="' . get_stylesheet_directory_uri() . '/glMatrix-min.js"></script>'
. '<script type="text/javascript" src="' . get_stylesheet_directory_uri() . '/primitive.js"></script>';
$main = '<script type="text/javascript">'
. 'main("' . $id . '",' . $rgba . ');'
. '</script>';
$output = sprintf( '%s<canvas id="%s" style="%s" width="%s" height="%s"></canvas>%s',
$output, $id, $style, $width, $height, $main );
return($output);
}
function twentyten_setup() {
add_shortcode( 'primitive', 'gPrimitive' );
}
?>