SVG-oriented Services - part #3
C'est quoi ?a?

SVG-oriented Services - part #3

Reminder

I've given you illustrations of a pie chart, an analog watch, a column chart, a radar chart, a burndown chart, I've shown you that there are documented (and FREELY accessible) services, I've shown you how to create an n-branched star, and how to create an n-pointed flower, how to create a sign with text centered and rotated, potentially at a certain angle, how to create a regular polygon, with or without canvas, I've shown you how to combine 2 services (polygon and arrow) to create an SVG that combines the two services. Not bad at all.

Now let's add a service to create a circle (illustrated in this article) and how to create a rectangle.

This won't take long!

Circle

https://trql.fm/test.circle.service.php?svg-width=1024&svg-height=1024&fill=orange&stroke=yellow&stroke-width=25        

Try it for yourself: https://trql.fm/test.circle.service.php?svg-width=1024&svg-height=1024&fill=orange&stroke=yellow&stroke-width=25

And what's the code of test.circle.service.php?

<?php
use \trql\vaesoli\Vaesoli   as v;
if ( ! defined( 'VAESOLI_CLASS_VERSION' ) )
    require_once( '/home/vaesoli/snippet-center/trql.vaesoli.class.php' );

$url        = "https://www.trql.fm/vaesoli!/?svg-circle";
$params[]   = 'svg-width';
$params[]   = 'svg-height';
$params[]   = 'x';
$params[]   = 'y';
$params[]   = 'radius';
$params[]   = 'fill';
$params[]   = 'stroke';
$params[]   = 'stroke-width';
foreach( $params as $param )
{
    if ( isset( $_GET[ $param ] ) )
        $url .= "&{$param}=" . urlencode( $_GET[ $param ] );
}   /* foreach( $params as $param ) */
$url .= "&id=mySVG";
$svgFile = str_replace( array( 'test.','.service' ),'',basename( FILE,'.php' ) . '.svg' );
$json   = v::HTTP_GetURL( $url );
if ( $result = json_decode( $json ) )
{
    echo $result->payload->svg;
    echo "<div class=\"call\" style=\"width:512px;\">\n";
    echo "<p style=\"text-align:center;\"><a href=\"{$url}\" target=\"_blank\">{$url}</a></p>\n";
    echo "</div> <!-- .call -->\n";
    echo "<div style=\"width:512px;\">\n";
        echo "<p style=\"text-align:center;\"><a href=\"data:image/svg+xml,\" download=\"{$svgFile}\" onclick=\"return copy( this,'mySVG' );\">Download</a></p>\n";
    echo "</div>";
    echo "<div>\n";
        echo "<h3>Parameters</h3>\n";
        foreach( $params as $param )
        {
            echo "<p>?{$param}=&lt;...&gt;</p>\n";
        }
    echo "</div>";
}
else
{
    echo "<p>Invalid result</p>";
}
?>
<script>
    function copy( a,id )
    {
        console.log( a );
        let svg;
        svg = document.getElementById(id).outerHTML;
        svg = svg.replace( /"/g,"'" );
        svg = svg.replace( /#/g,"%23" );
        a.setAttribute( "href","data:image/svg+xml," + svg );
        console.log( a.getAttribute( "href" ) ); 
        return ( true );
    }
</script>        

Rectangle

https://trql.fm/test.rectangle.service.php?svg-width=1024&svg-height=1024        

Conclusion

Tomorrow, we will add to our list of services (1) the ability to create SVG text (2) the ability to create a check-mark and (3) the ability to create a smiley face. And we will have reached 10 SVG services.

No fuss, friends !




要查看或添加评论,请登录

Patrick Boens的更多文章

  • Forging a ChatBot in the Digital Wilderness

    Forging a ChatBot in the Digital Wilderness

    In the relentless landscape of technological evolution, silence is not the absence of action—it is the crucible of…

  • AI Scanning an Invoice

    AI Scanning an Invoice

    This new issue, dedicated to ChatGPT and Sermo (my programming gateway to ChatGPT, Perplexity, and Claude 3.5 Sonnet)…

  • Software Engineers and AI

    Software Engineers and AI

    Through numerous articles written on the subject of artificial intelligence in the context of digital transformations…

  • Using templates to mimic sophisticated object

    Using templates to mimic sophisticated object

    The Power of Templates in IllicoDB3: Revolutionizing Database Structure In the realm of traditional databases, the…

  • More, Faster, Easier...

    More, Faster, Easier...

    In my previous article, I showed you how to create a small todo management app in record time. Now, based on this first…

  • AI at the Developers' Bedside

    AI at the Developers' Bedside

    Let's dive into the world of AI-powered app creation, showcasing just how effortless it can be to bring your ideas to…

    1 条评论
  • AI and IT

    AI and IT

    Here's the question I asked to "Sonar Huge", the AI model of Perplexity.ai: With the advent of AI taking by storm the…

  • The Imperative of AI in Digital Transformation Projects: A Wake-Up Call for Businesses

    The Imperative of AI in Digital Transformation Projects: A Wake-Up Call for Businesses

    In today's rapidly evolving digital landscape, companies that continue to approach their digital transformation and…

  • Data Migration Projects

    Data Migration Projects

    "Mise en bouche" My first interesting encounter with a data migration project dates back to 1999. The tech world was…

  • IllicoDB3 and AI

    IllicoDB3 and AI

    I have mentioned in the past that IllicoDB3 allows the use of artificial intelligence to generate code related to…

社区洞察

其他会员也浏览了