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

Shadows for p5 #3167

Closed
2 of 14 tasks
TanviKumar opened this issue Aug 20, 2018 · 7 comments
Closed
2 of 14 tasks

Shadows for p5 #3167

TanviKumar opened this issue Aug 20, 2018 · 7 comments

Comments

@TanviKumar
Copy link
Member

Nature of issue?

  • Found a bug
  • Existing feature enhancement
  • New feature request

Most appropriate sub-area of p5.js?

  • Color
  • Core/Environment/Rendering
  • Data
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Other (specify if possible)

New feature details:

Currently p5.js does not have any support for shadows. It's one of the very few things missing and should be relatively easy to implement too! This links to the documentation about shadows.

It would be great if a method could be added to allow the user to create shadows with ease. Perhaps multiple methods could be created to change specific properties of the shadows, though I'm unsure as to how useful that might truly be. Hoping this issue can be a space for discussion about this.

In case the community believes that this would be a useful addition, I've written some code for a method for creating shadows, hopefully that can be a good start!

@lmccart
Copy link
Member

lmccart commented Sep 1, 2018

I'm not seeing a lot of response around this one right now and I think it may be beyond the scope of the library for now. It is possible to call these methods natively on the canvas object, so I'm not sure a wrapper of these is necessary. Let's revisit in the future if others express the same need. Thanks @TanviKumar

@lmccart lmccart closed this as completed Sep 1, 2018
@lekmao
Copy link

lekmao commented Jun 5, 2019

@TanviKumar
Do you have an example of using "drop shadows" in 2D art?
New to p5.js and working on an assignment. I would like to add depth to it. Any help?
Thanks!

@flomerboy
Copy link

An example in the documentation would be very helpful - I don't know how to "call these methods natively on the canvas object" and I would expect the average p5js user to not be familiar with it either.

@lmccart
Copy link
Member

lmccart commented Jan 15, 2020

@jatin33 maybe you'd like to look at this one?

@Pedroxam
Copy link

Pedroxam commented Sep 24, 2020

Adding shadow to objects is easy :

var context = drawingContext; // or p5.drawingContext
context .shadowOffsetX = 5;
context .shadowOffsetY = -5;
context .shadowBlur = 10;
context .shadowColor = '#FFF';

@8o8inCodes
Copy link

Adding shadow to objects is easy :

var context = drawingContext; // or p5.drawingContext
context .shadowOffsetX = 5;
context .shadowOffsetY = -5;
context .shadowBlur = 10;
context .shadowColor = '#FFF';

Here is a documentation
https://p5js.org/reference/#/p5/drawingContext

@nnmrts
Copy link

nnmrts commented Aug 15, 2021

Yeah drawing a line without p5 on a canvas is "easy" too:

const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');

ctx.beginPath();       // Start a new path
ctx.moveTo(30, 50);    // Move the pen to (30, 50)
ctx.lineTo(150, 100);  // Draw a line to (150, 100)
ctx.stroke();

That's not the point of the issue though. Saying "I'm not sure a wrapper of these is necessary" would imply that 90% of p5.js is not necessary, most of it is just a wrapper around canvas stuff.

But I guess it's not in the scope of a creative coding library to add more accessible support for shadows.

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

No branches or pull requests

7 participants