简体   繁体   中英

How to have rounded corners for stage or layers in React Konva

在此处输入图片说明

Hi ,

I want my stage to look like below image and user will draw on it , my question is how can I do this with React-Konva ? I only saw cornerRadius property in rect. And also users actions should be with in the stage.

thanks in advance

You can do this with CSS styles:

  <Stage width={window.innerWidth} height={window.innerHeight} style={{
    backgroundColor: 'grey',
    borderRadius: '15px',
    overflow: 'hidden'
  }}>

https://codesandbox.io/s/98on17x8xr

The CSS solution is simpler, but if you want to do it with Konva there is a clipping function you can use.

https://konvajs.github.io/docs/clipping/Clipping_Function.html

您可以为Rect对象提供cornerRadius键属性

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM