mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
[WIP] Add preview of collision mask polygons
This commit is contained in:
@@ -1,40 +1,54 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mapVector } from '../../../../Utils/MapFor';
|
import { mapVector } from '../../../../Utils/MapFor';
|
||||||
|
import Measure from 'react-measure';
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
container: {
|
container: {
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
},
|
},
|
||||||
|
svg: {
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
type Props = {|
|
type Props = {|
|
||||||
polygons: gdVectorPolygon2d,
|
polygons: gdVectorPolygon2d,
|
||||||
|
imageWidth: number,
|
||||||
|
imageHeight: number,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
export default class CollisionMasksPreview extends React.Component<
|
export default class CollisionMasksPreview extends React.Component<
|
||||||
Props,
|
Props,
|
||||||
void
|
void
|
||||||
> {
|
> {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { polygons } = this.props;
|
const { polygons } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={styles.container}>
|
<svg
|
||||||
<svg>
|
width={this.props.imageWidth}
|
||||||
{mapVector(polygons, polygon => {
|
height={this.props.imageHeight}
|
||||||
const vertices = polygon.getVertices();
|
style={styles.svg}
|
||||||
return mapVector(vertices, vertex => (
|
>
|
||||||
<circle
|
{mapVector(polygons, (polygon, i) => {
|
||||||
cx={vertex.get_x()}
|
const vertices = polygon.getVertices();
|
||||||
cy={vertex.get_y()}
|
return (
|
||||||
r="3"
|
<polygon
|
||||||
fill="blue"
|
fill="rgba(255,0,0,0.2)"
|
||||||
/>
|
stroke="rgba(255,0,0,0.5)"
|
||||||
));
|
strokeWidth={1}
|
||||||
})}
|
fileRule="evenodd"
|
||||||
</svg>
|
points={mapVector(
|
||||||
</div>
|
vertices,
|
||||||
|
(vertex, j) => `${vertex.get_x()},${vertex.get_y()}`
|
||||||
|
).join(' ')}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</svg>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@ export default class SetupGridDialog extends Component {
|
|||||||
const actions = [
|
const actions = [
|
||||||
<FlatButton
|
<FlatButton
|
||||||
label="Cancel"
|
label="Cancel"
|
||||||
|
primary={false}
|
||||||
onClick={this.props.onCancel}
|
onClick={this.props.onCancel}
|
||||||
/>,
|
/>,
|
||||||
<FlatButton
|
<FlatButton
|
||||||
|
Reference in New Issue
Block a user