# How to draw a crescent

**URL:** <https://discourse.processing.org/t/how-to-draw-a-crescent/30771>\
**Category:** Coding Questions\
**Created:** [June 17, 2021, 8:26pm UTC](https://discourse.processing.org/t/how-to-draw-a-crescent/30771 "2021-06-17T20:26:32Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![Dan](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/dan/32/1829_2.png) [@Dan](https://discourse.processing.org/u/Dan)\
**Post date:** [September 27, 2021, 6:46pm UTC](https://discourse.processing.org/t/how-to-draw-a-crescent/30771/21 "2021-09-27T18:46:04Z")

</div>

Thanks for the link Jeremy! I’d like to learn much more about astronomy actually. I took a year of it in school decades ago but I’ve forgotten most of it by now. Curiously, that’s the last time I took a formal programming class and the language we used was … Pascal! I also have very little memory of that, aside from spending a lot of time looking for missed semicolons on that big green bar paper printers used to use. 🙂

---

<div class="post-metadata">

**Author:** ![Jeremy\_W](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@Jeremy\_W](https://discourse.processing.org/u/Jeremy_W)\
**Post date:** [September 27, 2021, 8:33pm UTC](https://discourse.processing.org/t/how-to-draw-a-crescent/30771/22 "2021-09-27T20:33:41Z")

</div>

No problem Dan.

Reading some of the posts and answers on this Processing site there is not very much (how about nothing !!) that I can contribute as it is “way out” of my field of expertise. It looks as if there is not a great deal that I can contribute here.

Cheers,

Jeremy.

---

<div class="post-metadata">

**Author:** ![Dan](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/dan/32/1829_2.png) [@Dan](https://discourse.processing.org/u/Dan)\
**Post date:** [September 27, 2021, 8:58pm UTC](https://discourse.processing.org/t/how-to-draw-a-crescent/30771/23 "2021-09-27T20:58:24Z")

</div>

Well I’m glad you contributed to this post!

---

<div class="post-metadata">

**Author:** ![arathorn76](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@arathorn76](https://discourse.processing.org/u/arathorn76)\
**Post date:** [October 1, 2021, 2:27pm UTC](https://discourse.processing.org/t/how-to-draw-a-crescent/30771/24 "2021-10-01T14:27:34Z")

</div>

> [@rapatski](#):
>
> Does this work? [p5.js Web Editor](https://editor.p5js.org/rapatski/sketches/GeTl8coHG)

It works for me - just in case you were still waiting for an answer.  
And it was animating just now - don´t know if you did anything to the code since you posted here

---

<div class="post-metadata">

**Author:** ![rapatski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rapatski/32/5164_2.png) [@rapatski](https://discourse.processing.org/u/rapatski)\
**Post date:** [October 1, 2021, 3:40pm UTC](https://discourse.processing.org/t/how-to-draw-a-crescent/30771/25 "2021-10-01T15:40:20Z")

</div>

When you say it animates, do you see the moon go through all of its phases, with the light continuously circling the sphere?

I don’t… I see the light kind of animating in on the left side, and then stopping. Which is odd, considering sin(frameCount) should continue to swing between -1 and 1… ?

---

<div class="post-metadata">

**Author:** ![arathorn76](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@arathorn76](https://discourse.processing.org/u/arathorn76)\
**Post date:** [October 1, 2021, 8:38pm UTC](https://discourse.processing.org/t/how-to-draw-a-crescent/30771/26 "2021-10-01T20:38:50Z")

</div>

> [@rapatski](#):
>
> When you say it animates, do you see the moon go through all of its phases, with the light continuously circling the sphere?

Now you asked specifically…  
I saw what you described and thought it was animating slowly and I ran out of patience.  
My bad.  
To make up for it: as you linked your sketch in the editor I had a little poke and some Reference-reading and came up with one additional line

```auto
  let angle = frameCount/20.0; //was frameCount/10.0
  moonPG.reset(); //was missing
  moonPG.directionalLight(255, 255, 255, cos(angle), 0, sin(angle));

```

Of course I didn´t save into your code - but I learned something about rendering

---

<div class="post-metadata">

**Author:** ![rapatski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rapatski/32/5164_2.png) [@rapatski](https://discourse.processing.org/u/rapatski)\
**Post date:** [October 3, 2021, 6:41pm UTC](https://discourse.processing.org/t/how-to-draw-a-crescent/30771/27 "2021-10-03T18:41:42Z")

</div>

Awesome! Changed it to include the reset. Thanks for finding that!

[Previous page](https://discourse.processing.org/t/how-to-draw-a-crescent/30771.md?page=1)
