expo / expo-2d-context

A pure-js implementation of the W3C's Canvas-2D Context API that can be run on either Expo Graphics or WebGL
111 stars 7 forks source link

How to draw images ? #12

Open ivanzamoraarias opened 4 years ago

ivanzamoraarias commented 4 years ago

Hi ! Sorry for this dummy question but I could not found a way to draw images ._. even using the Asset library from expo. is there a way with ctx.drawImage ?

flyskywhy commented 3 years ago

@ivanzamoraarias , @flyskywhy/react-native-gcanvas can draw images even from require('some.png').

After months work, @flyskywhy/react-native-gcanvas runs well on Android and iOS, fix several bugs and add feat: support drawImage() from require('some.png') on Android, iOS and Web described in Changelog.md, refactor with the detailed Example As Usage in README.md.

With Performance Test Result, and Convenient With Browser-like canvas APIs with the easily <canvas/> ported example react-native-particles-bg runs on Android, iOS and Web, @flyskywhy/react-native-gcanvas is the best choice for now :yum:

darkworks commented 3 years ago

no idea same issue. @flyskywhy i tried ur lib its very good just that its missing canva.toDataURL(); :( any idea how can we add it or convert canva to image or get base64 image data out of it

flyskywhy commented 3 years ago

@flyskywhy/react-native-gcanvas@2.2.0 support toDataURL() with png or jpeg on Android and iOS

VityaSchel commented 3 years ago

@ivanzamoraarias , @flyskywhy/react-native-gcanvas can draw images even from require('some.png').

After months work, @flyskywhy/react-native-gcanvas runs well on Android and iOS, fix several bugs and add feat: support drawImage() from require('some.png') on Android, iOS and Web described in Changelog.md, refactor with the detailed Example As Usage in README.md.

With Performance Test Result, and Convenient With Browser-like canvas APIs with the easily <canvas/> ported example react-native-particles-bg runs on Android, iOS and Web, @flyskywhy/react-native-gcanvas is the best choice for now 😋

If you take a careful look at name of this library you can see the word "expo" in it, but as you may know, expo does not support native modules and native code, including c++ code, which is in your library. This is why you probably won't find users here.

himrocks33 commented 2 years ago

Is there anyway to draw a video component similar to this js code? Doesn't seem draw image allows for an object reference.

canvas.getContext('2d').drawImage(this.video, 0, 0, 640, 480);

const image = canvas.toDataURL("image/jpeg");

@flyskywhy