extras:codikon:sonstiges:dome_projection_v01
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| extras:codikon:sonstiges:dome_projection_v01 [2025/07/06 07:48] – removed - external edit (Unknown date) 127.0.0.1 | extras:codikon:sonstiges:dome_projection_v01 [2025/11/26 14:15] (current) – Felix Hardmood Beck | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | Auch hier: https:// | ||
| + | |||
| + | < | ||
| + | |||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | <meta charset=" | ||
| + | < | ||
| + | <script src=" | ||
| + | <script src=" | ||
| + | < | ||
| + | body { margin: 0; overflow: hidden; background: black; } | ||
| + | canvas { display: block; position: absolute; z-index: -1; } | ||
| + | # | ||
| + | # | ||
| + | position: absolute; left: 50px; top: 50px; | ||
| + | background: rgba(0, | ||
| + | border: 1px solid red; border-radius: | ||
| + | z-index: 20; display: none; | ||
| + | } | ||
| + | .dg.main { background-color: | ||
| + | .dg .close-button { display: none !important; } | ||
| + | .dg .slider-fg { background: red !important; } | ||
| + | .dg .c .slider { background: #444 !important; } | ||
| + | .dg .cr.number { border-left: | ||
| + | .dg input[type=" | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | <div id=" | ||
| + | <div id=" | ||
| + | < | ||
| + | [h] Show/Hide Handles and GUI< | ||
| + | [r] Reset Workspace< | ||
| + | [a] Fill Circle Red< | ||
| + | [b] Fill Circle Green< | ||
| + | [c] Fill Circle Blue< | ||
| + | [d] Fill Circle Yellow< | ||
| + | [0] Remove Circle Fill< | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | let corners = [], circleCenter, | ||
| + | let showHandles = false, circleFillColor = null; | ||
| + | const cornerRadius = 25, interfaceSize = { w: 240, h: 80 }; | ||
| + | let params = { Diameter: 400 }, gui; | ||
| + | |||
| + | function setup() { | ||
| + | createCanvas(windowWidth, | ||
| + | resetCorners(); | ||
| + | gui = new dat.GUI({ autoPlace: false }); | ||
| + | document.getElementById(' | ||
| + | gui.add(params, | ||
| + | document.getElementById(' | ||
| + | } | ||
| + | |||
| + | function draw() { | ||
| + | background(0); | ||
| + | fill(50); noStroke(); | ||
| + | beginShape(); | ||
| + | if (circleFillColor) fill(circleFillColor); | ||
| + | stroke(255); | ||
| + | ellipse(circleCenter.x, | ||
| + | noStroke(); | ||
| + | rectMode(CENTER); | ||
| + | for (let el of interfaceElements) { | ||
| + | push(); | ||
| + | translate(el.position.x, | ||
| + | rotate(radians(el.rotation)); | ||
| + | fill(100); rect(0, 0, interfaceSize.w, | ||
| + | fill(255); text(el.label, | ||
| + | if (showHandles) { fill(255, 0, 0); ellipse(0, 0, cornerRadius); | ||
| + | pop(); | ||
| + | } | ||
| + | if (showHandles) { | ||
| + | fill(255, 0, 0); | ||
| + | for (let pt of corners) ellipse(pt.x, | ||
| + | ellipse(circleCenter.x, | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function mousePressed() { | ||
| + | const guiBounds = document.getElementById(' | ||
| + | if (mouseX >= guiBounds.left && mouseX <= guiBounds.left + guiBounds.width && | ||
| + | mouseY >= guiBounds.top && mouseY <= guiBounds.top + guiBounds.height) return; | ||
| + | |||
| + | for (let i = 0; i < interfaceElements.length; | ||
| + | let el = interfaceElements[i]; | ||
| + | let local = screenToLocal(mouseX, | ||
| + | if (local.x > -interfaceSize.w/ | ||
| + | local.y > -interfaceSize.h/ | ||
| + | if (showHandles) { | ||
| + | draggingInterfaceIndex = i; | ||
| + | } else { | ||
| + | if (el.label.includes(" | ||
| + | if (el.label.includes(" | ||
| + | if (el.label.includes(" | ||
| + | if (el.label.includes(" | ||
| + | } | ||
| + | return; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | if (showHandles) { | ||
| + | if (dist(mouseX, | ||
| + | draggingCircleCenter = true; return; | ||
| + | } | ||
| + | for (let i = 0; i < corners.length; | ||
| + | if (dist(mouseX, | ||
| + | draggingIndex = i; return; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | if (!insideWorkArea(mouseX, | ||
| + | } | ||
| + | |||
| + | function screenToLocal(mx, | ||
| + | let dx = mx - el.position.x; | ||
| + | let dy = my - el.position.y; | ||
| + | let angle = radians(-el.rotation); | ||
| + | let localX = dx * cos(angle) - dy * sin(angle); | ||
| + | let localY = dx * sin(angle) + dy * cos(angle); | ||
| + | return {x: localX, y: localY}; | ||
| + | } | ||
| + | |||
| + | function mouseDragged() { | ||
| + | if (draggingIndex !== -1) { | ||
| + | corners[draggingIndex].x = mouseX; | ||
| + | corners[draggingIndex].y = mouseY; | ||
| + | } else if (draggingCircleCenter) { | ||
| + | circleCenter.x = mouseX; | ||
| + | circleCenter.y = mouseY; | ||
| + | } else if (draggingInterfaceIndex !== -1) { | ||
| + | if (insideWorkArea(mouseX, | ||
| + | interfaceElements[draggingInterfaceIndex].position.x = mouseX; | ||
| + | interfaceElements[draggingInterfaceIndex].position.y = mouseY; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function mouseReleased() { | ||
| + | draggingIndex = -1; draggingCircleCenter = false; draggingInterfaceIndex = -1; | ||
| + | } | ||
| + | |||
| + | function keyPressed() { | ||
| + | if (key === ' | ||
| + | showHandles = !showHandles; | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | } | ||
| + | if (key === ' | ||
| + | resetCorners(); | ||
| + | params.Diameter = 400; gui.updateDisplay(); | ||
| + | } | ||
| + | if (key === ' | ||
| + | if (key === ' | ||
| + | if (key === ' | ||
| + | if (key === ' | ||
| + | if (key === ' | ||
| + | } | ||
| + | |||
| + | function windowResized() { resizeCanvas(windowWidth, | ||
| + | |||
| + | function resetCorners() { | ||
| + | const margin = 20; | ||
| + | const s = min(540, (min(windowWidth, | ||
| + | const centerX = windowWidth / 2; | ||
| + | const centerY = windowHeight / 2; | ||
| + | corners = [ | ||
| + | createVector(centerX - s, centerY - s), | ||
| + | createVector(centerX + s, centerY - s), | ||
| + | createVector(centerX + s, centerY + s), | ||
| + | createVector(centerX - s, centerY + s) | ||
| + | ]; | ||
| + | } | ||
| + | |||
| + | function resetCircleCenter() { circleCenter = createVector(windowWidth/ | ||
| + | |||
| + | function setupInterfaceElements() { | ||
| + | const cx = windowWidth / 2, cy = windowHeight / 2; | ||
| + | interfaceElements = [ | ||
| + | { id: " | ||
| + | { id: " | ||
| + | { id: " | ||
| + | { id: " | ||
| + | ]; | ||
| + | } | ||
| + | |||
| + | function insideWorkArea(x, | ||
| + | |||
| + | function collidePointPoly(px, | ||
| + | let collision = false; | ||
| + | for (let current = 0; current < vertices.length; | ||
| + | let next = (current + 1) % vertices.length; | ||
| + | let vc = vertices[current]; | ||
| + | let vn = vertices[next]; | ||
| + | if (((vc.y > py && vn.y < py) || (vc.y < py && vn.y > py)) && | ||
| + | (px < (vn.x - vc.x) * (py - vc.y) / (vn.y - vc.y) + vc.x)) { | ||
| + | collision = !collision; | ||
| + | } | ||
| + | } | ||
| + | return collision; | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | |||
| + | </ | ||
