CodingTrain / CodingTrain/Suggestion-Box

P5.js - Dealing with canvas in the background

Đang mở
#201 0 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
570
Fork
85
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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");

}

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Issue đề cập đến một canvas p5.js toàn màn hình, các nút DOM, createCanvas, windowWidth, windowHeight, canvas.position và canvas.style; không có tệp repository hoặc test nào được nêu tên. Hãy bắt đầu bằng việc xem lại tài liệu playlist DOM hiện có và coi là hoàn tất khi hướng dẫn về layering giữa canvas/DOM được ghi lại dưới dạng một chủ đề video.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript
Lĩnh vực
content, documentation, web-dev
Loại issue
Tài liệu
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.