Does Cinder support the ability to get a string and create SVG file from it? or to create kind of SVG file like bitmap(or any other buffers)?
doc.loadByString("<svg><text x='0' y='15' fill='red'> SVG </text></svg>"));
//now, doc include SVG file
I would like also to know if a file containing a Text tag can be loaded by Cinder (by the loadAsset function or any other function that loads SVG files)
Something like this maybe?
std::string svgString = "<svg><text x='0' y='15' fill='red'> SVG </text></svg>";
BufferRef buffer = Buffer::create( (void *)svgString.c_str(), svgString.size() );
DataSourceBufferRef dataSource = DataSourceBuffer::create( buffer );
svg::DocRef doc = svg::Doc::create( dataSource );
About your second question, the svg reader has a
Text node, so it should work.
Thanks for the quick reply! But I’m looking for more than that. After loading the string I need to convert the doc sto buffer bitmap.
Something like this:
Bitmap bitmap = doc.renderToBitmap()
BufferRef buffer2= Buffer::create((void*) bitmap.data(),bitmap.size())
I need the buffer to be gray-scale and not RGBA but it is not very necessary. Is it possible to convert the
doc object to a buffer?
What is your use case?
Did you check the svg samples? This is how you can render a Surface from an svg.