项目作者: react-paper

项目描述 :
Paper.js bindings for React
高级语言: JavaScript
项目地址: git://github.com/react-paper/react-paper-bindings.git
创建时间: 2016-01-21T14:50:44Z
项目社区:https://github.com/react-paper/react-paper-bindings

开源协议:

下载


Paper.js bindings for React Fiber

Demo

http://react-paper.github.io/react-paper-bindings/

Development

Start watching src with babel

  1. cd react-paper-bindings
  2. npm start

Link the library to the demo

  1. # npm link the library
  2. cd react-paper-bindings
  3. npm link
  4. cd demo
  5. npm link react-paper-bindings

Start demo with create-react-app

  1. cd demo
  2. npm start

If someone knows a better way, please let me know ;)

Similar projects

Example

  1. import React, { Component } from 'react'
  2. import {
  3. View,
  4. Layer,
  5. Group,
  6. Path,
  7. Circle,
  8. Ellipse,
  9. Rectangle,
  10. PointText,
  11. Tool,
  12. } from 'react-paper-bindings'
  13. const ReactLogo = ({ rotation, x, y }) => {
  14. return (
  15. <Group name={'reactLogo'} rotation={rotation}>
  16. <Ellipse
  17. center={[x, y]}
  18. size={[70, 25]}
  19. strokeWidth={2.5}
  20. strokeColor={'#61DAFB'}
  21. ></Ellipse>
  22. <Ellipse
  23. center={[x, y]}
  24. rotation={120}
  25. size={[70, 25]}
  26. strokeWidth={2.5}
  27. strokeColor={'#61DAFB'}
  28. ></Ellipse>
  29. <Ellipse
  30. center={[x, y]}
  31. rotation={240}
  32. size={[70, 25]}
  33. strokeWidth={2.5}
  34. strokeColor={'#61DAFB'}
  35. ></Ellipse>
  36. <Circle
  37. center={[x, y]}
  38. fillColor={'#61DAFB'}
  39. radius={7}
  40. ></Circle>
  41. </Group>
  42. )
  43. }
  44. const Paper = ({ activeTool, circles, rectangles, width, height }) => {
  45. return (
  46. <View activeTool={activeTool} width={width} height={height}>
  47. <Layer>
  48. {circles.map(circle => <Circle {...circle} ></Circle>)}
  49. </Layer>
  50. <Layer>
  51. {rectangles.map(rectangle => <Rectangle {...rectangle} ></Rectangle>)}
  52. </Layer>
  53. <Layer>
  54. <Rectangle
  55. center={[width/2, height/2]}
  56. fillColor={'#222222'}
  57. opacity={0.8}
  58. size={[320, 120]}
  59. ></Rectangle>
  60. <PointText
  61. content={'Paper.js'}
  62. fillColor={'white'}
  63. fontFamily={'Courier New'}
  64. fontSize={30}
  65. fontWeight={'bold'}
  66. justification={'center'}
  67. point={[(width/2)+40, (height/2)+10]}
  68. ></PointText>
  69. <ReactLogo
  70. rotation={rotation}
  71. x={(width/2)-100}
  72. y={(height/2)}
  73. ></ReactLogo>
  74. </Layer>
  75. <Tool
  76. active={activeTool === 'move'}
  77. name={'move'}
  78. onMouseDown={props.moveToolMouseDown}
  79. onMouseDrag={props.moveToolMouseDrag}
  80. onMouseUp={props.moveToolMouseUp}
  81. ></Tool>
  82. <Tool
  83. active={activeTool === 'pen'}
  84. name={'pen'}
  85. onMouseDown={props.penToolMouseDown}
  86. onMouseDrag={props.penToolMouseDrag}
  87. onMouseUp={props.penToolMouseUp}
  88. ></Tool>
  89. <Tool
  90. active={activeTool === 'circle'}
  91. name={'circle'}
  92. onMouseDown={props.addCircle}
  93. ></Tool>
  94. <Tool
  95. active={activeTool === 'rectangle'}
  96. name={'rectangle'}
  97. onMouseDown={props.addRectangle}
  98. ></Tool>
  99. </View>
  100. )
  101. }