Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Viewer 2 SVG_Scalable_Vector_Graphics_in_Sha  

SVG_Scalable_Vector_Graphics_in_Sha

Example website: http://tutorials.jenkov.com/svg/index.html

The demo script below, adapted from the Notecard on a Prim script, reads a notecard with SVG elements and puts it in the URL. This is limited to 1024 characters. Remember to create a notecard inside the prim for this to work.

Unfortunately, SVG is more trickier to handle when trying to embed it into a web page via the same prim. Using the other techniques like Ajax to increase the size is running into problems. To embed SVG into a page requires the use of the Object / Embed tags. It has no problems linking to an external website with the SVG file. But trying to reference a prim via HTTP-In to get the SVG code, is not working at all. The only way around that I can see would be to have IFrames and embed the "Data:image/svg+xml" Mime type encoding of the SVG in the Iframe source path.

Category: Viewer 2
By : Pavcules Superior
Created: 2010-09-02 Edited: 2010-09-02
Worlds: Second Life

the Zip file

Download all files for SVG_Scalable_Vector_Graphics_in_Sha
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. SVG_Scalable_Vector_Graphics_in_Sha_1.lsl
Get file # 2. SVG_Scalable_Vector_Graphics_in_Sha_2.lsl
1 // SVG on a Prim
2 // Developed by: Pavcules Superior
3 // Developed on: March 2010
4
5 string g_strNotecardName;
6 string g_strNotecardText;
7 integer g_intNotecardLine = 0;
8 key g_keyNotecardQueryID;
9 key g_keyURLRequestID;
10
11
12 // Start reading the notecard text.
13 ReadNotecardText()
14 {
15 llOwnerSay("Reading Notecard...please wait.");
16
17 g_intNotecardLine = 0;
18 g_strNotecardText = "";
19 g_strNotecardName = llGetInventoryName(INVENTORY_NOTECARD, 0);
20 g_keyNotecardQueryID = llGetNotecardLine(g_strNotecardName, g_intNotecardLine);
21
22 // Change the URL
23 llSetPrimMediaParams(0,[ PRIM_MEDIA_CURRENT_URL, "data:text/plain,Loading Page...Please Wait..." + (string)llGetUnixTime()]);
24
25 }
26
27
28 default
29 {
31 {
32
33 ReadNotecardText();
34
35 g_keyURLRequestID = llRequestURL();
36
37 }
38
39 changed(integer change)
40 {
41 // If the inventory is updated, read the notecard data again.
42 if(change & CHANGED_INVENTORY)
43 {
44 ReadNotecardText();
45 }
46 }
47
48
49 dataserver(key query_id, string data)
50 {
51 if(query_id == g_keyNotecardQueryID)
52 {
53 if(data != EOF)
54 {
55 // Store the text.
56 g_strNotecardText += data;
57
58 // Read next notecard line.
59 ++g_intNotecardLine;
60 g_keyNotecardQueryID = llGetNotecardLine(g_strNotecardName, g_intNotecardLine);
61 }
62 else
63 {
64 // We have reached the end of the notecard.
65 llOwnerSay("Size: " + (string)llStringLength(g_strNotecardText));
66 llOwnerSay("Rendering Media image...please wait.");
67
68 // Refresh the URL again by setting a random URL parameter value.
69 llSetPrimMediaParams(0,
70 [PRIM_MEDIA_AUTO_PLAY,TRUE,
71 PRIM_MEDIA_CURRENT_URL,"data:image/svg+xml," + g_strNotecardText,
72 PRIM_MEDIA_HEIGHT_PIXELS,1024,
73 PRIM_MEDIA_WIDTH_PIXELS,1024]);
74
75 }
76 }
77 }
78
79 }

SVG_Scalable_Vector_Graphics_in_Sha

Notecard used in showing that picture:

Category: Viewer 2
By : Pavcules Superior
Created: 2010-09-02 Edited: 2010-09-02
Worlds: Second Life

1 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >
2 <polyline points="0,0 0,500 500,250" style="stroke: #000000; stroke-width: 1; fill:#339933;" />
3 <circle cx="150" cy="750" r="100" style="stroke: #000000; stroke-width: 10; fill: #aaaaaa;" />
4 <ellipse cx="600" cy="600" rx="150" ry="250" style="stroke: #000000; stroke-width: 2; fill: #ffaaaa;" />
5 <rect x="800" y="50" width="100" height="600" rx="2" ry="2" style="stroke: #000000; stroke-width: 1; fill: #000088;" />
6 <text x="20" y="200" style="stroke: #000000;fill: #66ee66;font-family:Arial;font-size: 150px;">
7 Hello There</text>
8 <text x="200" y="400" style="stroke: #000000;fill: #ff0000;font-family:Arial;font-size: 125px;" transform="translate(250) rotate(45 50 50)">
9 A demo of SVG</text>
10 </svg>

Back to the Best Free Tools in Second Life and OpenSim.