Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

add drawShape function #1

wants to merge 1 commit into from

Conversation

MarieRouviere
Copy link

No description provided.

Copy link
Member

@kigiri kigiri left a 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`
Copy link
Member

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 = {
Copy link
Member

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) {
Copy link
Member

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':
Copy link
Member

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 = {}) => {
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants