ofrohn / d3-celestial

A star map with d3.js
BSD 3-Clause "New" or "Revised" License
635 stars 181 forks source link

MOON size #73

Closed kgoyal000 closed 4 years ago

kgoyal000 commented 4 years ago

hello @ofrohn first thanks for this awesome library , i want to increase the moon size i can't find any option can you please help. And thanks again 🙂

ofrohn commented 4 years ago

Since you closed it, you probably have found the location in the code where it was hard-coded, basically to make it the same size as the sun. However, since a hard-coded number is always worse than a configurable one, I added an override to the configuration, under planets.symbols: "lun": {symbol: "\u25cf", letter:"L", fill: "#ffffff", size: 12}, where the number for size is the (approximate) diameter of the symbol in pixels. That also gave me the opportunity to size all the planetary disks consistently. So thanks for the incentive to improve the code!

kgoyal000 commented 4 years ago

Thanks ofrohn for your time , there is an another issue with planets and moon , if we check them and then try to download svg an error came up and if we again click download svg then svg got downloaded but without white side of moon

Attaching screenshots of error as well as my code i wrote to make it work but i think the code i wrote is not fine although its working Screenshot from 2020-05-29 20-29-04 IMG_20200529_203618

ofrohn commented 4 years ago

I've just fixed the SVG module so that it also respects the size parameter I talked about above. If you use that setting instead of modifying the code, it should work as advertised. There was another issue that caused the Moon to be printed behind the stars. I put all the Solar System objects in a separate layer that will always be printed in front of the stars, which is the proper way for planets to behave.

kgoyal000 commented 4 years ago

Thanks for the fix , its really helpful 🙂

kgoyal000 commented 4 years ago

@ofrohn there still same error coming for which i used try catch attaching the settings which i implemented check that

when i click on download svg an error came up in console

then 2nd time i click download svg then it downloads the svg

ofrohn commented 4 years ago

OK, now I can replicate the error. It seems if you disable almost everything the d3.svg.customSymbol class doesn't get defined for some reason. Not sure why, but if I pull the declaration out of the saveSVG function it doesn't produce the error under the exact same settings. So I think I'll just do that and be done with it.

ofrohn commented 4 years ago

Can you check?

kgoyal000 commented 4 years ago

Thanks its all error free now really appreciate your time , sorry to bother you again but is this possible in future versions that if we increase width of canvas stars , planets all increase their sizes too , because we have to manually change the stellar size with exponential for stars to make them look nice

ofrohn commented 4 years ago

In the latest version the size of planetary objects is scaled when zooming in. That'll probably do what you want

kgoyal000 commented 4 years ago

Thanks ofrohn your work and personality is out of this world , thanks again

kgoyal000 commented 4 years ago

Hello ofrohn , hope you are doing well i found another issue with moon if we change symbol fill color to any other color it gets affected only on svg not on canvas

ofrohn commented 4 years ago

Good catch. That was a choice to use a hard-coded color for the moon symbol. But there really isn't any good reason to ignore the configuration setting, so I fixed if now.

kgoyal000 commented 4 years ago

Hi ofrohn sorry for disturbing again , i have a question i want to know whether i can use 🌑 this symbol for black moon or not when i replaced this with all moon unicode character's still that didn't worked for me , please guide me is that possible or not Thanks

ofrohn commented 4 years ago

I'm not sure I understand the issue correctly: You'd like to use a Unicode Moon symbol instead of the generated crescent? If yes, that is currently not possible because I always show the generated symbol with the settings 'symbol' and 'disk', because I like it so much. If you insist, I provide an override so that the 'symbol' setting uses the Unicode character.

kgoyal000 commented 4 years ago

I want moon to look like this , i thought this looks good than just white moon , but i don't know how i can achieve this Please help me in this IMG_20200606_014730

ofrohn commented 4 years ago

So you want to display the generated crescent in front of the unicode symbol? Well, that is pretty complicated, since the size of the crescent has to match the symbol exactly. That is somewhat problematic, since there are differences between fonts, browsers and OSes how the unicode is displayed. But if you want to do it for yourself for one specific setup, this code instead of the "darkluna" background circle should get you started:

  planets.selectAll(".dmoon")
    .data(jlun.features)
    .enter().append("text")
    .attr({dy: ".2em", dx: "-.75em", class: "darkluna"})
    .style ( "fill", "#000" )
    .attr("transform", function(d) { return point(d.geometry.coordinates); })
    .text("🌑");

And adapt the size of the crescent in the configuration object via the size parameter in planets -> symbols -> 'lun'. The 'dy' and 'dx' attributes in the snippet above may need some adjustment as well.

kgoyal000 commented 4 years ago

Thanks ofrohn , i just want to improve the code and want to know that how is this thing possible , i will definitely try as you said Thanks again