Comments (7)
Sure, see https://pkg.go.dev/github.com/tdewolff/canvas/renderers for an overview of implemented writers. I've also added
Canvas.Write
explicitly, but it's really the same as the implementations ofcanvas.Writer
inrenderers/renderers.go
.
Sorry, I didn't make myself clear.
When I call WriteFile()
or renderer.Write()
It will writes a file to disk then I can open the file transfer into Base64 format. I wonder if there is a way to create an image in memory and convert it to Base64 without writing it to disk
I'm new for go, bug I can show some browser-side examples or node.js
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
context.fillStyle = "#FF0000";
context.fillRect(50, 50, 200, 100);
// toBase64
var dataURL = canvas.toDataURL("image/png");
from canvas.
Like I mentioned, you can use the functions defined in renderers/ or the new Canvas.Write
function:
var c *canvas.Canvas
// ...
b := &bytes.Buffer{}
if err := renderers.PNG()(b, c); err != nil {
panic(err)
}
// or
var c *canvas.Canvas
// ...
b := &bytes.Buffer{}
if err := c.Write(b, renderers.PNG()); err != nil {
panic(err)
}
I've improved the documentation of those function.
from canvas.
Sure, see https://pkg.go.dev/github.com/tdewolff/canvas/renderers for an overview of implemented writers. I've also added Canvas.Write
explicitly, but it's really the same as the implementations of canvas.Writer
in renderers/renderers.go
.
from canvas.
that's cool. thanks alot
from canvas.
that's cool. thanks alot
from canvas.
that's cool. thanks alot
from canvas.
that's cool. thanks alot
from canvas.
Related Issues (20)
- [Question] Can we transform an element itself instead transform canvas? HOT 1
- Feature request: PostScript Parser HOT 2
- Bug Panic: Path Intersection HOT 3
- Bug found in path intersection code HOT 10
- ParseLaTeX() function doesn't work HOT 4
- Use go-text/fontscan.SystemFonts
- Preview failing in Mac OS X HOT 7
- [LaTeX Bug] (Not Urgent) Certain glyphs scale wrongly HOT 4
- [question] Drawing parsed SVG file HOT 6
- Font fallback handling HOT 2
- SVG Rendering Issues HOT 3
- Different output after upgrading to db7265801182 HOT 4
- Intersection panics HOT 1
- Bug found in path intersection code HOT 2
- Image is rasterised off-centre/rearranged HOT 3
- Consider using twpayne/go-svg for SVG XML generation HOT 2
- Using one canvas in another HOT 2
- Font Issue HOT 1
- Issue with the getting started template HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from canvas.