{ "name" : "ui_editor_preset_clock_title", "description" : "ui_editor_preset_clock_description", "tag" : "scene2d", "group" : "preset", "options" : { "droplistVisible" : true, "droplistOptions" : [ { "label" : "ui_editor_preset_clock_variant_clock", "value" : 0 }, { "label" : "ui_editor_preset_clock_variant_3dclock", "value" : 1 } ] }, "variants" : [ { "preview" : "previewclock/project.json", "objects" : [ { "alpha" : 1.0, "anchor" : "none", "angles" : "0.000 0.000 0.000", "backgroundcolor" : "0.000 0.000 0.000", "color" : "1.000 1.000 1.000", "copybackground" : true, "font" : "fonts/RobotoMono-Regular.ttf", "horizontalalign" : "center", "locktransforms" : false, "name" : "Clock", "opaquebackground" : false, "origin" : "960.000 540.000 0.000", "parallaxDepth" : "1.000 1.000", "perspective" : false, "pointsize" : 32.0, "scale" : "1.000 1.000 1.000", "size" : "379.000 117.000", "solid" : true, "text" : { "script" : "'use strict';\n\nexport var scriptProperties = createScriptProperties()\n\t// Whether you want a 24h or 12h style format\n\t.addCheckbox({\n\t\tname: 'use24hFormat',\n\t\tlabel: 'ui_editor_properties_use_24h_format',\n\t\tvalue: true\n\t})\n\t// Whether you want to see the seconds or not\n\t.addCheckbox({\n\t\tname: 'showSeconds',\n\t\tlabel: 'ui_editor_properties_show_seconds',\n\t\tvalue: false\n\t})\n\t// This will be used to separate each element\n\t.addText({\n\t\tname: 'delimiter',\n\t\tlabel: 'ui_editor_properties_delimiter',\n\t\tvalue: ':'\n\t})\n\t.finish();\n\n/**\n * @param {String} value (for property 'text')\n */\nexport function update(value) {\n\tlet time = new Date();\n\tvar hours = time.getHours();\n\tif (!scriptProperties.use24hFormat) {\n\t\thours %= 12;\n\t\tif (hours == 0) {\n\t\t\thours = 12;\n\t\t}\n\t}\n\thours = (\"00\" + hours).slice(-2);\n\tlet minutes = (\"00\" + time.getMinutes()).slice(-2);\n\tvalue = hours + scriptProperties.delimiter + minutes;\n\tif (scriptProperties.showSeconds) {\n\t\tlet seconds = (\"00\" + time.getSeconds()).slice(-2);\n\t\tvalue += scriptProperties.delimiter + seconds;\n\t}\n\treturn value;\n}\n", "value" : "12:34" }, "verticalalign" : "center", "visible" : true } ] }, { "preview" : "preview3dclock/project.json", "objects" : [ { "alpha" : 1.0, "anchor" : "none", "angles" : "0.000 0.000 0.000", "backgroundcolor" : "0.000 0.000 0.000", "color" : "1.000 1.000 1.000", "copybackground" : true, "font" : "fonts/Monofur-PK7og.ttf", "horizontalalign" : "center", "locktransforms" : false, "name" : "3D Clock", "opaquebackground" : false, "origin" : "960.000 540.000 0.000", "parallaxDepth" : "1.000 1.000", "perspective" : true, "pointsize" : 32.0, "scale" : "1.000 1.000 1.000", "size" : "500.000 100.000", "solid" : true, "text" : { "script" : "'use strict';\n\nimport * as WEMath from 'WEMath';\n\n// This will be used to separate each element\nlet delimiter = ':';\n\n// Whether you want to see the seconds or not\nlet showSeconds = true;\n\n// Whether you want a 24h or 12h style format\nlet use24hFormat = true;\n\n/**\n * @param {String} value (for property 'text')\n */\nvar shadowLayer;\nexport function update(value) {\n\tlet time = new Date();\n\tvar hours;\n\tvar suffix = '';\n\tif (use24hFormat) {\n\t\thours = (\"00\" + time.getHours()).slice(-2);\n\t} else {\n\t\thours = time.getHours();\n\t\tsuffix = hours >= 12 ? 'PM' : 'AM';\n\t\thours %= 12;\n\t\tif (hours == 0) {\n\t\t\thours = 12;\n\t\t}\n\t}\n\tlet minutes = (\"00\" + time.getMinutes()).slice(-2);\n\tlet seconds = (\"00\" + time.getSeconds()).slice(-2);\n\tvalue = hours + delimiter + minutes;\n\tif (showSeconds) {\n\t\tvalue += delimiter + seconds;\n\t}\n\tif (!use24hFormat) {\n\t\tvalue += ' ' + suffix;\n\t}\n\n\tvar delta = thisLayer.origin.subtract(input.cursorWorldPosition);\n\tvar shadowOffset = delta.copy();\n\tshadowOffset.z = 0;\n\tdelta = delta.divide(new Vec3(engine.canvasSize, 1));\n\tdelta.z = 0;\n\tvar rotation = new Vec3(delta.y, -delta.x, 4 * WEMath.mix(delta.x, -delta.x, Math.min(1, Math.max(0, delta.y * 0.1 + 0.5)))).multiply(50);\n\tthisLayer.angles = rotation;\n\tshadowLayer.angles = rotation;\n\tshadowLayer.origin = thisLayer.origin.add(shadowOffset.multiply(0.01));\n\tshadowLayer.text = value;\n\treturn value;\n}\n\n/**\n * @param {String} value (for property 'text')\n */\nexport function init() {\n\tshadowLayer = thisScene.createLayer({\n\t\ttext: 'shadow',\n\t\tcolor: '0 0 0',\n\t\talpha: 1,\n\t\tpointsize: thisLayer.pointsize,\n\t\tfont: thisLayer.font,\n\t\tperspective: true\n\t});\n\tshadowLayer.origin = thisLayer.origin;\n\tshadowLayer.angles = thisLayer.angles;\n\tshadowLayer.scale = thisLayer.scale;\n\tthisScene.sortLayer(shadowLayer, thisScene.getLayerIndex(thisLayer));\n}\n", "value" : "12:34" }, "verticalalign" : "center", "visible" : true } ] } ] }