HashLips / generative-art-opensource

Create generative art by using the canvas api and node js, feel free to contribute to this repo with new ideas.
MIT License
1.36k stars 695 forks source link

Help for a non English speaker #107

Open CarlosX99 opened 2 years ago

CarlosX99 commented 2 years ago

Hello, I have some problems to understand the videos due to the language. I know they are awesome but for me it is to complicated to follow all the steps. In a previous version of the script I was able to do it but not very well. It was like this but due to "Weight" some layers were not displayed.

In config.js

const races = { skull: { name: "Skull", layers: [ { name: "Background", elements: [ { id: 0, name: "Background1", path: ${dir}/1-background/Background1.png, weight: 10, }, { id: 1, name: "Background2", path: ${dir}/1-background/Background2.png, weight: 29, },

But now, in this new version I am unable to write the code because it is a little different. In other words, I can run the example but I cant see where are the paths to replace them or add mines. I have seen the videos but there are a lot of minutes and as I said before the language is a problem for me. I can understand it more or less but some parts are impossible.

I would like to ask for a complete template of the new version where I can replace the layers like I did in the previous version.

Thank you.

CarlosX99 commented 2 years ago

Thanks to the person who answered me before even though I can't see the answer now. I don't know if he or someone else has deleted it.

Thanks to that answer I have been able to solve my problem.

In Weight I thought I had to put a sum of 100 between all of them. In my last example the id:0 would be a 10% of the times, id:1 the 29% and so on.

Now, in a 5 layer I put:

id:0 weight 100 id:1 weight 80 id:2 weight 60 id:3 weight 40 id:4 weight 20

So the percentage of every id is that id minus the next id. Here I have a 20% of every layer and it is working.

If I want a super rarity of a 1% in id3 the weight should be id:3 40 id:4 39 leaving the total percentage like

id:0 20% id:1 20% id:2 20% id3 1% id4 39%

In other words, always begin with a 100 in the first Id and calculate the diference with the next id to obtain the percentages you want for every layer.