Author Topic: Built-in function to loads SVG image format?  (Read 3734 times)

0 Members and 1 Guest are viewing this topic.

Offline ForSe

  • Newbie
  • Posts: 6
    • View Profile
Built-in function to loads SVG image format?
« on: February 09, 2019, 05:31:07 am »
It would be good if QB64 has one.

Any possibility to add one in the future?

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Built-in function to loads SVG image format?
« Reply #1 on: February 09, 2019, 09:46:56 am »
Hi! I don't know whether QB64 developer will add this feature or not but for now, you can code your own function to load SVG files.
Oh! I think Fellippe have already done one.....
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Built-in function to loads SVG image format?
« Reply #2 on: February 09, 2019, 09:47:57 am »
Okay, So I found Fellippe's code in my QB64 code archive. :D
Code: QB64: [Select]
  1. 'Simple SVG reader for QB64
  2. 'Fellippe Heitor, 2017
  3. 'A lot of code borrowed as indicated in the comments.
  4. '----------------------------------------------------
  5. IF LEN(COMMAND$) THEN f$ = COMMAND$ ELSE f$ = "wikisample.svg"
  6. IF _FILEEXISTS(f$) = 0 THEN PRINT "File "; f$; " not found.": END
  7.  
  8. thisScreen& = _NEWIMAGE(800, 600, 32)
  9. SCREEN thisScreen&
  10. CLS , GetColor("white", 1)
  11.  
  12. DIM Total AS LONG
  13.     IF EOF(1) THEN EXIT DO
  14.     LINE INPUT #1, l0$
  15.     l$ = RTRIM$(LTRIM$(LCASE$(l0$)))
  16.  
  17.     DO
  18.         IF RIGHT$(l$, 1) = ">" THEN 'fetch more lines until we close the current tag
  19.             EXIT DO
  20.         ELSE
  21.             IF EOF(1) THEN EXIT DO
  22.             LINE INPUT #1, l2$
  23.             l0$ = l0$ + l2$
  24.             l$ = l$ + RTRIM$(LTRIM$(LCASE$(l2$)))
  25.         END IF
  26.     LOOP
  27.  
  28.     sp = INSTR(l$, " ")
  29.     IF sp = 0 THEN
  30.         IF l$ = "</svg>" THEN
  31.             EXIT DO
  32.         END IF
  33.     END IF
  34.  
  35.     Style$ = FindS(l$, "style")
  36.     IF LEN(Style$) THEN
  37.         FillOpacity! = 1
  38.         StrokeOpacity! = 1
  39.         IF INSTR(Style$, "fill-opacity") THEN
  40.             FillOpacity! = Find2(Style$, "fill-opacity")
  41.         ELSEIF INSTR(Style$, "opacity") THEN
  42.             FillOpacity! = Find2(Style$, "opacity")
  43.         END IF
  44.         IF INSTR(Style$, "stroke-opacity") THEN
  45.             StrokeOpacity! = Find2(Style$, "stroke-opacity")
  46.         ELSEIF INSTR(Style$, "opacity") THEN
  47.             StrokeOpacity! = Find2(Style$, "opacity")
  48.         END IF
  49.  
  50.         Fill$ = FindS2(Style$, "fill")
  51.         FillColor~& = GetColor(Fill$, FillOpacity!)
  52.         Stroke~& = GetColor(FindS2(Style$, "stroke"), StrokeOpacity!)
  53.         StrokeWidth% = Find2(Style$, "stroke-width")
  54.     ELSE
  55.         Fill$ = FindS(l$, "fill")
  56.         FillColor~& = GetColor(Fill$, 1)
  57.         Stroke~& = GetColor(FindS(l$, "stroke"), 1)
  58.         StrokeWidth% = Find(l$, "stroke-width")
  59.     END IF
  60.  
  61.     SELECT CASE LEFT$(l$, sp - 1)
  62.         CASE "<svg"
  63.             width% = Find(l$, "width")
  64.             height% = Find(l$, "height")
  65.             IF width% > 0 AND height% > 0 THEN
  66.                 newScreen& = _NEWIMAGE(width%, height%, 32)
  67.                 SCREEN newScreen&
  68.                 _PRINTMODE _KEEPBACKGROUND
  69.                 CLS , GetColor("white", 1)
  70.                 _FREEIMAGE thisScreen&
  71.                 thisScreen& = newScreen&
  72.             END IF
  73.         CASE "<rect"
  74.             Total = Total + 1
  75.             x! = Find(l$, "x")
  76.             y! = Find(l$, "y")
  77.             width% = Find(l$, "width")
  78.             height% = Find(l$, "height")
  79.  
  80.             IF Fill$ <> "none" THEN
  81.                 IF INSTR(l$, "rx=") THEN
  82.                     rx! = Find(l$, "rx")
  83.                     RoundRectFill x!, y!, x! + width% - 1, y! + height% - 1, rx!, FillColor~&
  84.                 ELSE
  85.                     LINE (x!, y!)-STEP(width% - 1, height% - 1), FillColor~&, BF
  86.                 END IF
  87.             END IF
  88.  
  89.             IF INSTR(l$, "rx=") = 0 THEN
  90.                 LINE (x!, y!)-STEP(width% - 1, height% - 1), Stroke~&, B
  91.                 FOR i = 1 TO ((StrokeWidth% - 1) / 2)
  92.                     LINE (x! - i, y! - i)-STEP(width% + (i * 2) - 1, height% + (i * 2) - 1), Stroke~&, B
  93.                 NEXT
  94.             END IF
  95.         CASE "<circle"
  96.             Total = Total + 1
  97.             cx! = Find(l$, "cx")
  98.             cy! = Find(l$, "cy")
  99.             r! = Find(l$, "r")
  100.  
  101.             IF Fill$ <> "none" THEN
  102.                 CircleFill cx!, cy!, r!, FillColor~&
  103.             END IF
  104.  
  105.             CIRCLE (cx!, cy!), r!, Stroke~&
  106.         CASE "<ellipse"
  107.             Total = Total + 1
  108.             cx! = Find(l$, "cx")
  109.             cy! = Find(l$, "cy")
  110.             rx! = Find(l$, "rx")
  111.             ry! = Find(l$, "ry")
  112.  
  113.             IF ry! > rx! THEN SWAP ry!, rx!
  114.  
  115.             IF Stroke~& = 0 THEN Stroke~& = FillColor~&
  116.  
  117.             CIRCLE (cx!, cy!), rx!, Stroke~&, , , ry! / rx!
  118.  
  119.             IF Fill$ <> "none" THEN
  120.                 PAINT (cx!, cy!), FillColor~&, Stroke~&
  121.             END IF
  122.         CASE "<polyline"
  123.             Total = Total + 1
  124.             Points$ = FindS(l$, "points")
  125.  
  126.             sp = INSTR(Points$, " ")
  127.             comma = INSTR(Points$, ",")
  128.             x1! = VAL(LEFT$(Points$, comma - 1))
  129.             IF sp THEN
  130.                 y1! = VAL(MID$(Points$, comma + 1, sp - comma))
  131.                 Points$ = MID$(Points$, sp + 1)
  132.             ELSE
  133.                 y1! = VAL(MID$(Points$, comma + 1))
  134.                 Points$ = ""
  135.             END IF
  136.  
  137.             DO WHILE LEN(Points$)
  138.                 sp = INSTR(Points$, " ")
  139.                 comma = INSTR(Points$, ",")
  140.                 x2! = VAL(LEFT$(Points$, comma - 1))
  141.                 IF sp THEN
  142.                     y2! = VAL(MID$(Points$, comma + 1, sp - comma))
  143.                 ELSE
  144.                     y2! = VAL(MID$(Points$, comma + 1))
  145.                 END IF
  146.  
  147.                 fline x1!, y1!, x2!, y2!, Stroke~&, StrokeWidth%
  148.                 x1! = x2!
  149.                 y1! = y2!
  150.  
  151.                 IF sp THEN
  152.                     Points$ = MID$(Points$, sp + 1)
  153.                 ELSE
  154.                     Points$ = ""
  155.                 END IF
  156.             LOOP
  157.         CASE "<polygon"
  158.             Total = Total + 1
  159.             Points$ = FindS(l$, "points")
  160.  
  161.             sp = INSTR(Points$, " ")
  162.             comma = INSTR(Points$, ",")
  163.             x1! = VAL(LEFT$(Points$, comma - 1))
  164.             IF sp THEN
  165.                 y1! = VAL(MID$(Points$, comma + 1, sp - comma))
  166.                 Points$ = MID$(Points$, sp + 1)
  167.             ELSE
  168.                 y1! = VAL(MID$(Points$, comma + 1))
  169.                 Points$ = ""
  170.             END IF
  171.  
  172.             x! = x1!
  173.             y! = y1!
  174.  
  175.             DO WHILE LEN(Points$)
  176.                 sp = INSTR(Points$, " ")
  177.                 comma = INSTR(Points$, ",")
  178.                 x2! = VAL(LEFT$(Points$, comma - 1))
  179.                 IF sp THEN
  180.                     y2! = VAL(MID$(Points$, comma + 1, sp - comma))
  181.                 ELSE
  182.                     y2! = VAL(MID$(Points$, comma + 1))
  183.                 END IF
  184.  
  185.                 fline x1!, y1!, x2!, y2!, Stroke~&, StrokeWidth%
  186.  
  187.                 x1! = x2!
  188.                 y1! = y2!
  189.  
  190.                 IF sp THEN
  191.                     Points$ = MID$(Points$, sp + 1)
  192.                 ELSE
  193.                     Points$ = ""
  194.                 END IF
  195.             LOOP
  196.  
  197.             fline x1!, y1!, x!, y!, Stroke~&, StrokeWidth%
  198.  
  199.             PAINT (x!, y! + 3), FillColor~&, Stroke~&
  200.         CASE "<line"
  201.             Total = Total + 1
  202.             x1! = Find(l$, "x1")
  203.             y1! = Find(l$, "y1")
  204.             x2! = Find(l$, "x2")
  205.             y2! = Find(l$, "y2")
  206.  
  207.             fline x1!, y1!, x2!, y2!, Stroke~&, StrokeWidth%
  208.         CASE "<text"
  209.             Total = Total + 1
  210.             '<text x="0" y="15" fill="red">I love SVG!</text>
  211.             x! = Find(l$, "x")
  212.             y! = Find(l$, "y")
  213.  
  214.             closingTag% = INSTR(l0$, ">")
  215.             endTag% = INSTR(l0$, "</text>")
  216.             text$ = MID$(l0$, closingTag% + 1, endTag% - closingTag% - 1)
  217.  
  218.             COLOR FillColor~&
  219.             _PRINTSTRING (x!, y!), text$
  220.     END SELECT
  221. _TITLE "SVG:" + LTRIM$(STR$(Total)) + " instructions processed"
  222.  
  223. FUNCTION FindS$ (theline$, key$)
  224. line$ = LCASE$(theline$)
  225. TheKey% = INSTR(LCASE$(line$), LCASE$(key$) + "=" + CHR$(34))
  226. IF TheKey% THEN
  227.     TheKey% = TheKey% + LEN(key$) + 2
  228.     ClosingQuote% = INSTR(TheKey% + 1, line$, CHR$(34))
  229.     FindS = MID$(line$, TheKey%, ClosingQuote% - TheKey%)
  230.  
  231. FUNCTION FindS2$ (theline$, key$)
  232. line$ = LCASE$(theline$) + ";"
  233. TheKey% = INSTR(LCASE$(line$), LCASE$(key$) + ":")
  234. IF TheKey% THEN
  235.     TheKey% = TheKey% + LEN(key$) + 1
  236.     ClosingQuote% = INSTR(TheKey% + 1, line$, ";")
  237.     FindS2 = MID$(line$, TheKey%, ClosingQuote% - TheKey%)
  238.  
  239. FUNCTION Find## (theline$, key$)
  240. line$ = LCASE$(theline$)
  241. TheKey% = INSTR(LCASE$(line$), LCASE$(key$) + "=" + CHR$(34))
  242. IF TheKey% THEN
  243.     TheKey% = TheKey% + LEN(key$) + 2
  244.     ClosingQuote% = INSTR(TheKey%, line$, CHR$(34))
  245.     Find = VAL(MID$(line$, TheKey%, ClosingQuote% - TheKey%))
  246.  
  247. FUNCTION Find2## (theline$, key$)
  248. line$ = LCASE$(theline$) + ";"
  249. TheKey% = INSTR(LCASE$(line$), LCASE$(key$) + ":")
  250. IF TheKey% THEN
  251.     TheKey% = TheKey% + LEN(key$) + 1
  252.     ClosingQuote% = INSTR(TheKey%, line$, ";")
  253.     Find2 = VAL(MID$(line$, TheKey%, ClosingQuote% - TheKey%))
  254.  
  255. SUB RoundRectFill (x AS INTEGER, y AS INTEGER, x1 AS INTEGER, y1 AS INTEGER, r AS INTEGER, c AS _UNSIGNED LONG)
  256. 'This sub from _vincent at the #qb64 chatroom on freenode.net
  257. LINE (x, y + r)-(x1, y1 - r), c, BF
  258.  
  259. a = r
  260. b = 0
  261. e = -a
  262.  
  263. DO WHILE a >= b
  264.     LINE (x + r - b, y + r - a)-(x1 - r + b, y + r - a), c, BF
  265.     LINE (x + r - a, y + r - b)-(x1 - r + a, y + r - b), c, BF
  266.     LINE (x + r - b, y1 - r + a)-(x1 - r + b, y1 - r + a), c, BF
  267.     LINE (x + r - a, y1 - r + b)-(x1 - r + a, y1 - r + b), c, BF
  268.  
  269.     b = b + 1
  270.     e = e + b + b
  271.     IF e > 0 THEN
  272.         a = a - 1
  273.         e = e - a - a
  274.     END IF
  275.  
  276. SUB CircleFill (CX AS LONG, CY AS LONG, R AS LONG, C AS LONG)
  277. 'This sub from here: http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=1848.msg17254#msg17254
  278. DIM Radius AS LONG
  279. DIM RadiusError AS LONG
  280.  
  281. Radius = ABS(R)
  282. RadiusError = -Radius
  283. X = Radius
  284. Y = 0
  285.  
  286. IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  287.  
  288. ' Draw the middle span here so we don't draw it twice in the main loop,
  289. ' which would be a problem with blending turned on.
  290. LINE (CX - X, CY)-(CX + X, CY), C, BF
  291.  
  292. WHILE X > Y
  293.  
  294.     RadiusError = RadiusError + Y * 2 + 1
  295.  
  296.     IF RadiusError >= 0 THEN
  297.  
  298.         IF X <> Y + 1 THEN
  299.             LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  300.             LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  301.         END IF
  302.  
  303.         X = X - 1
  304.         RadiusError = RadiusError - X * 2
  305.  
  306.     END IF
  307.  
  308.     Y = Y + 1
  309.  
  310.     LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  311.     LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  312.  
  313.  
  314.  
  315. SUB fline (x1 AS INTEGER, y1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER, c AS _UNSIGNED LONG, t AS INTEGER)
  316. 'Adapted from http://www.antonis.de/faq/progs/fatlines.bas
  317. '***************************************************************************
  318. ' FATLINES.BAS - Draws a fat line from (x1|y1) to (x2|y2) with color c and
  319. ' ============   thickness t
  320. '                Zeichnet eine dicke Linie von (x1|y1) nach (x2|y2) mit der
  321. '                Farbe c und der Dicke t. Die dicke Linie wird aus mehreren
  322. '                normalen Linien zusammengesetzt.
  323. '
  324. '===========================================================================
  325. ' Subject: FAT LINES                         Date: 08-06-99 (20:08)
  326. ' Author:  Marius Andra                      Code: QB, QBasic, PDS
  327. ' Origin:  marius.andra*mail.ee            Packet: GRAPHICS.ABC
  328. '***************************************************************************
  329. LINE (x1, y1)-(x2, y2), c
  330. IF t = 0 THEN EXIT SUB
  331.  
  332. IF x1 = x2 AND y1 <> y2 THEN 'vertical line
  333.     FOR i = 1 TO (t - 1) / 2
  334.         LINE (x1 - i, y1)-(x2 - i, y2), c
  335.         LINE (x1 + i, y1)-(x2 + i, y2), c
  336.     NEXT i
  337.     LINE (x1 - i, y1)-(x2 - i, y2), c
  338.  
  339. IF y1 = y2 AND x1 <> x2 THEN 'horizontal line
  340.     FOR i = 1 TO (t - 1) / 2
  341.         LINE (x1, y1 - i)-(x2, y2 - i), c
  342.         LINE (x1, y1 + i)-(x2, y2 + i), c
  343.     NEXT i
  344.     LINE (x1, y1 - i)-(x2, y2 - i), c
  345.  
  346. IF x1 < x2 AND y2 > y1 THEN 'falling line
  347.     FOR i = 1 TO (t - 1) / 2
  348.         LINE (x1 + i, y1)-(x2, y2 - i), c
  349.         LINE (x1, y1 + i)-(x2 - i, y2), c
  350.     NEXT i
  351.     LINE (x1 + i, y1)-(x2, y2 - i), c
  352.  
  353. IF x2 < x1 AND y2 > y1 THEN 'rising line
  354.     FOR i = 1 TO (t - 1) / 2
  355.         LINE (x1 - i, y1)-(x2, y2 - i), c
  356.         LINE (x1, y1 + i)-(x2 + i, y2), c
  357.     NEXT i
  358.     LINE (x1 - i, y1)-(x2, y2 - i), c
  359.  
  360. IF x1 < x2 AND y2 < y1 THEN 'rising line
  361.     FOR i = 1 TO (t - 1) / 2
  362.         LINE (x1, y1 - i)-(x2 - i, y2), c
  363.         LINE (x1 + i, y1)-(x2, y2 + i), c
  364.     NEXT i
  365.     LINE (x1, y1 - i)-(x2 - i, y2), c
  366.  
  367. IF x2 < x1 AND y2 < y1 THEN 'falling line
  368.     FOR i = 1 TO (t - 1) / 2
  369.         LINE (x1, y1 + i)-(x2 - i, y2), c
  370.         LINE (x1 - i, y1)-(x2, y2 + i), c
  371.     NEXT i
  372.     LINE (x1, y1 + i)-(x2 - i, y2), c
  373.  
  374. FUNCTION GetColor~& (theColorName$, Alpha!)
  375. ColorName$ = LCASE$(theColorName$)
  376.  
  377. IF LEFT$(ColorName$, 1) = "#" THEN
  378.     c$ = MID$(ColorName$, 2)
  379.     IF LEN(c$) = 6 THEN c$ = HEX$(Alpha! * 255) + c$
  380.     GetColor~& = VAL("&H" + c$)
  381. ELSEIF LEFT$(ColorName$, 4) = "rgb(" THEN
  382.     cpos% = 5
  383.     comma% = INSTR(cpos%, ColorName$, ",") - 1
  384.     r% = VAL(MID$(ColorName$, cpos%, comma% - cpos% + 1))
  385.  
  386.     cpos% = comma% + 2
  387.     comma% = INSTR(cpos%, ColorName$, ",") - 1
  388.     g% = VAL(MID$(ColorName$, cpos%, comma% - cpos% + 1))
  389.  
  390.     cpos% = comma% + 2
  391.     comma% = INSTR(cpos%, ColorName$, ")") - 1
  392.     b% = VAL(MID$(ColorName$, cpos%, comma% - cpos% + 1))
  393.  
  394.     GetColor~& = _RGBA32(r%, g%, b%, Alpha! * 255)
  395.     RESTORE ColorData
  396.     DO
  397.         READ TheColor$
  398.         IF TheColor$ = "END" THEN EXIT DO
  399.         IF LCASE$(LEFT$(TheColor$, INSTR(TheColor$, "=") - 1)) = ColorName$ THEN
  400.             GetColor~& = VAL("&H" + HEX$(Alpha! * 255) + MID$(TheColor$, INSTR(TheColor$, "=") + 4))
  401.             EXIT DO
  402.         END IF
  403.     LOOP
  404.  
  405. 'Color data from SMcNeill (https://dl.dropboxusercontent.com/u/83161214/Color32.BI):
  406. ColorData:
  407. DATA "AliceBlue=&HFFF0F8FF"
  408. DATA "Almond=&HFFEFDECD"
  409. DATA "AntiqueBrass=&HFFCD9575"
  410. DATA "AntiqueWhite=&HFFFAEBD7"
  411. DATA "Apricot=&HFFFDD9B5"
  412. DATA "Aqua=&HFF00FFFF"
  413. DATA "Aquamarine=&HFF7FFFD4"
  414. DATA "Asparagus=&HFF87A96B"
  415. DATA "AtomicTangerine=&HFFFFA474"
  416. DATA "Azure=&HFFF0FFFF"
  417. DATA "BananaMania=&HFFFAE7B5"
  418. DATA "Beaver=&HFF9F8170"
  419. DATA "Beige=&HFFF5F5DC"
  420. DATA "Bisque=&HFFFFE4C4"
  421. DATA "Bittersweet=&HFFFD7C6E"
  422. DATA "Black=&HFF000000"
  423. DATA "BlanchedAlmond=&HFFFFEBCD"
  424. DATA "BlizzardBlue=&HFFACE5EE"
  425. DATA "Blue=&HFF0000FF"
  426. DATA "BlueBell=&HFFA2A2D0"
  427. DATA "BlueGray=&HFF6699CC"
  428. DATA "BlueGreen=&HFF0D98BA"
  429. DATA "BlueViolet=&HFF8A2BE2"
  430. DATA "Blush=&HFFDE5D83"
  431. DATA "BrickRed=&HFFCB4154"
  432. DATA "Brown=&HFFA52A2A"
  433. DATA "BurlyWood=&HFFDEB887"
  434. DATA "BurntOrange=&HFFFF7F49"
  435. DATA "BurntSienna=&HFFEA7E5D"
  436. DATA "CadetBlue=&HFF5F9EA0"
  437. DATA "Canary=&HFFFFFF99"
  438. DATA "CaribbeanGreen=&HFF1CD3A2"
  439. DATA "CarnationPink=&HFFFFAACC"
  440. DATA "Cerise=&HFFDD4492"
  441. DATA "Cerulean=&HFF1DACD6"
  442. DATA "ChartReuse=&HFF7FFF00"
  443. DATA "Chestnut=&HFFBC5D58"
  444. DATA "Chocolate=&HFFD2691E"
  445. DATA "Copper=&HFFDD9475"
  446. DATA "Coral=&HFFFF7F50"
  447. DATA "Cornflower=&HFF9ACEEB"
  448. DATA "CornflowerBlue=&HFF6495ED"
  449. DATA "Cornsilk=&HFFFFF8DC"
  450. DATA "CottonCandy=&HFFFFBCD9"
  451. DATA "CrayolaAquamarine=&HFF78DBE2"
  452. DATA "CrayolaBlue=&HFF1F75FE"
  453. DATA "CrayolaBlueViolet=&HFF7366BD"
  454. DATA "CrayolaBrown=&HFFB4674D"
  455. DATA "CrayolaCadetBlue=&HFFB0B7C6"
  456. DATA "CrayolaForestGreen=&HFF6DAE81"
  457. DATA "CrayolaGold=&HFFE7C697"
  458. DATA "CrayolaGoldenrod=&HFFFCD975"
  459. DATA "CrayolaGray=&HFF95918C"
  460. DATA "CrayolaGreen=&HFF1CAC78"
  461. DATA "CrayolaGreenYellow=&HFFF0E891"
  462. DATA "CrayolaIndigo=&HFF5D76CB"
  463. DATA "CrayolaLavender=&HFFFCB4D5"
  464. DATA "CrayolaMagenta=&HFFF664AF"
  465. DATA "CrayolaMaroon=&HFFC8385A"
  466. DATA "CrayolaMidnightBlue=&HFF1A4876"
  467. DATA "CrayolaOrange=&HFFFF7538"
  468. DATA "CrayolaOrangeRed=&HFFFF2B2B"
  469. DATA "CrayolaOrchid=&HFFE6A8D7"
  470. DATA "CrayolaPlum=&HFF8E4585"
  471. DATA "CrayolaRed=&HFFEE204D"
  472. DATA "CrayolaSalmon=&HFFFF9BAA"
  473. DATA "CrayolaSeaGreen=&HFF9FE2BF"
  474. DATA "CrayolaSilver=&HFFCDC5C2"
  475. DATA "CrayolaSkyBlue=&HFF80DAEB"
  476. DATA "CrayolaSpringGreen=&HFFECEABE"
  477. DATA "CrayolaTann=&HFFFAA76C"
  478. DATA "CrayolaThistle=&HFFEBC7DF"
  479. DATA "CrayolaViolet=&HFF926EAE"
  480. DATA "CrayolaYellow=&HFFFCE883"
  481. DATA "CrayolaYellowGreen=&HFFC5E384"
  482. DATA "Crimson=&HFFDC143C"
  483. DATA "Cyan=&HFF00FFFF"
  484. DATA "Dandelion=&HFFFDDB6D"
  485. DATA "DarkBlue=&HFF00008B"
  486. DATA "DarkCyan=&HFF008B8B"
  487. DATA "DarkGoldenRod=&HFFB8860B"
  488. DATA "DarkGray=&HFFA9A9A9"
  489. DATA "DarkGreen=&HFF006400"
  490. DATA "DarkKhaki=&HFFBDB76B"
  491. DATA "DarkMagenta=&HFF8B008B"
  492. DATA "DarkOliveGreen=&HFF556B2F"
  493. DATA "DarkOrange=&HFFFF8C00"
  494. DATA "DarkOrchid=&HFF9932CC"
  495. DATA "DarkRed=&HFF8B0000"
  496. DATA "DarkSalmon=&HFFE9967A"
  497. DATA "DarkSeaGreen=&HFF8FBC8F"
  498. DATA "DarkSlateBlue=&HFF483D8B"
  499. DATA "DarkSlateGray=&HFF2F4F4F"
  500. DATA "DarkTurquoise=&HFF00CED1"
  501. DATA "DarkViolet=&HFF9400D3"
  502. DATA "DeepPink=&HFFFF1493"
  503. DATA "DeepSkyBlue=&HFF00BFFF"
  504. DATA "Denim=&HFF2B6CC4"
  505. DATA "DesertSand=&HFFEFCDB8"
  506. DATA "DimGray=&HFF696969"
  507. DATA "DodgerBlue=&HFF1E90FF"
  508. DATA "Eggplant=&HFF6E5160"
  509. DATA "ElectricLime=&HFFCEFF1D"
  510. DATA "Fern=&HFF71BC78"
  511. DATA "FireBrick=&HFFB22222"
  512. DATA "Floralwhite=&HFFFFFAF0"
  513. DATA "ForestGreen=&HFF228B22"
  514. DATA "Fuchsia=&HFFC364C5"
  515. DATA "FuzzyWuzzy=&HFFCC6666"
  516. DATA "Gainsboro=&HFFDCDCDC"
  517. DATA "GhostWhite=&HFFF8F8FF"
  518. DATA "Gold=&HFFFFD700"
  519. DATA "GoldenRod=&HFFDAA520"
  520. DATA "GrannySmithApple=&HFFA8E4A0"
  521. DATA "Gray=&HFF808080"
  522. DATA "Green=&HFF008000"
  523. DATA "GreenBlue=&HFF1164B4"
  524. DATA "GreenYellow=&HFFADFF2F"
  525. DATA "HoneyDew=&HFFF0FFF0"
  526. DATA "HotMagenta=&HFFFF1DCE"
  527. DATA "HotPink=&HFFFF69B4"
  528. DATA "Inchworm=&HFFB2EC5D"
  529. DATA "IndianRed=&HFFCD5C5C"
  530. DATA "Indigo=&HFF4B0082"
  531. DATA "Ivory=&HFFFFFFF0"
  532. DATA "JazzberryJam=&HFFCA3767"
  533. DATA "JungleGreen=&HFF3BB08F"
  534. DATA "Khaki=&HFFF0E68C"
  535. DATA "LaserLemon=&HFFFEFE22"
  536. DATA "Lavender=&HFFE6E6FA"
  537. DATA "LavenderBlush=&HFFFFF0F5"
  538. DATA "LawnGreen=&HFF7CFC00"
  539. DATA "LemonChiffon=&HFFFFFACD"
  540. DATA "LemonYellow=&HFFFFF44F"
  541. DATA "LightBlue=&HFFADD8E6"
  542. DATA "LightCoral=&HFFF08080"
  543. DATA "LightCyan=&HFFE0FFFF"
  544. DATA "LightGoldenRodYellow=&HFFFAFAD2"
  545. DATA "LightGray=&HFFD3D3D3"
  546. DATA "LightGreen=&HFF90EE90"
  547. DATA "LightPink=&HFFFFB6C1"
  548. DATA "LightSalmon=&HFFFFA07A"
  549. DATA "LightSeaGreen=&HFF20B2AA"
  550. DATA "LightSkyBlue=&HFF87CEFA"
  551. DATA "LightSlateGray=&HFF778899"
  552. DATA "LightSteelBlue=&HFFB0C4DE"
  553. DATA "LightYellow=&HFFFFFFE0"
  554. DATA "Lime=&HFF00FF00"
  555. DATA "LimeGreen=&HFF32CD32"
  556. DATA "Linen=&HFFFAF0E6"
  557. DATA "MacaroniAndCheese=&HFFFFBD88"
  558. DATA "Magenta=&HFFFF00FF"
  559. DATA "MagicMint=&HFFAAF0D1"
  560. DATA "Mahogany=&HFFCD4A4C"
  561. DATA "Maize=&HFFEDD19C"
  562. DATA "Manatee=&HFF979AAA"
  563. DATA "MangoTango=&HFFFF8243"
  564. DATA "Maroon=&HFF800000"
  565. DATA "Mauvelous=&HFFEF98AA"
  566. DATA "MediumAquamarine=&HFF66CDAA"
  567. DATA "MediumBlue=&HFF0000CD"
  568. DATA "MediumOrchid=&HFFBA55D3"
  569. DATA "MediumPurple=&HFF9370DB"
  570. DATA "MediumSeaGreen=&HFF3CB371"
  571. DATA "MediumSlateBlue=&HFF7B68EE"
  572. DATA "MediumSpringGreen=&HFF00FA9A"
  573. DATA "MediumTurquoise=&HFF48D1CC"
  574. DATA "MediumVioletRed=&HFFC71585"
  575. DATA "Melon=&HFFFDBCB4"
  576. DATA "MidnightBlue=&HFF191970"
  577. DATA "MintCream=&HFFF5FFFA"
  578. DATA "MistyRose=&HFFFFE4E1"
  579. DATA "Moccasin=&HFFFFE4B5"
  580. DATA "MountainMeadow=&HFF30BA8F"
  581. DATA "Mulberry=&HFFC54B8C"
  582. DATA "NavajoWhite=&HFFFFDEAD"
  583. DATA "Navy=&HFF000080"
  584. DATA "NavyBlue=&HFF1974D2"
  585. DATA "NeonCarrot=&HFFFFA343"
  586. DATA "OldLace=&HFFFDF5E6"
  587. DATA "Olive=&HFF808000"
  588. DATA "OliveDrab=&HFF6B8E23"
  589. DATA "OliveGreen=&HFFBAB86C"
  590. DATA "Orange=&HFFFFA500"
  591. DATA "OrangeRed=&HFFFF4500"
  592. DATA "OrangeYellow=&HFFF8D568"
  593. DATA "Orchid=&HFFDA70D6"
  594. DATA "OuterSpace=&HFF414A4C"
  595. DATA "OutrageousOrange=&HFFFF6E4A"
  596. DATA "PacificBlue=&HFF1CA9C9"
  597. DATA "PaleGoldenRod=&HFFEEE8AA"
  598. DATA "PaleGreen=&HFF98FB98"
  599. DATA "PaleTurquoise=&HFFAFEEEE"
  600. DATA "PaleVioletRed=&HFFDB7093"
  601. DATA "PapayaWhip=&HFFFFEFD5"
  602. DATA "Peach=&HFFFFCFAB"
  603. DATA "PeachPuff=&HFFFFDAB9"
  604. DATA "Periwinkle=&HFFC5D0E6"
  605. DATA "Peru=&HFFCD853F"
  606. DATA "PiggyPink=&HFFFDDDE6"
  607. DATA "PineGreen=&HFF158078"
  608. DATA "Pink=&HFFFFC0CB"
  609. DATA "PinkFlamingo=&HFFFC74FD"
  610. DATA "PinkSherbet=&HFFF78FA7"
  611. DATA "Plum=&HFFDDA0DD"
  612. DATA "PowderBlue=&HFFB0E0E6"
  613. DATA "Purple=&HFF800080"
  614. DATA "PurpleHeart=&HFF7442C8"
  615. DATA "PurpleMountainsMajesty=&HFF9D81BA"
  616. DATA "PurplePizzazz=&HFFFE4EDA"
  617. DATA "RadicalRed=&HFFFF496C"
  618. DATA "RawSienna=&HFFD68A59"
  619. DATA "RawUmber=&HFF714B23"
  620. DATA "RazzleDazzleRose=&HFFFF48D0"
  621. DATA "Razzmatazz=&HFFE3256B"
  622. DATA "Red=&HFFFF0000"
  623. DATA "RedOrange=&HFFFF5349"
  624. DATA "RedViolet=&HFFC0448F"
  625. DATA "RobinsEggBlue=&HFF1FCECB"
  626. DATA "RosyBrown=&HFFBC8F8F"
  627. DATA "RoyalBlue=&HFF4169E1"
  628. DATA "RoyalPurple=&HFF7851A9"
  629. DATA "SaddleBrown=&HFF8B4513"
  630. DATA "Salmon=&HFFFA8072"
  631. DATA "SandyBrown=&HFFF4A460"
  632. DATA "Scarlet=&HFFFC2847"
  633. DATA "ScreaminGreen=&HFF76FF7A"
  634. DATA "SeaGreen=&HFF2E8B57"
  635. DATA "SeaShell=&HFFFFF5EE"
  636. DATA "Sepia=&HFFA5694F"
  637. DATA "Shadow=&HFF8A795D"
  638. DATA "Shamrock=&HFF45CEA2"
  639. DATA "ShockingPink=&HFFFB7EFD"
  640. DATA "Sienna=&HFFA0522D"
  641. DATA "Silver=&HFFC0C0C0"
  642. DATA "SkyBlue=&HFF87CEEB"
  643. DATA "SlateBlue=&HFF6A5ACD"
  644. DATA "SlateGray=&HFF708090"
  645. DATA "Snow=&HFFFFFAFA"
  646. DATA "SpringGreen=&HFF00FF7F"
  647. DATA "SteelBlue=&HFF4682B4"
  648. DATA "Sunglow=&HFFFFCF48"
  649. DATA "SunsetOrange=&HFFFD5E53"
  650. DATA "Tann=&HFFD2B48C"
  651. DATA "Teal=&HFF008080"
  652. DATA "TealBlue=&HFF18A7B5"
  653. DATA "Thistle=&HFFD8BFD8"
  654. DATA "TickleMePink=&HFFFC89AC"
  655. DATA "Timberwolf=&HFFDBD7D2"
  656. DATA "Tomato=&HFFFF6347"
  657. DATA "TropicalRainForest=&HFF17806D"
  658. DATA "Tumbleweed=&HFFDEAA88"
  659. DATA "Turquoise=&HFF40E0D0"
  660. DATA "TurquoiseBlue=&HFF77DDE7"
  661. DATA "UnmellowYellow=&HFFFFFF66"
  662. DATA "Violet=&HFFEE82EE"
  663. DATA "VioletBlue=&HFF324AB2"
  664. DATA "VioletRed=&HFFF75394"
  665. DATA "VividTangerine=&HFFFFA089"
  666. DATA "VividViolet=&HFF8F509D"
  667. DATA "Wheat=&HFFF5DEB3"
  668. DATA "White=&HFFFFFFFF"
  669. DATA "Whitesmoke=&HFFF5F5F5"
  670. DATA "WildBlueYonder=&HFFA2ADD0"
  671. DATA "WildStrawberry=&HFFFF43A4"
  672. DATA "WildWatermelon=&HFFFC6C85"
  673. DATA "Wisteria=&HFFCDA4DE"
  674. DATA "Yellow=&HFFFFFF00"
  675. DATA "YellowGreen=&HFF9ACD32"
  676. DATA "YellowOrange=&HFFFFAE42"
  677. DATA "END"
  678.  
  679.  
  680.  
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

