Database Search
Browse 1,393 Games , 57,550 Screens and 2,050 Videos
The Ultimate reference tool for game designers.
Game UI Database was created by
Filters
GAME FILTERS
Platform
Genre
Theme
Aesthetic
Camera
SCREEN FILTERS
Elements
UI Style
Patterns & Shapes
Materials & Textures
Colour
VIDEO FILTERS
Screen Transitions
Looping Animations
Screen Patterns
");
updateGrid();
if (firstClick != 0) {
}
$('.overlay_main').css('width', '');
$('.filmreel').removeClass('enabled');
$('.overlay_top-bar').css('top', '0px');
$('.overlay_caption').css('bottom', '0px');
imageCanvas = document.getElementById('highlightCanvas');
ctx = imageCanvas.getContext('2d');
img = new Image();
img.src = imageGallery[thisGalleryID][currentImageIndex].URL;
img.onload = function() {
imageCanvas.width = img.width;
imageCanvas.height = img.height;
ctx.drawImage(img, 0, 0);
ctx.globalAlpha = 0;
ctx.fillStyle = 'black';
ctx.fillRect(0, 0, imageCanvas.width, imageCanvas.height);
};
}
$( "#text_" + currentImageIndex ).contents().clone().prependTo( ".overlay_main > div" ).hide().fadeIn();
var leftIndex = currentImageIndex - 1;
var rightIndex = parseInt(currentImageIndex) + parseInt(1);
if (currentImageIndex == 0) {
leftIndex = imageGallery[thisGalleryID].length - 1;
}
if (currentImageIndex == (imageGallery[thisGalleryID].length - 1)) {
rightIndex = 0;
}
if (imageGallery[thisGalleryID][leftIndex].URL.substr(-4) === '.mp4') {
$('.overlay_left').html("");
} else {
$('.overlay_left').html("");
}
if (imageGallery[thisGalleryID][rightIndex].URL.substr(-4) === '.mp4') {
$('.overlay_right').html("");
} else {
$('.overlay_right').html("");
}
$('.image_final').on('load', function() {
$(this).prev().fadeOut(10, function() {
$(this).remove();
if ((inspectorView == 0) && (gridEnabled == 1)) {
$('.overlay_main > div').css('width', 'fit-content');
} else {
$('.overlay_main > div').css('width', '');
}
$('.gridcss').css('opacity', '1');
});
});
if (inspectorView == 1) {
clearTimeout(updateTimeout);
if (inspectorAJAXrequest) {
inspectorAJAXrequest.abort();
inspectorAJAXrequest = null;
}
if (videoInspectorAJAXrequest) {
videoInspectorAJAXrequest.abort();
videoInspectorAJAXrequest = null;
}
if (ocrAJAXrequest) {
ocrAJAXrequest.abort();
ocrAJAXrequest = null;
}
$(".guidbGallery_inspector").html("");
if (imageGallery[thisGalleryID][currentImageIndex].video == true) {
$('.overlay_main').html("");
var src = imageGallery[thisGalleryID][currentImageIndex].URL;
var iframedata = '';
$('.overlay_main div').html(iframedata);
$('video').prop('muted', false);
$('.overlay_main').css('width', '');
} else {
$('div[id="ocr"]').remove();
$('.overlay_main > div').append("");
$('.overlay_main').css('width', 'max-content');
ocrAJAXrequest = $.ajax({
url: "galleryscript/inspector_OCR.php",
type: "GET",
data: { id: imageGallery[thisGalleryID][currentImageIndex].imageID, w: imageGallery[thisGalleryID][currentImageIndex].width, h: imageGallery[thisGalleryID][currentImageIndex].height },
success: function(data) {
$('#ocr').html(data);
if ($(window).width() > 767) {
$('[data-bs-toggle="tooltip"]').tooltip();
}
}
});
}
$(".guidbGallery_inspector").append('
');
updateTimeout = setTimeout(function() {
inspectorAJAXrequest = $.ajax({
url: "galleryscript/inspector.php",
type: "GET",
data: { id: imageGallery[thisGalleryID][currentImageIndex].imageID },
cache: false,
success: function(data) {
$('#inspector_content').html(data);
updateColourHighlights();
}
});
}, 50);
if (window.location.href.indexOf('inspector=') == -1) {
var newURL = window.location.href;
if (window.location.href.indexOf('?') == -1) {
newURL += '?inspector=1';
} else {
newURL += '&inspector=1';
}
window.history.pushState({ path: newURL }, '', newURL);
}
}
$('body, .overlay_top-bar, .overlay_caption, .guidbGallery_overlay, .overlay_media, .image_final').on('touchmove', function(e) {
e.preventDefault();
});
}
$(window).resize(function() {
if (overlayStatus == 0) {
return;
}
if (inspectorView == 0) {
if (inspectorView == 1 && $(window).width() < imageGallery[thisGalleryID][currentImageIndex].width) {
$('.overlay_media').css('width', 'inherit');
} else {
$('.overlay_main').css('width', '');
}
}
});
$('.arrow-left').click(function(event) {
if (overlayStatus == 0) {
return;
}
if (currentImageIndex == 0) {
currentImageIndex = imageGallery[thisGalleryID].length - 1;
} else {
currentImageIndex--;
}
setTimeout(function() {
updateGallery();
}, 100);
});
$('.arrow-right').click(function(event) {
if (overlayStatus == 0) {
return;
}
if (currentImageIndex == (imageGallery[thisGalleryID].length - 1)) {
currentImageIndex = 0;
} else {
currentImageIndex++;
}
setTimeout(function() {
updateGallery();
}, 100);
});
$('.overlay_close').click(function(event) {
if (overlayStatus == 0) {
return;
}
if (overlayStatus == 1) {
hideGallery();
}
});
$('#guidbGallery_swipebox').remove();
var galleryTarget = $('#guidbGallery_mediaall');
$(function() {
var startX, startY, currentX, currentY, movedX, movedY, mousemove, scaling = false;
var initialDistance = null;
var initialAngle = 0;
var baseScale = 1;
var currentScale = 1;
var currentRotation = 0;
var initialTouchPosition = { x: null, y: null };
var accumulatedTranslation = { x: 0, y: 0 };
reset();
function getCoordinates(event) {
if (event.originalEvent.touches && event.originalEvent.touches.length) {
return { x: event.originalEvent.touches[0].pageX, y: event.originalEvent.touches[0].pageY };
} else {
return { x: event.pageX, y: event.pageY };
}
}
function reset() {
startX = 0;
startY = 0;
currentX = 0;
currentY = 0;
movedX = 0;
movedY = 0;
mousemove = 0;
scaling = false;
$(".guidbGallery_mediaall").stop(true, true);
$(".guidbGallery_mediaall").css('left', '0');
$('.overlay_media').css('filter', 'brightness(1)');
galleryTarget.css('cursor', 'grab');
}
galleryTarget.on('mousedown touchstart', function(e) {
e.preventDefault();
reset();
if ($(e.target).closest('.gridcss > div').length) {
return;
}
if (inspectorView == 1 ) {
return;
}
if ($(e.target).closest('button').length) {
return;
}
if ((e.originalEvent.touches) && (e.originalEvent.touches.length === 2)) {
scaling = true;
pinchStart(e);
}
if (scaling == false) {
var coords = getCoordinates(e);
startX = coords.x;
startY = coords.y;
mousemove = 1;
galleryTarget.css('cursor', 'grabbing');
} else {
pinchStart(e);
}
if (currentScale == 1) {
resetFadeOutTopBar();
}
});
galleryTarget.on('mousemove touchmove', function(e) {
e.preventDefault();
e.stopPropagation();
var coords = getCoordinates(e);
currentX = coords.x;
currentY = coords.y;
movedX = currentX - startX;
movedY = currentY - startY;
if (scaling == true) {
pinchMove(e);
return;
} else if ( ((currentScale < 0.9) || (currentScale > 1.1)) && (scaling == false)) {
zoomMove(e);
return;
} else {
if (mousemove == 1) {
if ((currentX >= (startX + 30)) || (currentX <= (startX - 30))) {
mousemove = 2;
}
if ((currentY >= (startY + 50)) || (currentY <= (startY - 50))) {
mousemove = 3;
}
}
if (mousemove == 2) {
panHorizontal(movedX);
}
if (mousemove == 3) {
panVertical(movedY);
}
}
if (currentScale == 1) {
resetFadeOutTopBar();
}
});
$(window).on('mouseup touchend', function(e) {
if (currentScale == 1) {
resetFadeOutTopBar();
}
if (scaling == true) {
pinchEnd(e);
scaling = false;
} else if ((movedX == 0) && (movedY == 0)) {
reset();
zoomReset();
return;
}
if (mousemove == 2) {
if (movedX <= -30) {
slideRight();
} else if (movedX >= 30) {
slideLeft();
} else {
slideReset();
}
}
if (mousemove == 3) {
if (movedY <= -120) {
slideUp();
} else if (movedY >= 120) {
slideDown();
} else {
slideReset();
}
$(".guidbGallery_overlay").animate({
opacity: '0.95'
}, {
duration: 200
});
}
mousemove = 0;
galleryTarget.css('cursor', 'grab');
});
function calculateDistance(touches) {
let touch1 = touches[0];
let touch2 = touches[1];
return Math.sqrt(Math.pow(touch1.pageX - touch2.pageX, 2) + Math.pow(touch1.pageY - touch2.pageY, 2));
}
function calculateAngle(touches) {
let touch1 = touches[0];
let touch2 = touches[1];
return Math.atan2(touch2.pageY - touch1.pageY, touch2.pageX - touch1.pageX) * 180 / Math.PI;
}
function zoomReset() {
if ($('.overlay_main').find('video').length > 0) {
var img = $('.overlay_main div .overlay_video');
} else {
var img = $('.overlay_main div .image_final');
}
img.css('transition', 'transform 0.2s ease-out');
img.css('transform', '');
setTimeout(function() {
img.css('transition', '');
}, 200);
initialDistance = null;
initialAngle = 0;
baseScale = 1;
currentScale = 1;
currentRotation = 0;
initialTouchPosition = { x: null, y: null };
accumulatedTranslation = { x: 0, y: 0 };
$('.overlay_left').show();
$('.overlay_right').show();
resetFadeOutTopBar();
}
function pinchStart(e) {
if (e.touches.length === 2) {
initialTouchPosition.x = e.touches[0].pageX;
initialTouchPosition.y = e.touches[0].pageY;
initialDistance = calculateDistance(e.touches);
initialAngle = calculateAngle(e.touches);
currentScale = baseScale;
$("#mainthumbnail").css('opacity', '0');
} else if (e.touches.length === 2) {
initialTouchPosition.x = e.touches[0].pageX;
initialTouchPosition.y = e.touches[0].pageY;
}
}
var sensitivity = 0.5;
function pinchMove(e) {
if (e.touches.length === 2 && initialDistance != null) {
if ($('.overlay_main').find('video').length > 0) {
var image = $('.overlay_main div .overlay_video');
} else {
var image = $('.overlay_main div .image_final');
}
var currentDistance = calculateDistance(e.touches);
var currentAngle = calculateAngle(e.touches);
var scaleChange = currentDistance / initialDistance;
var angleChange = currentAngle - initialAngle;
currentScale = baseScale * scaleChange;
currentRotation += angleChange;
var deltaX = (e.touches[0].pageX - initialTouchPosition.x) * sensitivity;
var deltaY = (e.touches[0].pageY - initialTouchPosition.y) * sensitivity;
accumulatedTranslation.x += deltaX;
accumulatedTranslation.y += deltaY;
initialTouchPosition.x = e.touches[0].pageX;
initialTouchPosition.y = e.touches[0].pageY;
initialAngle = currentAngle;
image.css('transform', `scale(${currentScale}) rotate(${currentRotation}deg) translate(${accumulatedTranslation.x}px, ${accumulatedTranslation.y}px)`);
}
}
function zoomMove(e) {
if (e.originalEvent.touches.length === 1 && scaling === false) {
var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
var deltaX = (touch.pageX - startX);
var deltaY = (touch.pageY - startY);
var image;
if ($('.overlay_main').find('video').length > 0) {
image = $('.overlay_main div .overlay_video');
} else {
image = $('.overlay_main div .image_final');
}
var newPosX = accumulatedTranslation.x + deltaX;
var newPosY = accumulatedTranslation.y + deltaY;
if ((Math.abs(accumulatedTranslation.x - newPosX) > 150) || (Math.abs(accumulatedTranslation.y - newPosY) > 150)) {
return;
}
image.css('transform', `scale(${currentScale}) rotate(${currentRotation}deg) translate(${newPosX}px, ${newPosY}px)`);
accumulatedTranslation.x = newPosX;
accumulatedTranslation.y = newPosY;
startX = touch.pageX;
startY = touch.pageY;
}
}
function pinchEnd(e) {
baseScale = currentScale;
initialDistance = null;
if (currentScale != 1) {
return;
}
$('.overlay_left').show();
$('.overlay_right').show();
}
function panStart() {
$(".guidbGallery_mediaall").stop(true, true);
$(".guidbGallery_mediaall").css('left', '0');
mousemove = 0;
$('.overlay_media').css('filter', 'brightness(1)');
}
function panVertical(mouseposY) {
$('.overlay_top-bar').hide();
$('.overlay_caption').hide();
currentDistance = mouseposY;
$(".guidbGallery_mediaall").css('top', currentDistance);
if (currentDistance > 0) {
$(".guidbGallery_overlay").css('opacity', 0.95 - (currentDistance / 1000));
} else {
$(".guidbGallery_overlay").css('opacity', 0.95 + (currentDistance / 1000));
}
}
function panHorizontal(mouseposX) {
var dampingFactor = 0.9;
currentDistance = mouseposX * dampingFactor;
$(".guidbGallery_mediaall").css('left', currentDistance + 'px');
if ($('.overlay_main').find('video').length > 0) {
$('.overlay_main').find('video').get(0).pause();
}
}
var slideTime = 220;
function slideRight() {
$(".guidbGallery_mediaall").stop(true, true);
$(".guidbGallery_mediaall").animate({
left: '-100%'
}, {
duration: slideTime,
easing: "swing",
complete: function() {
if (currentImageIndex == (imageGallery[thisGalleryID].length - 1)) {
currentImageIndex = 0;
} else {
currentImageIndex++;
}
$('.overlay_left').removeClass('overlay_left').addClass('overlay_2');
$('.overlay_main').removeClass('overlay_main').addClass('overlay_1');
$('.overlay_right').removeClass('overlay_right').addClass('overlay_main');
$('.overlay_1').removeClass('overlay_1').addClass('overlay_left');
$('.overlay_2').removeClass('overlay_2').addClass('overlay_right');
updateGallery();
$(".guidbGallery_mediaall").css({
left: '0px'
});
$(".guidbGallery_mediaall").stop(true, true);
}
});
}
function slideLeft() {
$(".guidbGallery_mediaall").stop(true, true);
$(".guidbGallery_mediaall").animate({
left: '100%'
}, {
duration: slideTime,
easing: "swing",
complete: function() {
if (currentImageIndex == 0) {
currentImageIndex = imageGallery[thisGalleryID].length - 1;
} else {
currentImageIndex--;
}
$('.overlay_right').removeClass('overlay_right').addClass('overlay_2');
$('.overlay_main').removeClass('overlay_main').addClass('overlay_1');
$('.overlay_left').removeClass('overlay_left').addClass('overlay_main');
$('.overlay_1').removeClass('overlay_1').addClass('overlay_left');
$('.overlay_2').removeClass('overlay_2').addClass('overlay_right');
updateGallery();
$(".guidbGallery_mediaall").css({
left: '0px'
});
$(".guidbGallery_mediaall").stop(true, true);
}
});
}
function slideUp() {
$(".guidbGallery_mediaall").animate({
top: '-70%'
}, {
duration: 100,
easing: "easeOutCirc",
complete: function() {
}
});
hideGallery();
}
function slideDown() {
$(".guidbGallery_mediaall").animate({
top: '70%'
}, {
duration: 100,
easing: "easeOutCirc",
complete: function() {
}
});
hideGallery();
}
function slideReset() {
$(".guidbGallery_mediaall").animate({
left: '0px', top: '0%'
}, {
duration: 260,
easing: "swing"
});
if ($('.overlay_main').find('video').length > 0) {
$('.overlay_main').find('video').get(0).play();
}
$('.overlay_top-bar').show();
$('.overlay_caption').show();
}
});
var fadeTimer = 0;
function fadeOutTopBar() {
if (fadeTimer != 0) {
clearTimeout(fadeTimer);
}
fadeTimer = setTimeout(function() {
$('.overlay_top-bar').css('opacity', '0');
$('.overlay_caption').css('opacity', '0');
}, 2000);
}
fadeOutTopBar();
function resetFadeOutTopBar() {
if (fadeTimer != 0) {
clearTimeout(fadeTimer);
}
fadeOutTopBar();
$('.overlay_top-bar').css('opacity', '1');
$('.overlay_caption').css('opacity', '1');
}
$('#guidbGallery_mediaall').mousemove(function() {
resetFadeOutTopBar();
});
$(window).mousemove(function() {
resetFadeOutTopBar();
});
var inspectorView = 0;
$('#guidbGallery_toggle').click(function(event) {
inspectorView = 1 - inspectorView;
if (inspectorView == 1) {
$('#guidbGallery_toggle').addClass('enabled');
$('.guidbGallery_inspector').addClass('enabled');
$("#overlay_container_inner").addClass("inspector");
$('.overlay_left').css('display', 'none');
$('.overlay_right').css('display', 'none');
$('#guidbGallery_toggle').html('');
enableInspector();
} else {
$('#guidbGallery_toggle').removeClass('enabled');
$('.guidbGallery_inspector').removeClass('enabled');
$("#overlay_container_inner").removeClass("inspector");
setTimeout(function() {
$('.overlay_left').css('display', 'flex');
$('.overlay_right').css('display', 'flex');
}, 300);
$('#guidbGallery_toggle').html('');
disableInspector();
}
});
function enableInspector() {
$('.overlay_caption').addClass('inspector');
$('.overlay_top-bar').addClass('inspector');
$('.guidbGallery_mediaall').addClass('inspector');
$(".overlay_media").css('display', 'block');
$(".guidbGallery_overlay").animate({
opacity: '1'
}, {
duration: 500
});
$(".guidbGallery_mediaall").animate({
width: '70%'
}, {
duration: 300,
easing: "easeOutCirc"
});
$(".overlay_right").animate({
opacity: '0'
}, {
duration: 300,
easing: "easeOutCirc"
}, {
complete: function() {
$(".overlay_right").css('display', 'none');
}
});
$(".overlay_left").animate({
opacity: '0'
}, {
duration: 300,
easing: "easeOutCirc"
}, {
complete: function() {
$(".overlay_left").css('display', 'none');
}
});
$(".guidbGallery_inspector").html("");
if (imageGallery[thisGalleryID][currentImageIndex].video == true) {
$('video').prop('muted', false);
var src = $('video source').attr('src');
var iframedata = '';
$('.overlay_main div').html(iframedata);
$('.overlay_main > div').css('width', '');
$('.overlay_main').css('width', '');
} else {
$('div[id="ocr"]').remove();
$('.overlay_main').append("");
$('#ocr').load("galleryscript/inspector_OCR.php?id=" + imageGallery[thisGalleryID][currentImageIndex].imageID + "&w=" + imageGallery[thisGalleryID][currentImageIndex].width + "&h=" + imageGallery[thisGalleryID][currentImageIndex].height, function() {
if ($(window).width() > 767) {
$('[data-bs-toggle="tooltip"]').tooltip();
}
});
$('.overlay_main').css('width', 'max-content');
}
$.get("galleryscript/inspector.php?id=" + imageGallery[thisGalleryID][currentImageIndex].imageID, function(data) {
$(".guidbGallery_inspector").append(data);
updateColourHighlights();
});
$('.filmreel').removeClass('enabled');
$('.overlay_top-bar').css('top', '0px');
$('.overlay_caption').css('bottom', '0px');
if (window.location.href.indexOf('inspector=') == -1) {
var newURL = window.location.href;
if (window.location.href.indexOf('?') == -1) {
newURL += '?inspector=1';
} else {
newURL += '&inspector=1';
}
window.history.pushState({ path: newURL }, '', newURL);
}
}
function disableInspector() {
$('.overlay_caption').removeClass('inspector');
$('.overlay_top-bar').removeClass('inspector');
$('.guidbGallery_mediaall').removeClass('inspector');
$(".overlay_media").css('display', 'flex');
$(".overlay_left").css('display', 'flex');
$(".overlay_right").css('display', 'flex');
$('.overlay_main').css('width', '');
$(".guidbGallery_overlay").animate({
opacity: '0.95'
}, {
duration: 500
});
$(".guidbGallery_mediaall").animate({
width: '100%'
}, {
duration: 400,
easing: "easeOutCirc"
});
$(".overlay_right").animate({
opacity: '1'
}, {
duration: 100,
easing: "easeOutCirc"
});
$(".overlay_left").animate({
opacity: '1'
}, {
duration: 100,
easing: "easeOutCirc"
});
updateGallery();
if (window.location.href.indexOf('inspector=') != -1) {
var newURL = window.location.href.replace(/&?inspector=1/, '');
window.history.pushState({ path: newURL }, '', newURL);
}
}
function hideAllSubmenus() {
$(".visualizermenu").hide();
$(".gridmenu").hide();
}
$("#guidbGallery_visualizer").click(function() {
hideAllSubmenus();
$(".visualizermenu").toggle();
});
$("#guidbGallery_grid").click(function() {
hideAllSubmenus();
$(".gridmenu").toggle();
});
$(document).mouseup(function(e) {
var container = $(".hexSubmenu");
if (!container.is(e.target) && container.has(e.target).length === 0) {
container.hide();
}
});
var gridEnabled = 0;
$(".gridPlus").click(function() {
$(this).parent().find('input').val(parseInt($(this).parent().find('input').val()) + 1);
if ($(this).parent().find('input').val() < 1) {
$(this).parent().find('input').val(1);
}
updateGrid();
});
$(".gridMinus").click(function() {
$(this).parent().find('input').val(parseInt($(this).parent().find('input').val()) - 1);
if ($(this).parent().find('input').val() < 1) {
$(this).parent().find('input').val(1);
}
updateGrid();
});
$(".gridInput").change(function() {
updateGrid();
if ($(this).val() < 1) {
$(this).val(1);
}
});
function updateGrid() {
$('.grid .vertical').html('');
$('.grid .horizontal').html('');
var rows = parseInt($('#grid_horizontalCells').val());
var cols = parseInt($('#grid_verticalCells').val());
var totalGrid = rows * cols;
$('.gridcss').css('grid-template-columns', 'repeat(' + cols + ', 1fr)');
$('.gridcss').css('grid-template-rows', 'repeat(' + rows + ', 1fr)');
$('.gridcss').css('grid-column-gap', $('#grid_verticalGap').val() + 'px');
$('.gridcss').css('grid-row-gap', $('#grid_horizontalGap').val() + 'px');
$('.gridcss').html('');
for (i = 0; i < totalGrid; i++) {
var gridClasses = "";
if (i < (cols)) {
gridClasses += " toprow";
}
if (i > (totalGrid - cols - 1)) {
gridClasses += " bottomrow";
}
if (i % cols == 0) {
gridClasses += " leftcol";
}
if (i % cols == (cols - 1)) {
gridClasses += " rightcol";
}
$('.gridcss').append('');
}
if (totalGrid < 2) {
$('#gridOptions').hide();
gridEnabled = 0;
} else {
$('#gridOptions').show();
gridEnabled = 1;
}
if (inspectorView == 0 && (gridEnabled == 1)) {
$('.overlay_main > div').css('width', 'fit-content');
} else {
$('.overlay_main > div').css('width', '');
}
}
$('#resetGrid').click(function() {
$('#grid_verticalCells').val(1);
$('#grid_horizontalCells').val(1);
$('#gridOptions').hide();
updateGrid();
});
function convertGridToSVG(width, height) {
var ns = 'http://www.w3.org/2000/svg';
var svg = document.createElementNS(ns, 'svg');
svg.setAttributeNS(null, 'width', width);
svg.setAttributeNS(null, 'height', height);
let $grid = $('.gridcss');
let columns = $grid.css('grid-template-columns').split(' ').length;
let rows = $grid.css('grid-template-rows').split(' ').length;
for (let i = 1; i < rows; i++) {
let line = document.createElementNS(ns, 'line');
line.setAttributeNS(null, 'x1', '0%');
line.setAttributeNS(null, 'y1', (i * (100 / rows)) + '%');
line.setAttributeNS(null, 'x2', '100%');
line.setAttributeNS(null, 'y2', (i * (100 / rows)) + '%');
line.setAttributeNS(null, 'stroke', 'white');
svg.appendChild(line);
}
for (let i = 1; i < columns; i++) {
let line = document.createElementNS(ns, 'line');
line.setAttributeNS(null, 'x1', (i * (100 / columns)) + '%');
line.setAttributeNS(null, 'y1', '0%');
line.setAttributeNS(null, 'x2', (i * (100 / columns)) + '%');
line.setAttributeNS(null, 'y2', '100%');
line.setAttributeNS(null, 'stroke', 'white');
svg.appendChild(line);
}
var serializer = new XMLSerializer();
var svgString = serializer.serializeToString(svg);
var textarea = document.createElement('textarea');
document.body.appendChild(textarea);
textarea.value = svgString;
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
}
$('#exportGrid').click(function() {
convertGridToSVG(imageGallery[thisGalleryID][currentImageIndex].width, imageGallery[thisGalleryID][currentImageIndex].height);
});
$("input[name='gallery_visualizer']").on('change', function() {
removeAllFilters();
let filterType = $(this).val();
switch(filterType) {
case 'default':
removeAllFilters()
break;
case 'greyscale':
$('.guidbGallery_mediaall').addClass('filter_greyscale');
break;
case 'inversionFilter':
$('.guidbGallery_mediaall').addClass('filter_invert');
break;
case 'protanopiaFilter':
$('.guidbGallery_mediaall').addClass('filter_protanopia');
break;
case 'deutranopiaFilter':
$('.guidbGallery_mediaall').addClass('filter_deutranopia');
break;
case 'tritanopiaFilter':
$('.guidbGallery_mediaall').addClass('filter_tritanopia');
break;
case 'scanlineFilter':
$('.guidbGallery_mediaall').addClass('scanlines');
break;
case 'audienceFilter':
$('.visAudience').show();
break;
}
});
function removeAllFilters() {
$('.guidbGallery_mediaall').removeClass('filter_greyscale');
$('.guidbGallery_mediaall').removeClass('filter_invert');
$('.guidbGallery_mediaall').removeClass('filter_protanopia');
$('.guidbGallery_mediaall').removeClass('filter_deutranopia');
$('.guidbGallery_mediaall').removeClass('filter_tritanopia');
$('.guidbGallery_mediaall').removeClass('scanlines');
$('.visAudience').hide();
}
$('#guidbGallery_clipboard').click(async function() {
const $img = $('.overlay_main .image_final');
const img = $img.get(0);
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const imgElement = new Image();
imgElement.crossOrigin = 'Anonymous';
imgElement.src = img.src;
imgElement.onload = async function() {
canvas.width = imgElement.width;
canvas.height = imgElement.height;
ctx.drawImage(imgElement, 0, 0);
canvas.toBlob(async function(blob) {
try {
const data = [new ClipboardItem({ 'image/png': blob })];
await navigator.clipboard.write(data);
} catch (err) {
console.error('Failed to copy image: ', err);
}
}, 'image/png');
};
imgElement.onerror = function() {
console.error('Failed to load the image for copying.');
};
});
$('#guidbGallery_videoclipboard').click(async function() {
let video;
if (inspectorView == 1) {
const iframe = document.getElementById('inspectorImage');
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
video = iframeDocument.querySelector('video');
} else {
const $video = $('.overlay_main video');
video = $video.get(0);
}
if (video) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
canvas.toBlob(async function(blob) {
try {
const data = [new ClipboardItem({ 'image/png': blob })];
await navigator.clipboard.write(data);
} catch (err) {
console.error('Failed to copy video frame: ', err);
}
}, 'image/png');
} else {
console.error('Video element not found.');
}
});
function playVideo() {
$('video').prop('muted', true);
$('video').get(0).play();
}
window.addEventListener("orientationchange", function() {
window.scrollTo(0, 0);
if ((window.orientation === 90) || (window.orientation === -90)) {
$('#test').html('Landscape');
} else {
$('#test').html('Portrait');
}
}, false);
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
function playPopcornSound(maxY) {
if ($("input[name='gallery_visualizer']:checked").val() != 'audienceFilter') {
return;
}
fetch('img/throw.wav')
.then(response => response.arrayBuffer())
.then(arrayBuffer => audioCtx.decodeAudioData(arrayBuffer))
.then(audioBuffer => {
var source = audioCtx.createBufferSource();
source.buffer = audioBuffer;
var playbackRate = 0 + (maxY / 1000) * 2;
source.playbackRate.value = playbackRate;
source.connect(audioCtx.destination);
source.start(0);
})
.catch(e => console.error(e));
}
$(document).keydown(function(e) {
if ($("input[name='gallery_visualizer']:checked").val() != 'audienceFilter') {
return;
}
if (e.key === "u" || e.key === "U") {
var startX = Math.random() * $(window).width();
var randX = (startX < ($(window).width() / 3)) ? -200 : 200;
var endX = startX + (Math.random() * 200 - randX);
var controlX = (startX + endX) / 2;
var maxY = ($(window).height() / 2) + (Math.random() * 700 - 50);
var startRotation = Math.random() * 360;
playPopcornSound(maxY);
var img = $("", {
src: "img/popcorn.png",
class: "popcorn",
css: {
position: 'absolute',
bottom: 0,
left: startX,
transform: 'rotate(' + startRotation + 'deg)'
}
}).appendTo("#overlay_container_inner");
$({counter: 0}).animate({counter: 1}, {
duration: 1000,
step: function(t) {
var x = (1-t)*(1-t)*startX + 2*(1-t)*t*controlX + t*t*endX;
var y = (1-t)*(1-t)*0 + 2*(1-t)*t*maxY + t*t*0;
img.css({
left: x,
bottom: y,
transform: 'rotate(' + startRotation + 'deg) scale(' + (1 - t) + ')'
});
},
complete: function() {
img.remove();
}
});
}
});
$(document).keydown(function(e) {
if ($("input[name='gallery_visualizer']:checked").val() != 'audienceFilter') {
return;
}
if (e.key === "l" || e.key === "L") {
var startX = Math.random() * $(window).width();
var img = $("", {
src: "img/heart.png",
class: "heart",
css: {
position: 'absolute',
bottom: 0,
left: startX
}
}).appendTo("#overlay_container_inner");
$({counter: 0}).animate({counter: 1}, {
duration: 2000,
step: function(t) {
var y = $(window).height() * t;
var oscillation = 10 * Math.sin(2 * Math.PI * t * 3);
var scale = 0.7 - t;
img.css({
bottom: y,
left: startX + oscillation,
opacity: 1 - t,
transform: 'scale(' + scale + ')'
});
},
complete: function() {
img.remove();
}
});
}
});