custom height and width of gcanvas #63
Unanswered
hunteronoffical
asked this question in
Q&A
Replies: 1 comment
-
Maybe you need |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
hi !
i have simple code. if i fixed height of canvas, cavas display but this code is not display. please help me
import React, { useState, useContext, useEffect } from 'react';
import { GCanvasView, GImage } from '@flyskywhy/react-native-gcanvas';
const Test = (height=300) => {
const [canvasOff, setcanvasOff] = useState(null);
useEffect(() => {
console.log("asdfasdfg")
if (canvasOff) {
canvasOff.width = 1000;
canvasOff.height = heightx;
const ctx = canvasOff.getContext('2d');
ctx.beginPath();
//rect
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, 50, 50);
//rect
ctx.fillStyle = 'green';
ctx.fillRect(50, 50, 50, 50);
ctx.fill();
ctx.render()
}
}, []
)
return (
<>
<GCanvasView
onCanvasResize={onCanvasResize} onCanvasCreate={(cavans) => { setcanvasOff(cavans),console.log(heightx) }} height={height} style={{ width: '100%', }} />
</>
);
}
export default Test;
Beta Was this translation helpful? Give feedback.
All reactions