FellippeHeitor

  • Guest
Re: Built-in function to loads SVG image format?
« Reply #3 on: February 09, 2019, 09:55:01 am »
It's a veeeeery limited xml parser focused on a subset of svg tags, and renders veeeeery crudely too, but it's a start if one wants to keep working on it. It was a fun exercise to write, hope it's useful to anyone.

As to "Any possibility to add one in the future?", it greatly depends on the existence of a good svg to raster c++ library out there. Anyone know of a good one?

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Built-in function to loads SVG image format?
« Reply #4 on: February 09, 2019, 10:52:42 am »
As to "Any possibility to add one in the future?", it greatly depends on the existence of a good svg to raster c++ library out there. Anyone know of a good one?
Will SVG++ (SVGPP) work?
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

FellippeHeitor

  • Guest
Re: Built-in function to loads SVG image format?
« Reply #5 on: February 09, 2019, 10:54:27 am »
Good question.

Offline ForSe

  • Newbie
  • Posts: 6
    • View Profile
Re: Built-in function to loads SVG image format?
« Reply #6 on: February 09, 2019, 06:30:53 pm »
you can code your own function to load SVG files.

Yeah, I thought to make my own too.

As to "Any possibility to add one in the future?", it greatly depends on the existence of a good svg to raster c++ library out there. Anyone know of a good one?
Will SVG++ (SVGPP) work?

That's one of the reason why I suggested to add a built-in function, there are already some open source SVG library in C++ out there.

Okay, So I found Fellippe's code in my QB64 code archive. :D

I tested the code with some of my SVG files, I also tested https://www.svgrepo.com/show/123512/simple-cloud.svg, but it only show a blank, white screen.