-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add drawShape function #1
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On pourra check enssemble, desoler du temps de reaction j'avais pas vu que la pr etait en attente
for(let i = 0; i < 8; i++) { | ||
octoPos.push([x + hr * Math.cos( (2*i + 1) * Math.PI/8), y + hr * Math.sin( (2*i + 1) * Math.PI/8)]) | ||
} | ||
path = `${octoPos.reduce((p, [x, y]) => (`${p}L${x},${y}`), `M${octoPos[0][0]},${octoPos[0][1]}`)}z` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool le reduce, j'trouve quand meme que la version map / join est plus simple:
`M${octoPos[0][0]},${octoPos[0][1]}${octoPos.map(([x, y]) => `L${x},${y}`).join('')}z`
group.appendChild(Circle({ ...defaultShapeCircle, ...custom, cx: x, cy: y })) | ||
return | ||
} | ||
const shape = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pourquoi passez par la variable shape
ici ?
d'ailler toute la partie group / append pour etre faite ici.
const hr = radius / 2 | ||
let path | ||
|
||
switch(shapeType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'suis pas fan du switch on pourrais faire un tableau de fonctions qui retourne toujours un path.
Ca demande de creer le rond avec un path mais c'est pas la mort:
https://codepen.io/jakob-e/pen/bgBegJ
comme ca on peu ecrire:
const d = shapeHandlers[shapeType](x, y, radius, hr, custom)
const elem = Path({ ...defaultShapePath, ...custom, d })
group.appendChild(elem)
case 'SQUARE': | ||
path = `M${x-hr},${y+hr}v${-radius}h${radius}v${radius}z` | ||
break | ||
case 'DIAMOND': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pas sur de vouloir les metre en majuscule, j'trouve ca generalement plus chiant a ecrire
'stroke-dasharray': "0.005,0.015" | ||
} | ||
|
||
const drawShape = (x, y, shapeType, custom = {}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
custom c'est les proprietes additionnelles ?
generalement on appelle ca props
No description provided.