CodingTrain / CodingTrain/Suggestion-Box
P5.js - Dealing with canvas in the background
- Langage dominant
- Aucune donnée de langage
- Étoiles
- 570
- Forks
- 85
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
Hi, for one of my own project, I needed to realize a full screen animation (character walking on a terrain made of tiles) with dom elements as a user interface. My problem soon became clear : if my canvas was full screen, I couldn't access the dom elements layered "on top" of the canvas (click buttons and such was impossible) .
I found a solution myself, but I believe there are others and would love to see how you'd handle it. I really struggled myself, and I thinks it's a problem (although not a hard one) that is sufficient for a small video in the dom playlist.
My solution :
//________________________________________________________________
var canvas;
var domElement;
function setup(){
canvas = createCanvas(windowWidth, windowHeight)
canvas.position(0,0);
domElement = createButton('You can't click me');
domElement.style("height", "100px");
domElement.style("width", "100px");
domElement.position(0,0));
/*Using this line, the button is clickable. Good thing is, the canvas' surface which is not covered by a dom element is still clickable. I'm literally using this all the time. Allows for easy UI making. */
canvas.style("z-index", "-1");
}
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
L’issue mentionne un canvas p5.js en plein écran, des boutons DOM, createCanvas, windowWidth, windowHeight, canvas.position et canvas.style ; aucun fichier du dépôt ni aucun test n’est nommé. Commencez par examiner le matériel existant de la playlist DOM et considérez-le comme terminé lorsque les indications sur la superposition du canvas et du DOM sont documentées comme sujet de vidéo.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript
- Domaine
- content, documentation, web-dev
- Type d'issue
- Documentation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 25/100