srwiley / rasterx

Rasterx is an SVG 2.0 path compliant rasterizer that can use either scany, the golang vector or a derivative of the freetype anti-aliaser.
BSD 3-Clause "New" or "Revised" License
132 stars 11 forks source link

Implementing the rasterx interface #9

Open Noofbiz opened 4 years ago

Noofbiz commented 4 years ago

Hello! I want to be able to render svgs directly to, say, an opengl framebuffer rather than an image.Image. I've actually already got the engine and framework and shaders needed, and It seems to me that a lot of the types in this package could be interfaces, which could then allow me to implement them to allow me to do just that. Is that a direction you'd be willing to take? I'll put together the PR and write it myself, I'm just wondering if you had any tips or ideas on going about it. Thanks!

srwiley commented 4 years ago

Hi Noofbiz, Sorry for taking so long to get back to you. I had to do some reconfiguring on my setup and review some stuff before I could answer intelligently.

I am definitely interested in whatever can make writing to opengl faster and (hopefully) cleaner. You should take a look at the scanx https://github.com/srwiley/scanx repository

// ImgSpanner is a Spanner that draws Spans onto xgraphics.Image // or image.RGBA image types // It uses either a color function as a the color source, or a fgColor // if colFunc is nil. ImgSpanner struct { baseSpanner pix []uint8 stride int

// xgraphics.Images swap r and b pixel values // compared to saved rgb value. xpixel bool colorFunc rasterx.ColorFunc }

Although this version uses the xgraphics.Image type, which it sounds like you want to avoid, it also uses my new Scanner interface rather than the freetype Paint interface. This avoids the spans being pushed into a slice before being sent to the image buffer. Instead the receiving interface gets the data directly, and is somewhat faster.

I hope this helps. I would be happy to follow what you are doing in this regard.

best wishes, srwiley

On Sat, Jul 11, 2020 at 6:08 PM Noofbiz notifications@github.com wrote:

Hello! I want to be able to render svgs directly to, say, an opengl framebuffer rather than an image.Image. I've actually already got the engine and framework and shaders needed, and It seems to me that a lot of the types in this package could be interfaces, which could then allow me to implement them to allow me to do just that. Is that a direction you'd be willing to take? I'll put together the PR and write it myself, I'm just wondering if you had any tips or ideas on going about it. Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/srwiley/rasterx/issues/9, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4VOB67GQFS3DTOAPATXR3R3EEI5ANCNFSM4OXRZNMQ .

Noofbiz commented 4 years ago

That looks like exactly what I need. I'm working on adding svg support to engo. I am currently using rasterx to get images then upload them like pngs or jpgs. But I really want to keep all the parts of the svg separate to support things like dragon bones like animations and motion tweening. So instead of uploading svgs to the GPU as textures, I want to keep them as shapes, curves, etc.

Noofbiz commented 3 years ago

related to https://github.com/srwiley/oksvg/issues/22