diff --git a/scripts/system/fingerPaint/PaintWindow.qml b/scripts/system/fingerPaint/PaintWindow.qml deleted file mode 100644 index 9e6b7b2ced..0000000000 --- a/scripts/system/fingerPaint/PaintWindow.qml +++ /dev/null @@ -1,383 +0,0 @@ -// import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick 2.6 -import QtQuick.Window 2.2 -import QtQuick.Controls 1.5 -import QtQuick.Dialogs 1.1 -import Hifi 1.0 as Hifi -import QtQuick.Controls.Styles 1.4 -import QtQuick.Layouts 1.3 -import "content" - -Rectangle { - id: root - width: parent ? parent.width : 100 - height: parent ? parent.height : 100 - color: "transparent" - signal moved(vector2d position); - signal resized(size size); - - signal sendToScript(var message); - - property var channel; - - TabView { - id: frame - anchors.fill: parent - anchors.margins: 4 - Tab { title: "content/tabicons/colorpaletteBtn.png" - ColorWheel{ - id: colorPicker - anchors.verticalCenter: parent.verticalCenter - } - function sendToScript( message) { root.sendToScript(message)} - } - Tab { title: "content/tabicons/linewidthBtn.png" - Slider { - - value: 0.25 - onValueChanged: { - root.sendToScript(["width", value]); - } - - style: SliderStyle { - - handle: Rectangle { - anchors.centerIn: parent - - implicitWidth: 34 - implicitHeight: 34 - border.color: "black" - border.width: 1 - color: "transparent" - - Rectangle { - anchors.fill: parent; anchors.margins: 2 - border.color: "white"; border.width: 1 - color: "transparent" - } - } - - } - - } - - } - Tab { title: "content/tabicons/brushesBtn.png" - GridLayout { - id: grid - columns: 3 - - Layout.maximumWidth : 100 - Layout.maximumHeight : 100 - Layout.fillWidth : true - Layout.fillHeight : true - Button { - //width : Layout.fillWidth - //height : Layout.fillHeight - Layout.fillWidth : true - Layout.fillHeight : true - text: "" - //iconSource: "content/brushes/paintbrush1.png" - onClicked: { - root.sendToScript(["brush", img.source]); - } - - Image { - id: img - source: "content/brushes/paintbrush1.png" - anchors.fill: parent - - } - - style: ButtonStyle { - background: Rectangle { - //width : Layout.fillWidth - //height : Layout.fillHeight - border.width: control.activeFocus ? 2 : 1 - border.color: "#888" - radius: 4 - gradient: Gradient { - GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" } - GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" } - } - } - } - } - Button { - //width : Layout.fillWidth - //height : Layout.fillHeight - Layout.fillWidth : true - Layout.fillHeight : true - text: "" - //iconSource: "content/brushes/paintbrush2.png" - //onClicked: { - // root.sendToScript(["brush", iconSource]); - //} - - //iconSource: "content/brushes/paintbrush1.png" - onClicked: { - root.sendToScript(["brush", img2.source]); - } - - Image { - id: img2 - source: "content/brushes/paintbrush2.png" - anchors.fill: parent - - } - - style: ButtonStyle { - background: Rectangle { - //width : Layout.fillWidth - //height : Layout.fillHeight - border.width: control.activeFocus ? 2 : 1 - border.color: "#888" - radius: 4 - gradient: Gradient { - GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" } - GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" } - } - } - } - } - Button { - Layout.fillWidth : true - Layout.fillHeight : true - //width : Layout.fillWidth - //height : Layout.fillHeight - text: "" - //iconSource: "content/brushes/paintbrush3.png" - //onClicked: { - // root.sendToScript(["brush", iconSource]); - //} - - //iconSource: "content/brushes/paintbrush1.png" - onClicked: { - root.sendToScript(["brush", img3.source]); - } - - Image { - id: img3 - source: "content/brushes/paintbrush3.png" - anchors.fill: parent - - } - - style: ButtonStyle { - background: Rectangle { - //width : Layout.fillWidth - //height : Layout.fillHeight - border.width: control.activeFocus ? 2 : 1 - border.color: "#888" - radius: 4 - gradient: Gradient { - GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" } - GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" } - } - } - } - } - Button { - Layout.fillWidth : true - Layout.fillHeight : true - //width : Layout.fillWidth - //height : Layout.fillHeight - text: "" - //iconSource: "content/brushes/paintbrush4.png" - //onClicked: { - // root.sendToScript(["brush", iconSource]); - //} - - //iconSource: "content/brushes/paintbrush1.png" - onClicked: { - root.sendToScript(["brush", img4.source]); - } - - Image { - id: img4 - source: "content/brushes/paintbrush4.png" - anchors.fill: parent - - } - - style: ButtonStyle { - background: Rectangle { - //width : Layout.fillWidth - //height : Layout.fillHeight - border.width: control.activeFocus ? 2 : 1 - border.color: "#888" - radius: 4 - gradient: Gradient { - GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" } - GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" } - } - } - } - } - Button { - Layout.fillWidth : true - Layout.fillHeight : true - //width : Layout.fillWidth - //height : Layout.fillHeight - text: "" - //iconSource: "content/brushes/paintbrush5.png" - //onClicked: { - // root.sendToScript(["brush", iconSource]); - //} - - //iconSource: "content/brushes/paintbrush1.png" - onClicked: { - root.sendToScript(["brush", img5.source]); - } - - Image { - id: img5 - source: "content/brushes/paintbrush5.png" - anchors.fill: parent - - } - - style: ButtonStyle { - background: Rectangle { - //width : Layout.fillWidth - //height : Layout.fillHeight - border.width: control.activeFocus ? 2 : 1 - border.color: "#888" - radius: 4 - gradient: Gradient { - GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" } - GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" } - } - } - } - } - Button { - Layout.fillWidth : true - Layout.fillHeight : true - //width : Layout.fillWidth - //height : Layout.fillHeight - text: "" - //iconSource: "content/brushes/paintbrush6.png" - //onClicked: { - // root.sendToScript(["brush", iconSource]); - //} - - //iconSource: "content/brushes/paintbrush1.png" - onClicked: { - root.sendToScript(["brush", img6.source]); - } - - Image { - id: img6 - source: "content/brushes/paintbrush6.png" - anchors.fill: parent - - } - - style: ButtonStyle { - background: Rectangle { - //width : Layout.fillWidth - //height : Layout.fillHeight - border.width: control.activeFocus ? 2 : 1 - border.color: "#888" - radius: 4 - gradient: Gradient { - GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" } - GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" } - } - } - } - } - } - } - - Tab { title: "content/tabicons/eraser.png" - - - - Button { - width : 200 - height : 50 - - anchors.verticalCenter: parent.verticalCenter - text: "Undo" - onClicked: { - root.sendToScript(["undo"]); - } - - style: ButtonStyle { - background: Rectangle { - //width : Layout.fillWidth - //height : Layout.fillHeight - border.width: control.activeFocus ? 2 : 1 - border.color: "#888" - radius: 4 - gradient: Gradient { - GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" } - GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" } - } - } - } - } - } - - Tab { title: "content/tabicons/pointingfinger128px.png" - - - - Button { - width : 200 - height : 50 - anchors.verticalCenter: parent.verticalCenter - text: "Toggle Hand" - onClicked: { - root.sendToScript(["hand"]); - } - - style: ButtonStyle { - background: Rectangle { - - border.width: control.activeFocus ? 2 : 1 - border.color: "#888" - radius: 4 - gradient: Gradient { - GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" } - GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" } - } - } - } - } - } - - style: TabViewStyle { - frameOverlap: 1 - tab: Rectangle { - color: styleData.selected ? "steelblue" : "grey" - border.color: "grey" - implicitWidth: 100 - implicitHeight: 100 - radius: 2 - Text { - id: text - anchors.centerIn: parent - text: "" - color: styleData.selected ? "white" : "black" - } - Image { - source: styleData.title - width: parent.width - height: parent.height - } - } - frame: Rectangle { color: "grey" } - } - } - - -} - - - - - diff --git a/scripts/system/fingerPaint/content/CheckerBoard.qml b/scripts/system/fingerPaint/content/CheckerBoard.qml deleted file mode 100644 index ccf5903d47..0000000000 --- a/scripts/system/fingerPaint/content/CheckerBoard.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -Grid { - id: root - property int cellSide: 5 - anchors.fill: parent - rows: height/cellSide; columns: width/cellSide - clip: true - Repeater { - model: root.columns*root.rows - Rectangle { - width: root.cellSide; height: root.cellSide - color: (index%2 == 0) ? "gray" : "white" - } - } -} diff --git a/scripts/system/fingerPaint/content/ColorUtils.js b/scripts/system/fingerPaint/content/ColorUtils.js deleted file mode 100644 index 57c5a26727..0000000000 --- a/scripts/system/fingerPaint/content/ColorUtils.js +++ /dev/null @@ -1,94 +0,0 @@ -// creates color value from hue, saturation, brightness, alpha -function hsba(h, s, b, a) { - var lightness = (2 - s)*b; - var satHSL = s*b/((lightness <= 1) ? lightness : 2 - lightness); - lightness /= 2; - return Qt.hsla(h, satHSL, lightness, a); -} - -function clamp(val, min, max){ - return Math.max(min, Math.min(max, val)) ; -} - -function mix(x, y , a) -{ - return x * (1 - a) + y * a ; -} - -function hsva2rgba(hsva) { - var c = hsva.z * hsva.y ; - var x = c * (1 - Math.abs( (hsva.x * 6) % 2 - 1 )) ; - var m = hsva.z - c ; - - if (hsva.x < 1/6 ) - return Qt.vector4d(c+m, x+m, m, hsva.w) ; - else if (hsva.x < 1/3 ) - return Qt.vector4d(x+m, c+m, m, hsva.w) ; - else if (hsva.x < 0.5 ) - return Qt.vector4d(m, c+m, x+m, hsva.w) ; - else if (hsva.x < 2/3 ) - return Qt.vector4d(m, x+m, c+m, hsva.w) ; - else if (hsva.x < 5/6 ) - return Qt.vector4d(x+m, m, c+m, hsva.w) ; - else - return Qt.vector4d(c+m, m, x+m, hsva.w) ; - -} - -function rgba2hsva(rgba) -{ - var r = rgba.x; - var g = rgba.y; - var b = rgba.z; - var max = Math.max(r, g, b), min = Math.min(r, g, b); - var h, s, v = max; - - var d = max - min; - s = max === 0 ? 0 : d / max; - - if(max == min){ - h = 0; // achromatic - } else{ - switch(max){ - case r: - h = (g - b) / d + (g < b ? 6 : 0); - break; - case g: - h = (b - r) / d + 2; - break; - case b: - h = (r - g) / d + 4; - break; - } - h /= 6; - } - - return Qt.vector4d(h, s, v, rgba.w); -} - - -// extracts integer color channel value [0..255] from color value -function getChannelStr(clr, channelIdx) { - return parseInt(clr.toString().substr(channelIdx*2 + 1, 2), 16); -} - -//convert to hexa with nb char -function intToHexa(val , nb) -{ - var hexaTmp = val.toString(16) ; - var hexa = ""; - var size = hexaTmp.length - if (size < nb ) - { - for(var i = 0 ; i < nb - size ; ++i) - { - hexa += "0" - } - } - return hexa + hexaTmp -} - -function hexaFromRGBA(red, green, blue, alpha) -{ - return intToHexa(Math.round(red * 255), 2)+intToHexa(Math.round(green * 255), 2)+intToHexa(Math.round(blue * 255), 2); -} diff --git a/scripts/system/fingerPaint/content/ColorWheel.qml b/scripts/system/fingerPaint/content/ColorWheel.qml deleted file mode 100644 index 0cbf001558..0000000000 --- a/scripts/system/fingerPaint/content/ColorWheel.qml +++ /dev/null @@ -1,284 +0,0 @@ -import QtQuick 2.2 -import QtQuick.Window 2.0 -import QtQuick.Layouts 1.1 - -import "ColorUtils.js" as ColorUtils - -Item { - id: root - width: parent.width - height: parent.height * 0.666 - focus: true - - // Color value in RGBA with floating point values between 0.0 and 1.0. - - - property vector4d colorHSVA: Qt.vector4d(1, 1, 1, 1) - QtObject { - id: m - // Color value in HSVA with floating point values between 0.0 and 1.0. - property vector4d colorRGBA: ColorUtils.hsva2rgba(root.colorHSVA) - } - - signal accepted - - onAccepted: { - var rgba = ColorUtils.hsva2rgba(root.colorHSVA) - parent.sendToScript(["color", rgba.x*255 , rgba.y*255, rgba.z*255]); - } - - RowLayout { - spacing: 20 - anchors.fill: parent - - Wheel { - id: wheel - Layout.fillWidth: true - Layout.fillHeight: true - Layout.minimumWidth: 200 - Layout.minimumHeight: 200 - - hue: colorHSVA.x - saturation: colorHSVA.y - onUpdateHS: { - colorHSVA = Qt.vector4d(hueSignal,saturationSignal, colorHSVA.z, colorHSVA.w) - } - onAccepted: { - root.accepted() - } - } - - // brightness picker slider - Item { - Layout.fillHeight: true - Layout.minimumWidth: 20 - Layout.minimumHeight: 200 - - //Brightness background - Rectangle { - anchors.fill: parent - gradient: Gradient { - GradientStop { - id: brightnessBeginColor - position: 0.0 - color: { - var rgba = ColorUtils.hsva2rgba( - Qt.vector4d(colorHSVA.x, - colorHSVA.y, 1, 1)) - return Qt.rgba(rgba.x, rgba.y, rgba.z, rgba.w) - } - } - GradientStop { - position: 1.0 - color: "#000000" - } - } - } - - VerticalSlider { - id: brigthnessSlider - anchors.fill: parent - value: colorHSVA.z - onValueChanged: { - colorHSVA = Qt.vector4d(colorHSVA.x, colorHSVA.y, value, colorHSVA.w) - } - onAccepted: { - root.accepted() - } - } - } - - - // text inputs - ColumnLayout { - Layout.fillHeight: true - Layout.minimumWidth: 150 - Layout.minimumHeight: 200 - anchors.verticalCenter: parent.verticalCenter - spacing: 10 - - // current color display - Rectangle { - Layout.minimumWidth: 150 - Layout.minimumHeight: 50 - CheckerBoard { - cellSide: 5 - } - Rectangle { - id: colorDisplay - width: parent.width - height: parent.height - border.width: 1 - border.color: "black" - color: Qt.rgba(m.colorRGBA.x, m.colorRGBA.y, m.colorRGBA.z) - opacity: m.colorRGBA.w - } - } - - - // current color value - Item { - Layout.minimumWidth: 120 - Layout.minimumHeight: 25 - - Text { - id: captionBox - text: "#" - width: 18 - height: parent.height - color: "#AAAAAA" - font.pixelSize: 16 - font.bold: true - } - PanelBorder { - height: parent.height - anchors.left : captionBox.right - width: parent.width - captionBox.width - TextInput { - id: currentColor - color: "#AAAAAA" - selectionColor: "#FF7777AA" - font.pixelSize: 16 - font.capitalization: "AllUppercase" - maximumLength: 9 - focus: true - text: ColorUtils.hexaFromRGBA(m.colorRGBA.x, m.colorRGBA.y, - m.colorRGBA.z, m.colorRGBA.w) - font.family: "Droid Sans" - selectByMouse: true - validator: RegExpValidator { - regExp: /^([A-Fa-f0-9]{6})$/ - } - onEditingFinished: { - var colorTmp = Qt.vector4d( parseInt(text.substr(0, 2), 16) / 255, - parseInt(text.substr(2, 2), 16) / 255, - parseInt(text.substr(4, 2), 16) / 255, - colorHSVA.w) ; - colorHSVA = ColorUtils.rgba2hsva(colorTmp) - } - } - } - } - // H, S, B color value boxes - Column { - Layout.minimumWidth: 80 - Layout.minimumHeight: 25 - NumberBox { - id: hue - caption: "H" - // TODO: put in NumberBox - value: Math.round(colorHSVA.x * 100000) / 100000 // 5 Decimals - decimals: 2 - max: 1 - min: 0 - onAccepted: { - colorHSVA = Qt.vector4d(boxValue, colorHSVA.y, colorHSVA.z, colorHSVA.w) - root.accepted() - } - } - NumberBox { - id: sat - caption: "S" - value: Math.round(colorHSVA.y * 100) / 100 // 2 Decimals - decimals: 2 - max: 1 - min: 0 - onAccepted: { - colorHSVA = Qt.vector4d(colorHSVA.x, boxValue, colorHSVA.z, colorHSVA.w) - root.accepted() - } - } - NumberBox { - id: brightness - caption: "B" - value: Math.round(colorHSVA.z * 100) / 100 // 2 Decimals - decimals: 2 - max: 1 - min: 0 - onAccepted: { - colorHSVA = Qt.vector4d(colorHSVA.x, colorHSVA.y, boxValue, colorHSVA.w) - root.accepted() - } - } - NumberBox { - id: hsbAlpha - caption: "A" - value: Math.round(colorHSVA.w * 100) / 100 // 2 Decimals - decimals: 2 - max: 1 - min: 0 - onAccepted: { - colorHSVA.w = boxValue - root.accepted() - } - } - } - - // R, G, B color values boxes - Column { - Layout.minimumWidth: 80 - Layout.minimumHeight: 25 - NumberBox { - id: red - caption: "R" - value: Math.round(m.colorRGBA.x * 255) - min: 0 - max: 255 - decimals: 0 - onAccepted: { - var colorTmp = Qt.vector4d( boxValue / 255, - m.colorRGBA.y, - m.colorRGBA.z, - colorHSVA.w) ; - colorHSVA = ColorUtils.rgba2hsva(colorTmp) - root.accepted() - } - } - NumberBox { - id: green - caption: "G" - value: Math.round(m.colorRGBA.y * 255) - min: 0 - max: 255 - decimals: 0 - onAccepted: { - var colorTmp = Qt.vector4d( m.colorRGBA.x, - boxValue / 255, - m.colorRGBA.z, - colorHSVA.w) ; - colorHSVA = ColorUtils.rgba2hsva(colorTmp) - root.accepted() - } - } - NumberBox { - id: blue - caption: "B" - value: Math.round(m.colorRGBA.z * 255) - min: 0 - max: 255 - decimals: 0 - onAccepted: { - var colorTmp = Qt.vector4d( m.colorRGBA.x, - m.colorRGBA.y, - boxValue / 255, - colorHSVA.w) ; - colorHSVA = ColorUtils.rgba2hsva(colorTmp) - root.accepted() - } - } - NumberBox { - id: rgbAlpha - caption: "A" - value: Math.round(m.colorRGBA.w * 255) - min: 0 - max: 255 - decimals: 0 - onAccepted: { - root.colorHSVA.w = boxValue / 255 - root.accepted() - } - } - } - } - } -} diff --git a/scripts/system/fingerPaint/content/NumberBox.qml b/scripts/system/fingerPaint/content/NumberBox.qml deleted file mode 100644 index e801571db2..0000000000 --- a/scripts/system/fingerPaint/content/NumberBox.qml +++ /dev/null @@ -1,64 +0,0 @@ -import QtQuick 2.2 -import "ColorUtils.js" as ColorUtils - -Row { - id: root - property string caption: "" - property real value: 0 - property real min: 0 - property real max: 255 - property int decimals: 2 - - QtObject { - id: m - // Hack: force update of the text after text validation - property int forceTextUpdate: 0 - } - - onValueChanged: { - - console.debug("NumberBox root.value:" + root.value) - } - - width: 60 - height: 20 - spacing: 0 - anchors.margins: 5 - - signal accepted(var boxValue) - - Text { - id: captionBox - text: root.caption - width: 18; height: parent.height - color: "#AAAAAA" - font.pixelSize: 16; font.bold: true - horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignBottom - anchors.bottomMargin: 3 - } - PanelBorder { - height: parent.height - anchors.leftMargin: 4; - anchors.left: captionBox.right; anchors.right: parent.right - TextInput { - id: inputBox - // Hack: force update of the text if the value is the same after the clamp. - text: m.forceTextUpdate ? root.value.toString() : root.value.toString() - anchors.leftMargin: 4; anchors.topMargin: 1; anchors.fill: parent - color: "#AAAAAA"; selectionColor: "#FF7777AA" - font.pixelSize: 14 - focus: true - onEditingFinished: { - var newText = ColorUtils.clamp(parseFloat(inputBox.text), root.min, root.max).toString() - if(newText != root.value) { - root.accepted(newText) - } - else { - m.forceTextUpdate = m.forceTextUpdate + 1 // Hack: force update - } - } - } - } -} - - diff --git a/scripts/system/fingerPaint/content/PanelBorder.qml b/scripts/system/fingerPaint/content/PanelBorder.qml deleted file mode 100644 index c78ca732cf..0000000000 --- a/scripts/system/fingerPaint/content/PanelBorder.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width : 40; height : 15; radius: 2 - border.width: 1; border.color: "#FF101010" - color: "transparent" - anchors.leftMargin: 1; anchors.topMargin: 3 - clip: true - Rectangle { - anchors.fill: parent; radius: 2 - anchors.leftMargin: -1; anchors.topMargin: -1 - anchors.rightMargin: 0; anchors.bottomMargin: 0 - border.width: 1; border.color: "#FF525255" - color: "transparent" - } -} diff --git a/scripts/system/fingerPaint/content/VerticalSlider.qml b/scripts/system/fingerPaint/content/VerticalSlider.qml deleted file mode 100644 index 4092c06f39..0000000000 --- a/scripts/system/fingerPaint/content/VerticalSlider.qml +++ /dev/null @@ -1,72 +0,0 @@ -import QtQuick 2.0 -import "mathUtils.js" as MathUtils - -Item { - id: root - width: 15 - height: 200 - - - property real value - signal accepted - - states : - // When user is moving the slider - State { - name: "editing" - PropertyChanges { - target: root - // Initialize with the value in the default state. - // Allows to break the link in that state. - value: root.value - } - } - - // Cursor - Item { - id: pickerCursor - width: parent.width - height: 8 - - Rectangle { - id: cursor - x: -4 - y: MathUtils.clamp(root.height * (1 - root.value), 0.0, root.height) - width: parent.width + -2*x - height: parent.height - border.color: "black" - border.width: 1 - color: "transparent" - - Rectangle { - anchors.fill: parent; anchors.margins: 2 - border.color: "white"; border.width: 1 - color: "transparent" - } - } - } - - MouseArea { - id: mouseAreaSlider - anchors.fill: parent - property bool isDrag : false - function sliderHandleMouse(mouse){ - root.state = 'editing' - if (mouse.buttons & Qt.LeftButton | isDrag) { - root.value = MathUtils.clampAndProject(mouse.y, 0.0, height, 1.0, 0.0) - } - } - onPositionChanged: { - sliderHandleMouse(mouse) - } - onPressed: { - isDrag = true - sliderHandleMouse(mouse) - } - onReleased: { - isDrag = false - root.state = '' - root.accepted() - } - } -} diff --git a/scripts/system/fingerPaint/content/Wheel.qml b/scripts/system/fingerPaint/content/Wheel.qml deleted file mode 100644 index 853dae691e..0000000000 --- a/scripts/system/fingerPaint/content/Wheel.qml +++ /dev/null @@ -1,145 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - width: 200 - height: 200 - - property real hue : 1 - property real saturation : 1 - - signal accepted() - signal updateHS(var hueSignal, var saturationSignal) - - states : - // When user is moving the slider - State { - name: "editing" - PropertyChanges { - target: root - // Better solution ? because the value is change in the fonction of mouse area - hue: hue - saturation: saturation - } - } - - Rectangle { - id: wheel - //Keep the wheel round - width: parent.width < parent.height ? parent.width : parent.height ; - height: width ; - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - color: "transparent" - ShaderEffect { - id: shader - anchors.fill: parent - vertexShader: " - uniform highp mat4 qt_Matrix; - attribute highp vec4 qt_Vertex; - attribute highp vec2 qt_MultiTexCoord0; - varying highp vec2 coord; - - void main() { - coord = qt_MultiTexCoord0 - vec2(0.5, 0.5); - gl_Position = qt_Matrix * qt_Vertex; - }" - fragmentShader: " - varying highp vec2 coord; - - vec3 hsv2rgb(in vec3 c){ - vec4 k = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + k.xyz) * 6.0 - k.www); - return c.z * mix(k.xxx, clamp(p - k.xxx, 0.0, 1.0), c.y); - } - - void main() { - const float PI = 3.14159265358979323846264; - float s = sqrt(coord.x * coord.x + coord.y * coord.y); - - if( s > 0.5 ){ - gl_FragColor = vec4(0, 0, 0, 0); - return; - } - - float h = - atan( coord.y / coord.x ); - s *= 2.0; - - if( coord.x >= 0.0 ){ - h += PI; - } - - h = h / (2.0 * PI); - vec3 hsl = vec3(h, s, 1.0); - vec3 rgb = hsv2rgb(hsl); - gl_FragColor.rgb = rgb; - gl_FragColor.a = 1.0; - }" - } - - Item { - id: pickerCursor - x: parent.width/2 * (1 + root.saturation * Math.cos(2 * Math.PI * root.hue - Math.PI)) - r - y: parent.width/2 * (1 + root.saturation * Math.sin(-2 * Math.PI * root.hue - Math.PI)) - r - property int r : 8 - Rectangle { - width: parent.r*2; height: parent.r*2 - radius: parent.r - border.color: "black"; border.width: 2 - color: "transparent" - Rectangle { - anchors.fill: parent; anchors.margins: 2; - border.color: "white"; border.width: 2 - radius: width/2 - color: "transparent" - } - } - } - - MouseArea { - id : wheelArea - property bool isDrag : false - - // Clamp cursor to wheel - function keepCursorInWheel(mouse, wheelArea, wheel) { - root.state = 'editing' - if (mouse.buttons & Qt.LeftButton | isDrag) { - // cartesian to polar coords - var ro = Math.sqrt(Math.pow(mouse.x-wheel.width/2,2)+Math.pow(mouse.y-wheel.height/2,2)); - var theta = Math.atan2(((mouse.y-wheel.height/2)*(-1)),((mouse.x-wheel.width/2))); - - // Wheel limit - if(ro > wheel.width/2) - ro = wheel.width/2; - - // polar to cartesian coords - var cursor = Qt.vector2d(0, 0); - cursor.x = Math.max(-pickerCursor.r, Math.min(wheelArea.width, ro*Math.cos(theta)+wheel.width/2)-pickerCursor.r); - cursor.y = Math.max(-pickerCursor.r, Math.min(wheelArea.height, wheel.height/2-ro*Math.sin(theta)-pickerCursor.r)); - - hue = Math.ceil((Math.atan2(((cursor.y+pickerCursor.r-wheel.height/2)*(-1)),((cursor.x+pickerCursor.r-wheel.width/2)))/(Math.PI*2)+0.5)*100)/100 - saturation = Math.ceil(Math.sqrt(Math.pow(cursor.x+pickerCursor.r-width/2,2)+Math.pow(cursor.y+pickerCursor.r-height/2,2))/wheel.height*2*100)/100; - root.updateHS(hue, saturation) ; - } - } - anchors.fill: parent - - onPositionChanged: { - keepCursorInWheel(mouse, wheelArea, wheel) - - } - onPressed: { - isDrag = true - keepCursorInWheel(mouse, wheelArea, wheel) - - } - - onReleased: { - isDrag = false - root.state = '' - root.accepted() ; - } - } - } - -} diff --git a/scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedBrush.js b/scripts/system/fingerPaint/content/animatedBrushes/animatedBrush.js similarity index 92% rename from scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedBrush.js rename to scripts/system/fingerPaint/content/animatedBrushes/animatedBrush.js index 0ae689a44c..50ee89b7fe 100644 --- a/scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedBrush.js +++ b/scripts/system/fingerPaint/content/animatedBrushes/animatedBrush.js @@ -21,11 +21,9 @@ AnimatedBrushClass.prototype.onUpdate = function(deltaSeconds, entityID) { * @param animatedBrushObject: the animation object (should be a subclass of animatedBrush) */ AnimatedBrushClass.prototype.updateUserData = function(entityID, animatedBrushObject) { - //print("Saving class " + animatedBrushObject.NAME); var prevUserData = Entities.getEntityProperties(entityID).userData; if (prevUserData) { - print("saving on parent: " + JSON.stringify(animatedBrushObject)); prevUserData = prevUserData == "" ? new Object() : JSON.parse(prevUserData); //preserve other possible user data if (prevUserData.animations != null && prevUserData.animations[animatedBrushObject.NAME] != null) { delete prevUserData.animations[animatedBrushObject.NAME]; diff --git a/scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedBrushScript.js b/scripts/system/fingerPaint/content/animatedBrushes/animatedBrushScript.js similarity index 93% rename from scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedBrushScript.js rename to scripts/system/fingerPaint/content/animatedBrushes/animatedBrushScript.js index 18935d8c7c..82b1e46955 100644 --- a/scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedBrushScript.js +++ b/scripts/system/fingerPaint/content/animatedBrushes/animatedBrushScript.js @@ -9,11 +9,9 @@ self.intervalID = Script.setInterval(function() { if (Vec3.withinEpsilon(MyAvatar.position, Entities.getEntityProperties(entityID).position, MIN_PLAY_DISTANCE)) { var userData = Entities.getEntityProperties(entityID).userData; - //print("UserData: " + userData); if (userData) { var userDataObject = JSON.parse(userData); var animationObject = userDataObject.animations; - print("Playing animation " + JSON.stringify(animationObject)); var newAnimationObject = null; if (!userDataObject.timeFromLastAnimation) { userDataObject.timeFromLastAnimation = Date.now(); diff --git a/scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedBrushesList.js b/scripts/system/fingerPaint/content/animatedBrushes/animatedBrushesList.js similarity index 100% rename from scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedBrushesList.js rename to scripts/system/fingerPaint/content/animatedBrushes/animatedBrushesList.js diff --git a/scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedHueBrush.js b/scripts/system/fingerPaint/content/animatedBrushes/animatedHueBrush.js similarity index 84% rename from scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedHueBrush.js rename to scripts/system/fingerPaint/content/animatedBrushes/animatedHueBrush.js index 46a6b8ce06..64bb07f25a 100644 --- a/scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedHueBrush.js +++ b/scripts/system/fingerPaint/content/animatedBrushes/animatedHueBrush.js @@ -1,11 +1,9 @@ //Superclass Script.include("animatedBrush.js"); -Script.include("../../ColorUtils2.js"); +Script.include("../js/ColorUtils.js"); function AnimatedHueBrushClass(settings, entityID) { - //Animated brush vars AnimatedBrush.call(this); - //print("Starting animated hue brush"); this.hsvColor = rgb2hsv(Entities.getEntityProperties(entityID).color);// {hue: 0, saturation: 1.0, value: 1.0}; this.animatedColor = {red: 0, green: 0, blue: 0}; } @@ -15,7 +13,6 @@ AnimatedHueBrushClass.prototype.ANIMATED_BRUSH_INCREMENT = 0.5; //linear increme AnimatedHueBrushClass.prototype.NAME = "animatedHueBrush"; AnimatedHueBrushClass.prototype.onUpdate = function(deltaSeconds, entityID) { - //print("Animated Hue Brush"); this.hsvColor.hue = this.hsvColor.hue + ((deltaSeconds * this.ANIMATED_BRUSH_INCREMENT)/this.ANIMATED_BRUSH_TIME); this.hsvColor.hue = this.hsvColor.hue >= 360 ? 0 : this.hsvColor.hue; //restart hue cycle this.animatedColor = hsv2rgb(this.hsvColor); @@ -23,7 +20,6 @@ AnimatedHueBrushClass.prototype.onUpdate = function(deltaSeconds, entityID) { this.parent.updateUserData(entityID, this); } -//AnimatedHueBrushClass.prototype = Object.create(AnimatedBrush.prototype); AnimatedHueBrushClass.prototype.constructor = AnimatedHueBrushClass; AnimatedHueBrushClass.prototype.parent = AnimatedBrush.prototype; diff --git a/scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedRotationBrush.js b/scripts/system/fingerPaint/content/animatedBrushes/animatedRotationBrush.js similarity index 89% rename from scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedRotationBrush.js rename to scripts/system/fingerPaint/content/animatedBrushes/animatedRotationBrush.js index 3587e88bf4..413d21f5c6 100644 --- a/scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedRotationBrush.js +++ b/scripts/system/fingerPaint/content/animatedBrushes/animatedRotationBrush.js @@ -2,9 +2,7 @@ Script.include("animatedBrush.js"); function AnimatedRotationBrushClass(settings, entityID) { - //animated brush vars AnimatedBrush.call(this); - //print("Starting animated rotation brush"); this.angle = 0; this.activeAxis = settings.axis; } @@ -17,7 +15,6 @@ AnimatedRotationBrushClass.prototype.ANIMATED_BRUSH_INCREMENT = 5; //linear incr AnimatedRotationBrushClass.prototype.NAME = "animatedRotationBrush"; //linear increment of brush size; AnimatedRotationBrushClass.prototype.onUpdate = function(deltaSeconds, entityID) { - //print("Animated rotation this: " + JSON.stringify(rotation)); this.angle = this.angle + ((deltaSeconds * this.ANIMATED_BRUSH_INCREMENT)/this.ANIMATED_BRUSH_TIME); this.angle = this.angle >= 360 ? 0 : this.angle; //restart hue cycle var rotation = Vec3.multiply(this.angle, this.activeAxis); diff --git a/scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedTranslationBrush.js b/scripts/system/fingerPaint/content/animatedBrushes/animatedTranslationBrush.js similarity index 87% rename from scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedTranslationBrush.js rename to scripts/system/fingerPaint/content/animatedBrushes/animatedTranslationBrush.js index b435be2938..464976621c 100644 --- a/scripts/system/fingerPaint/content/brushes/animatedBrushes/animatedTranslationBrush.js +++ b/scripts/system/fingerPaint/content/animatedBrushes/animatedTranslationBrush.js @@ -2,9 +2,7 @@ Script.include("animatedBrush.js"); function AnimatedTranslationBrushClass(settings, entityID) { - //Animated brush vars AnimatedBrush.call(this); - //print("Starting Animated Translation brush"); this.startingPosition = null; this.translation = 0; this.activeAxis = settings.axis; @@ -19,9 +17,7 @@ AnimatedTranslationBrushClass.prototype.MAX_TRANSLATION = 2; AnimatedTranslationBrushClass.prototype.NAME = "animatedTranslationBrush"; //linear increment of brush size; AnimatedTranslationBrushClass.prototype.onUpdate = function(deltaSeconds, entityID) { - //print("translation this: " + JSON.stringify(this) + " : " + JSON.stringify(this.activeAxis)); var currentPosition = Entities.getEntityProperties(entityID).position; - //print("currentPosition " + JSON.stringify(currentPosition)); if (this.startingPosition == null) { this.startingPosition = currentPosition; } diff --git a/scripts/system/fingerPaint/content/brushes/256x256/Thumbs.db b/scripts/system/fingerPaint/content/brushes/256x256/Thumbs.db deleted file mode 100644 index b31b5e9603..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/256x256/Thumbs.db and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/256x256/basic.png b/scripts/system/fingerPaint/content/brushes/256x256/basic.png deleted file mode 100644 index d632abd501..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/256x256/basic.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/256x256/bristle.png b/scripts/system/fingerPaint/content/brushes/256x256/bristle.png deleted file mode 100644 index 8c74fb9121..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/256x256/bristle.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/256x256/gouache.png b/scripts/system/fingerPaint/content/brushes/256x256/gouache.png deleted file mode 100644 index f48c107f8c..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/256x256/gouache.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/256x256/spat-medium.png b/scripts/system/fingerPaint/content/brushes/256x256/spat-medium.png deleted file mode 100644 index 578bd7f8f8..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/256x256/spat-medium.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/256x256/sponge.png b/scripts/system/fingerPaint/content/brushes/256x256/sponge.png deleted file mode 100644 index 852c35d946..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/256x256/sponge.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/256x256stretched/Thumbs.db b/scripts/system/fingerPaint/content/brushes/256x256stretched/Thumbs.db deleted file mode 100644 index 3485f5be45..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/256x256stretched/Thumbs.db and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/256x256stretched/basic.png b/scripts/system/fingerPaint/content/brushes/256x256stretched/basic.png deleted file mode 100644 index e09d3a1883..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/256x256stretched/basic.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/256x256stretched/bristle.png b/scripts/system/fingerPaint/content/brushes/256x256stretched/bristle.png deleted file mode 100644 index b2b9c91661..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/256x256stretched/bristle.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/basic.png b/scripts/system/fingerPaint/content/brushes/basic.png index a0482a8a34..d632abd501 100644 Binary files a/scripts/system/fingerPaint/content/brushes/basic.png and b/scripts/system/fingerPaint/content/brushes/basic.png differ diff --git a/scripts/system/fingerPaint/content/brushes/colored/breakfast.png b/scripts/system/fingerPaint/content/brushes/breakfast.png similarity index 100% rename from scripts/system/fingerPaint/content/brushes/colored/breakfast.png rename to scripts/system/fingerPaint/content/brushes/breakfast.png diff --git a/scripts/system/fingerPaint/content/brushes/bristle.png b/scripts/system/fingerPaint/content/brushes/bristle.png index 21ba816070..8c74fb9121 100644 Binary files a/scripts/system/fingerPaint/content/brushes/bristle.png and b/scripts/system/fingerPaint/content/brushes/bristle.png differ diff --git a/scripts/system/fingerPaint/content/brushes/colored/chique.png b/scripts/system/fingerPaint/content/brushes/colored/chique.png deleted file mode 100644 index 901a2cbfcf..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/colored/chique.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/colored/hawaii.png b/scripts/system/fingerPaint/content/brushes/colored/hawaii.png deleted file mode 100644 index 2df6b63334..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/colored/hawaii.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/colored/pastels.png b/scripts/system/fingerPaint/content/brushes/colored/pastels.png deleted file mode 100644 index 974fb900ac..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/colored/pastels.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/gimickkywhite/dot.png b/scripts/system/fingerPaint/content/brushes/dot.png similarity index 100% rename from scripts/system/fingerPaint/content/brushes/gimickkywhite/dot.png rename to scripts/system/fingerPaint/content/brushes/dot.png diff --git a/scripts/system/fingerPaint/content/brushes/256x256/dupuiz.png b/scripts/system/fingerPaint/content/brushes/dupuiz.png similarity index 100% rename from scripts/system/fingerPaint/content/brushes/256x256/dupuiz.png rename to scripts/system/fingerPaint/content/brushes/dupuiz.png diff --git a/scripts/system/fingerPaint/content/brushes/gimickkywhite/flowers2.png b/scripts/system/fingerPaint/content/brushes/flowers2.png similarity index 100% rename from scripts/system/fingerPaint/content/brushes/gimickkywhite/flowers2.png rename to scripts/system/fingerPaint/content/brushes/flowers2.png diff --git a/scripts/system/fingerPaint/content/brushes/gimickkywhite/Thumbs.db b/scripts/system/fingerPaint/content/brushes/gimickkywhite/Thumbs.db deleted file mode 100644 index 8ed71fddcb..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/gimickkywhite/Thumbs.db and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/gouache.png b/scripts/system/fingerPaint/content/brushes/gouache.png index 90c19401ee..f48c107f8c 100644 Binary files a/scripts/system/fingerPaint/content/brushes/gouache.png and b/scripts/system/fingerPaint/content/brushes/gouache.png differ diff --git a/scripts/system/fingerPaint/content/brushes/256x256stretched/gouache.png b/scripts/system/fingerPaint/content/brushes/gouacheB.png similarity index 100% rename from scripts/system/fingerPaint/content/brushes/256x256stretched/gouache.png rename to scripts/system/fingerPaint/content/brushes/gouacheB.png diff --git a/scripts/system/fingerPaint/content/brushes/gradient.png b/scripts/system/fingerPaint/content/brushes/gradient.png deleted file mode 100644 index a212ba5525..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/gradient.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/gradient3.png b/scripts/system/fingerPaint/content/brushes/gradient3.png deleted file mode 100644 index d401c6ba22..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/gradient3.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/256x256/graphite.png b/scripts/system/fingerPaint/content/brushes/graphite.png similarity index 100% rename from scripts/system/fingerPaint/content/brushes/256x256/graphite.png rename to scripts/system/fingerPaint/content/brushes/graphite.png diff --git a/scripts/system/fingerPaint/content/brushes/gimickkywhite/heart.png b/scripts/system/fingerPaint/content/brushes/heart.png similarity index 100% rename from scripts/system/fingerPaint/content/brushes/gimickkywhite/heart.png rename to scripts/system/fingerPaint/content/brushes/heart.png diff --git a/scripts/system/fingerPaint/content/brushes/gimickkywhite/hearts.png b/scripts/system/fingerPaint/content/brushes/hearts.png similarity index 100% rename from scripts/system/fingerPaint/content/brushes/gimickkywhite/hearts.png rename to scripts/system/fingerPaint/content/brushes/hearts.png diff --git a/scripts/system/fingerPaint/content/brushes/gimickkywhite/leaves.png b/scripts/system/fingerPaint/content/brushes/leaves.png similarity index 100% rename from scripts/system/fingerPaint/content/brushes/gimickkywhite/leaves.png rename to scripts/system/fingerPaint/content/brushes/leaves.png diff --git a/scripts/system/fingerPaint/content/brushes/colored/newton.png b/scripts/system/fingerPaint/content/brushes/newton.png similarity index 100% rename from scripts/system/fingerPaint/content/brushes/colored/newton.png rename to scripts/system/fingerPaint/content/brushes/newton.png diff --git a/scripts/system/fingerPaint/content/brushes/paintbrush2.png b/scripts/system/fingerPaint/content/brushes/paintbrush2.png deleted file mode 100644 index 2d4ac23157..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/paintbrush2.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/paintbrush3.png b/scripts/system/fingerPaint/content/brushes/paintbrush3.png deleted file mode 100644 index f17d723625..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/paintbrush3.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/paintbrush4.png b/scripts/system/fingerPaint/content/brushes/paintbrush4.png deleted file mode 100644 index 2ced63a82f..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/paintbrush4.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/paintbrush5.png b/scripts/system/fingerPaint/content/brushes/paintbrush5.png deleted file mode 100644 index b523fe916e..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/paintbrush5.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/pastel.png b/scripts/system/fingerPaint/content/brushes/pastel.png deleted file mode 100644 index 01fdc1e5f1..0000000000 Binary files a/scripts/system/fingerPaint/content/brushes/pastel.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/brushes/gimickkywhite/polka.png b/scripts/system/fingerPaint/content/brushes/polka.png similarity index 100% rename from scripts/system/fingerPaint/content/brushes/gimickkywhite/polka.png rename to scripts/system/fingerPaint/content/brushes/polka.png diff --git a/scripts/system/fingerPaint/content/brushes/gimickkywhite/snowflakes2.png b/scripts/system/fingerPaint/content/brushes/snowflakes2.png similarity index 100% rename from scripts/system/fingerPaint/content/brushes/gimickkywhite/snowflakes2.png rename to scripts/system/fingerPaint/content/brushes/snowflakes2.png diff --git a/scripts/system/fingerPaint/content/brushes/colored/softy.png b/scripts/system/fingerPaint/content/brushes/softy.png similarity index 100% rename from scripts/system/fingerPaint/content/brushes/colored/softy.png rename to scripts/system/fingerPaint/content/brushes/softy.png diff --git a/scripts/system/fingerPaint/content/brushes/256x256/spat-fine.png b/scripts/system/fingerPaint/content/brushes/spat-fine.png similarity index 100% rename from scripts/system/fingerPaint/content/brushes/256x256/spat-fine.png rename to scripts/system/fingerPaint/content/brushes/spat-fine.png diff --git a/scripts/system/fingerPaint/content/brushes/sponge.png b/scripts/system/fingerPaint/content/brushes/sponge.png index cccc1dfa28..852c35d946 100644 Binary files a/scripts/system/fingerPaint/content/brushes/sponge.png and b/scripts/system/fingerPaint/content/brushes/sponge.png differ diff --git a/scripts/system/fingerPaint/content/brushes/256x256stretched/sponge.png b/scripts/system/fingerPaint/content/brushes/spongeB.png similarity index 100% rename from scripts/system/fingerPaint/content/brushes/256x256stretched/sponge.png rename to scripts/system/fingerPaint/content/brushes/spongeB.png diff --git a/scripts/system/fingerPaint/content/chosen.png b/scripts/system/fingerPaint/content/chosen.png deleted file mode 100644 index c9876546b1..0000000000 Binary files a/scripts/system/fingerPaint/content/chosen.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/ColorUtils2.js b/scripts/system/fingerPaint/content/js/ColorUtils.js similarity index 100% rename from scripts/system/fingerPaint/content/ColorUtils2.js rename to scripts/system/fingerPaint/content/js/ColorUtils.js diff --git a/scripts/system/fingerPaint/content/mathUtils.js b/scripts/system/fingerPaint/content/mathUtils.js deleted file mode 100644 index b8e65b3760..0000000000 --- a/scripts/system/fingerPaint/content/mathUtils.js +++ /dev/null @@ -1,21 +0,0 @@ -.pragma library - -// FIXME(loicm) It would be better to have these functions available in a global -// set of common native C++ functions. - -function clamp(x, min, max) { - return Math.max(min, Math.min(x, max)); -} - -function lerp(x, a, b) { - return ((1.0 - x) * a) + (x * b); -} - -// Linearly project a value x from [xmin, xmax] into [ymin, ymax] -function projectValue(x, xmin, xmax, ymin, ymax) { - return ((x - xmin) * ymax - (x - xmax) * ymin) / (xmax - xmin) -} - -function clampAndProject(x, xmin, xmax, ymin, ymax) { - return projectValue(clamp(x, xmin, xmax), xmin, xmax, ymin, ymax) -} diff --git a/scripts/system/fingerPaint/content/tabicons/brushesBtn.png b/scripts/system/fingerPaint/content/tabicons/brushesBtn.png deleted file mode 100644 index edff19f038..0000000000 Binary files a/scripts/system/fingerPaint/content/tabicons/brushesBtn.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/tabicons/colorpaletteBtn.png b/scripts/system/fingerPaint/content/tabicons/colorpaletteBtn.png deleted file mode 100644 index d96895c1f6..0000000000 Binary files a/scripts/system/fingerPaint/content/tabicons/colorpaletteBtn.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/tabicons/eraser.png b/scripts/system/fingerPaint/content/tabicons/eraser.png deleted file mode 100644 index 46af1a2473..0000000000 Binary files a/scripts/system/fingerPaint/content/tabicons/eraser.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/tabicons/linewidthBtn.png b/scripts/system/fingerPaint/content/tabicons/linewidthBtn.png deleted file mode 100644 index 93cbe7bed4..0000000000 Binary files a/scripts/system/fingerPaint/content/tabicons/linewidthBtn.png and /dev/null differ diff --git a/scripts/system/fingerPaint/content/tabicons/pointingfinger128px.png b/scripts/system/fingerPaint/content/tabicons/pointingfinger128px.png deleted file mode 100644 index 7b68d90b04..0000000000 Binary files a/scripts/system/fingerPaint/content/tabicons/pointingfinger128px.png and /dev/null differ diff --git a/scripts/system/fingerPaint/fingerPaint.js b/scripts/system/fingerPaint/fingerPaint.js index 54d2bffaa8..2115929603 100644 --- a/scripts/system/fingerPaint/fingerPaint.js +++ b/scripts/system/fingerPaint/fingerPaint.js @@ -13,39 +13,34 @@ BUTTON_NAME = "PAINT", //undo vars UNDO_STACK_SIZE = 10, - undoStack = []; - isFingerPainting = false, - isTabletFocused = false, - shouldRestoreTablet = false, - tabletDebugFocusLine = null, + _undoStack = []; + _isFingerPainting = false, + _isTabletFocused = false, + _shouldRestoreTablet = false, MAX_LINE_WIDTH = 0.036, - leftHand = null, - rightHand = null, - leftBrush = null, - rightBrush = null, - isBrushColored = false, - isLeftHandDominant = false, - isMouseDrawing = false, - savedSettings = null, + _leftHand = null, + _rightHand = null, + _leftBrush = null, + _rightBrush = null, + _isBrushColored = false, + _isLeftHandDominant = false, + _isMouseDrawing = false, + _savedSettings = null, + _isTabletDisplayed = false, CONTROLLER_MAPPING_NAME = "com.highfidelity.fingerPaint", - isTabletDisplayed = false, HIFI_POINT_INDEX_MESSAGE_CHANNEL = "Hifi-Point-Index", HIFI_GRAB_DISABLE_MESSAGE_CHANNEL = "Hifi-Grab-Disable", HIFI_POINTER_DISABLE_MESSAGE_CHANNEL = "Hifi-Pointer-Disable", SCRIPT_PATH = Script.resolvePath(''), CONTENT_PATH = SCRIPT_PATH.substr(0, SCRIPT_PATH.lastIndexOf('/')), - ANIMATION_SCRIPT_PATH = Script.resolvePath("content/brushes/animatedBrushes/animatedBrushScript.js"), + ANIMATION_SCRIPT_PATH = Script.resolvePath("content/animatedBrushes/animatedBrushScript.js"), APP_URL = CONTENT_PATH + "/html/main.html"; - // Set up the qml ui - //var qml = Script.resolvePath('PaintWindow.qml'); Script.include("../libraries/controllers.js"); - Script.include("content/ColorUtils2.js"); - Script.include("content/brushes/animatedBrushes/animatedBrushesList.js"); - //var window = null; + Script.include("content/js/ColorUtils.js"); + Script.include("content/animatedBrushes/animatedBrushesList.js"); - //var inkSource = null; - var inkSourceOverlay = null; + var _inkSourceOverlay = null; // Set path for finger paint hand animations var RIGHT_ANIM_URL = Script.resourcesPath() + 'avatar/animations/touch_point_closed_right.fbx'; var LEFT_ANIM_URL = Script.resourcesPath() + 'avatar/animations/touch_point_closed_left.fbx'; @@ -55,38 +50,38 @@ function paintBrush(name) { // Paints in 3D. var brushName = name, - STROKE_COLOR = { - red: savedSettings.currentColor.red, - green: savedSettings.currentColor.green, - blue: savedSettings.currentColor.blue + _strokeColor = { + red: _savedSettings.currentColor.red, + green: _savedSettings.currentColor.green, + blue: _savedSettings.currentColor.blue }, - dynamicColor = null, + _dynamicColor = null, ERASE_SEARCH_RADIUS = 0.1, // m STROKE_DIMENSIONS = { x: 10, y: 10, z: 10 }, - isDrawingLine = false, - isTriggerPressureWidthEnabled = savedSettings.currentTriggerWidthEnabled, - entityID, - basePosition, - strokePoints, - strokeNormals, - strokeColors, - strokeWidths, - timeOfLastPoint, - isContinuousLine = savedSettings.currentIsContinuous, - lastPosition = null, - shouldKeepDrawing = false, - texture = CONTENT_PATH + "/" + savedSettings.currentTexture.brushName, - dynamicEffects = savedSettings.currentDynamicBrushes; + _isDrawingLine = false, + _isTriggerWidthEnabled = _savedSettings.currentTriggerWidthEnabled, + _entityID, + _basePosition, + _strokePoints, + _strokeNormals, + _strokeColors, + _strokeWidths, + _timeOfLastPoint, + _isContinuousLine = _savedSettings.currentIsContinuous, + _lastPosition = null, + _shouldKeepDrawing = false, + _texture = CONTENT_PATH + "/" + _savedSettings.currentTexture.brushName, + _dynamicEffects = _savedSettings.currentDynamicBrushes; //'https://upload.wikimedia.org/wikipedia/commons/thumb/9/93/Caris_Tessellation.svg/1024px-Caris_Tessellation.svg.png', // Daantje - strokeWidthMultiplier = savedSettings.currentStrokeWidth * 2 + 0.1, - IS_UV_MODE_STRETCH = savedSettings.currentTexture.brushType == "stretch", + _strokeWidthMultiplier = _savedSettings.currentStrokeWidth * 2 + 0.1, + _isUvModeStretch = _savedSettings.currentTexture.brushType == "stretch", MIN_STROKE_LENGTH = 0.005, // m MIN_STROKE_INTERVAL = 66, // ms MAX_POINTS_PER_LINE = 70; // Hard-coded limit in PolyLineEntityItem.h. - function strokeNormal() { - if (!isMouseDrawing) { - var controllerPose = isLeftHandDominant + function calculateStrokeNormal() { + if (!_isMouseDrawing) { + var controllerPose = _isLeftHandDominant ? getControllerWorldLocation(Controller.Standard.LeftHand, true) : getControllerWorldLocation(Controller.Standard.RightHand, true); var fingerTipRotation = controllerPose.rotation; @@ -98,17 +93,17 @@ } - function changeStrokeColor(red, green, blue) { - STROKE_COLOR.red = red; - STROKE_COLOR.green = green; - STROKE_COLOR.blue = blue; + function setStrokeColor(red, green, blue) { + _strokeColor.red = red; + _strokeColor.green = green; + _strokeColor.blue = blue; } function getStrokeColor() { - return STROKE_COLOR; + return _strokeColor; } - function nextValueInRange(value, min, max, increment) { + function calculateValueInRange(value, min, max, increment) { var delta = max - min; value += increment; if (value > max) { @@ -119,84 +114,89 @@ } function attacthColorToProperties(properties) { - var isAnyDynamicEffectEnabled = false; + //colored brushes should always be white and no effects should be applied + if (_isBrushColored) { + properties.color = {red: 255, green: 255, blue: 255}; + return; + } - if ("dynamicHue" in dynamicEffects && dynamicEffects.dynamicHue) { + var isAnyDynamicEffectEnabled = false; + if ("dynamicHue" in _dynamicEffects && _dynamicEffects.dynamicHue) { isAnyDynamicEffectEnabled = true; var hueIncrement = 359.0 / 70.0; - dynamicColor.hue = nextValueInRange(dynamicColor.hue, 0, 359, hueIncrement); + _dynamicColor.hue = calculateValueInRange(_dynamicColor.hue, 0, 359, hueIncrement); } - if ("dynamicSaturation" in dynamicEffects && dynamicEffects.dynamicSaturation) { + if ("dynamicSaturation" in _dynamicEffects && _dynamicEffects.dynamicSaturation) { isAnyDynamicEffectEnabled = true; - dynamicColor.saturation = dynamicColor.saturation == 0.2 ? 0.8 : 0.2; - /*var saturationIncrement = 1.0 / 70.0; - dynamicColor.saturation = nextValueInRange(dynamicColor.saturation, 0, 1, saturationIncrement);*/ + _dynamicColor.saturation = _dynamicColor.saturation == 0.2 ? 0.8 : 0.2; + //saturation along the full line + //var saturationIncrement = 1.0 / 70.0; + //_dynamicColor.saturation = calculateValueInRange(_dynamicColor.saturation, 0, 1, saturationIncrement); } - if ("dynamicValue" in dynamicEffects && dynamicEffects.dynamicValue) { + if ("dynamicValue" in _dynamicEffects && _dynamicEffects.dynamicValue) { isAnyDynamicEffectEnabled = true; - dynamicColor.value = dynamicColor.value == 0.2 ? 0.8 : 0.2; - /*var saturationIncrement = 1.0 / 70.0; - dynamicColor.saturation = nextValueInRange(dynamicColor.saturation, 0, 1, saturationIncrement);*/ + _dynamicColor.value = _dynamicColor.value == 0.2 ? 0.8 : 0.2; + //value along the full line + //var saturationIncrement = 1.0 / 70.0; + //_dynamicColor.saturation = calculateValueInRange(_dynamicColor.saturation, 0, 1, saturationIncrement); } if (!isAnyDynamicEffectEnabled) { - properties.color = STROKE_COLOR; + properties.color = _strokeColor; return; } - var newRgbColor = hsv2rgb(dynamicColor); - strokeColors.push({ + var newRgbColor = hsv2rgb(_dynamicColor); + _strokeColors.push({ x: newRgbColor.red/255.0, y: newRgbColor.green/255.0, z: newRgbColor.blue/255.0} ); - properties.strokeColors = strokeColors; + properties.strokeColors = _strokeColors; } - function setDynamicEffects(newDynamicEffects) { - dynamicEffects = newDynamicEffects; + function setDynamicEffects(dynamicEffects) { + _dynamicEffects = dynamicEffects; } - function isDrawing() { - return isDrawingLine; + function isDrawingLine() { + return _isDrawingLine; } - function changeStrokeWidthMultiplier(multiplier) { - // MIN_STROKE_LENGTH = ((multiplier * MIN_STROKE_LENGTH) / 0.25)*0.5; - //print("MIN_STROKE_LENGTH: " + MIN_STROKE_LENGTH); - strokeWidthMultiplier = multiplier; + function setStrokeWidthMultiplier(strokeWidthMultiplier) { + _strokeWidthMultiplier = strokeWidthMultiplier; } - function switchContinuousLine(isContinuous) { - isContinuousLine = isContinuous; + function setIsContinuousLine(isContinuousLine) { + _isContinuousLine = isContinuousLine; } - function setTriggerPressureWidthEnabled(isEnabled) { - isTriggerPressureWidthEnabled = isEnabled; + function setIsTriggerWidthEnabled(isTriggerWidthEnabled) { + _isTriggerWidthEnabled = isTriggerWidthEnabled; } - function changeUVMode(isUVModeStretch) { - IS_UV_MODE_STRETCH = isUVModeStretch; + function setUVMode(isUvModeStretch) { + _isUvModeStretch = isUvModeStretch; } function getStrokeWidth() { - return strokeWidthMultiplier; + return _strokeWidthMultiplier; } function getEntityID() { - return entityID; + return _entityID; } - function changeTexture(textureURL) { - texture = textureURL; + function setTexture(texture) { + _texture = texture; } function undo() { - var undo = undoStack.pop(); - if (undoStack.length == 0) { + var undo = _undoStack.pop(); + if (_undoStack.length == 0) { var undoDisableEvent = {type: "undoDisable", value: true}; tablet.emitScriptEvent(JSON.stringify(undoDisableEvent)); } @@ -206,9 +206,9 @@ //restoring a deleted entity will create a new entity with a new id therefore we need to update //the created elements id in the undo stack. For the delete elements though, it is not necessary //to update the id since you can't delete the same entity twice - for (var i = 0; i < undoStack.length; i++) { - if (undoStack[i].type == "created" && undoStack[i].data == prevEntityId) { - undoStack[i].data = newEntity; + for (var i = 0; i < _undoStack.length; i++) { + if (_undoStack[i].type == "created" && _undoStack[i].data == prevEntityId) { + _undoStack[i].data = newEntity; } } } else { @@ -217,55 +217,55 @@ } function calculateLineWidth(width) { - if (isTriggerPressureWidthEnabled) { - return width * strokeWidthMultiplier; + if (_isTriggerWidthEnabled) { + return width * _strokeWidthMultiplier; } else { - return MAX_LINE_WIDTH * strokeWidthMultiplier; //MAX_LINE_WIDTH + return MAX_LINE_WIDTH * _strokeWidthMultiplier; //MAX_LINE_WIDTH } } function startLine(position, width) { // Start drawing a polyline. - if (isTabletFocused) + if (_isTabletFocused) return; width = calculateLineWidth(width); - if (isDrawingLine) { + if (_isDrawingLine) { print("ERROR: startLine() called when already drawing line"); // Nevertheless, continue on and start a new line. } - if (shouldKeepDrawing) { - strokePoints = [Vec3.distance(basePosition, strokePoints[strokePoints.length - 1])]; + if (_shouldKeepDrawing) { + _strokePoints = [Vec3.distance(_basePosition, _strokePoints[_strokePoints.length - 1])]; } else { - strokePoints = [Vec3.ZERO]; + _strokePoints = [Vec3.ZERO]; } - basePosition = position; - strokeNormals = [strokeNormal()]; - strokeColors = []; - strokeWidths = [width]; - timeOfLastPoint = Date.now(); + _basePosition = position; + _strokeNormals = [calculateStrokeNormal()]; + _strokeColors = []; + _strokeWidths = [width]; + _timeOfLastPoint = Date.now(); var newEntityProperties = { type: "PolyLine", name: "fingerPainting", shapeType: "box", position: position, - linePoints: strokePoints, - normals: strokeNormals, - strokeWidths: strokeWidths, - textures: texture, // Daantje - isUVModeStretch: IS_UV_MODE_STRETCH, + linePoints: _strokePoints, + normals: _strokeNormals, + strokeWidths: _strokeWidths, + textures: _texture, // Daantje + isUVModeStretch: _isUvModeStretch, dimensions: STROKE_DIMENSIONS, }; - dynamicColor = rgb2hsv(STROKE_COLOR); + _dynamicColor = rgb2hsv(_strokeColor); attacthColorToProperties(newEntityProperties); - entityID = Entities.addEntity(newEntityProperties); - isDrawingLine = true; - addAnimationToBrush(entityID); - lastPosition = position; + _entityID = Entities.addEntity(newEntityProperties); + _isDrawingLine = true; + addAnimationToBrush(_entityID); + _lastPosition = position; } function drawLine(position, width) { @@ -276,13 +276,13 @@ width = calculateLineWidth(width); - if (!isDrawingLine) { + if (!_isDrawingLine) { print("ERROR: drawLine() called when not drawing line"); return; } - localPosition = Vec3.subtract(position, basePosition); - distanceToPrevious = Vec3.distance(localPosition, strokePoints[strokePoints.length - 1]); + localPosition = Vec3.subtract(position, _basePosition); + distanceToPrevious = Vec3.distance(localPosition, _strokePoints[_strokePoints.length - 1]); if (distanceToPrevious > MAX_DISTANCE_TO_PREVIOUS) { // Ignore occasional spurious finger tip positions. @@ -290,70 +290,64 @@ } if (distanceToPrevious >= MIN_STROKE_LENGTH - && (Date.now() - timeOfLastPoint) >= MIN_STROKE_INTERVAL - && strokePoints.length < MAX_POINTS_PER_LINE) { - strokePoints.push(localPosition); - //strokeColors.push({x: STROKE_COLOR.red/255.0, y: STROKE_COLOR.green/255.0, z: STROKE_COLOR.blue/255.0}); - strokeNormals.push(strokeNormal()); - strokeWidths.push(width); - timeOfLastPoint = Date.now(); + && (Date.now() - _timeOfLastPoint) >= MIN_STROKE_INTERVAL + && _strokePoints.length < MAX_POINTS_PER_LINE) { + _strokePoints.push(localPosition); + _strokeNormals.push(calculateStrokeNormal()); + _strokeWidths.push(width); + _timeOfLastPoint = Date.now(); var editItemProperties = { - color: STROKE_COLOR, - linePoints: strokePoints, - normals: strokeNormals, - strokeWidths: strokeWidths + color: _strokeColor, + linePoints: _strokePoints, + normals: _strokeNormals, + strokeWidths: _strokeWidths }; attacthColorToProperties(editItemProperties); - Entities.editEntity(entityID, editItemProperties); + Entities.editEntity(_entityID, editItemProperties); - } else if (isContinuousLine && strokePoints.length >= MAX_POINTS_PER_LINE) { + } else if (_isContinuousLine && _strokePoints.length >= MAX_POINTS_PER_LINE) { print("restarting to draw line"); finishLine(position, width); - shouldKeepDrawing = true; - startLine(lastPosition, width); + _shouldKeepDrawing = true; + startLine(_lastPosition, width); } - if (strokePoints.length >= MAX_POINTS_PER_LINE) + if (_strokePoints.length >= MAX_POINTS_PER_LINE) print("restarting to draw linea asdasdadwe"); - lastPosition = position; + _lastPosition = position; } function finishLine(position, width) { // Finish drawing polyline; delete if it has only 1 point. - //print("Before adding script: " + JSON.stringify(Entities.getEntityProperties(entityID))); - var userData = Entities.getEntityProperties(entityID).userData; - if (userData && JSON.parse(userData).animations) { - Entities.editEntity(entityID, { + var userData = Entities.getEntityProperties(_entityID).userData; + if (userData && JSON.parse(userData).animations && !_isBrushColored) { + Entities.editEntity(_entityID, { script: ANIMATION_SCRIPT_PATH, }); } - //print("After adding script: " + JSON.stringify(Entities.getEntityProperties(entityID))); - //setIsDrawingFingerPaint(entityID, false); - //print("already stopped drawing"); width = calculateLineWidth(width); - if (!isDrawingLine) { + if (!_isDrawingLine) { print("ERROR: finishLine() called when not drawing line"); return; } - if (strokePoints.length === 1) { + if (_strokePoints.length === 1) { // Delete "empty" line. - Entities.deleteEntity(entityID); + Entities.deleteEntity(_entityID); } - isDrawingLine = false; - shouldKeepDrawing = false; - addElementToUndoStack({type: "created", data: entityID}); - //print("After adding script 3: " + JSON.stringify(Entities.getEntityProperties(entityID))); + _isDrawingLine = false; + _shouldKeepDrawing = false; + addElementToUndoStack({type: "created", data: _entityID}); } function cancelLine() { // Cancel any line being drawn. - if (isDrawingLine) { - Entities.deleteEntity(entityID); - isDrawingLine = false; + if (_isDrawingLine) { + Entities.deleteEntity(_entityID); + _isDrawingLine = false; } } @@ -377,9 +371,9 @@ for (i = 0, entitiesLength = entities.length; i < entitiesLength; i += 1) { properties = Entities.getEntityProperties(entities[i], ["type", "position", "linePoints"]); if (properties.type === "PolyLine") { - basePosition = properties.position; + _basePosition = properties.position; for (j = 0, pointsLength = properties.linePoints.length; j < pointsLength; j += 1) { - distance = Vec3.distance(position, Vec3.sum(basePosition, properties.linePoints[j])); + distance = Vec3.distance(position, Vec3.sum(_basePosition, properties.linePoints[j])); if (distance <= foundDistance) { found = true; foundID = entities[i]; @@ -393,11 +387,6 @@ if (found) { addElementToUndoStack({type: "deleted", data: Entities.getEntityProperties(foundID)}); Entities.deleteEntity(foundID); - /*Entities.editEntity(entityID, { - color: «, - normals: strokeNormals, - strokeWidths: strokeWidths - });*/ } } @@ -412,17 +401,18 @@ cancelLine: cancelLine, eraseClosestLine: eraseClosestLine, tearDown: tearDown, - changeStrokeColor: changeStrokeColor, - changeStrokeWidthMultiplier: changeStrokeWidthMultiplier, - changeTexture: changeTexture, - isDrawing: isDrawing, + setStrokeColor: setStrokeColor, + setStrokeWidthMultiplier: setStrokeWidthMultiplier, + setTexture: setTexture, + isDrawingLine: isDrawingLine, undo: undo, getStrokeColor: getStrokeColor, getStrokeWidth: getStrokeWidth, getEntityID: getEntityID, - changeUVMode: changeUVMode, - setTriggerPressureWidthEnabled: setTriggerPressureWidthEnabled, - setDynamicEffects: setDynamicEffects + setUVMode: setUVMode, + setIsTriggerWidthEnabled: setIsTriggerWidthEnabled, + setDynamicEffects: setDynamicEffects, + setIsContinuousLine: setIsContinuousLine }; } @@ -467,7 +457,7 @@ var LEFT_HUD_LASER = 1; var RIGHT_HUD_LASER = 2; var BOTH_HUD_LASERS = LEFT_HUD_LASER + RIGHT_HUD_LASER; - if (isLeftHandDominant){ + if (_isLeftHandDominant){ HMD.setHandLasers(RIGHT_HUD_LASER, true, LASER_TRIGGER_COLOR_XYZW, SYSTEM_LASER_DIRECTION); HMD.disableHandLasers(LEFT_HUD_LASER); @@ -478,7 +468,6 @@ } HMD.disableExtraLaser(); - var wasTriggerPressed, fingerTipPosition, lineWidth; @@ -504,45 +493,17 @@ + (triggerValue - TRIGGER_START_WIDTH_RAMP) / TRIGGER_RAMP_WIDTH * RAMP_LINE_WIDTH; } - if ((handName === "left" && isLeftHandDominant) || (handName === "right" && !isLeftHandDominant)){ + if ((handName === "left" && _isLeftHandDominant) || (handName === "right" && !_isLeftHandDominant)){ if (!wasTriggerPressed && isTriggerPressed) { - - // TEST DAANTJE changes to a random color everytime you start a new line - //leftBrush.changeStrokeColor(Math.random()*255, Math.random()*255, Math.random()*255); - //rightBrush.changeStrokeColor(Math.random()*255, Math.random()*255, Math.random()*255); - // TEST Stroke line width - //var dim = Math.random()*4 + +0.5; - //var dim2 = Math.floor( Math.random()*40 + 5); - //leftBrush.changeStrokeWidthMultiplier(dim); - //rightBrush.changeStrokeWidthMultiplier(dim); - + // TEST DAANTJE changes to a random color everytime you start a new line triggerPressedCallback(fingerTipPosition, lineWidth); } else if (wasTriggerPressed && isTriggerPressed) { triggerPressingCallback(fingerTipPosition, lineWidth); } else { - triggerReleasedCallback(fingerTipPosition, lineWidth); - - /* // define condition to switch dominant hands - if (Vec3.length(Vec3.subtract(fingerTipPosition, opositeHandPosition)) < 0.1){ - isLeftHandDominant = !isLeftHandDominant; - - // Test DAANTJE changes texture - // if (Math.random() > 0.5) { - // leftBrush.changeTexture(null); - // rightBrush.changeTexture(null); - // }else { - // leftBrush.changeTexture('http://i.imgur.com/SSWDJtd.png'); - // rightBrush.changeTexture('https://upload.wikimedia.org/wikipedia/commons/thumb/9/93/Caris_Tessellation.svg/1024px-Caris_Tessellation.svg.png'); - // } - - } */ - + triggerReleasedCallback(fingerTipPosition, lineWidth); } - } - } - } function onGripPress(value) { @@ -552,7 +513,6 @@ function updateGripPress() { var fingerTipPosition; - gripValue = gripValue * GRIP_SMOOTH_RATIO + rawGripValue * (1.0 - GRIP_SMOOTH_RATIO); if (isGripPressed) { @@ -562,7 +522,7 @@ if (isGripPressed) { fingerTipPosition = MyAvatar.getJointPosition(handName === "left" ? "LeftHandIndex4" : "RightHandIndex4"); - if ((handName === "left" && isLeftHandDominant) || (handName === "right" && !isLeftHandDominant)){ + if ((handName === "left" && _isLeftHandDominant) || (handName === "right" && !_isLeftHandDominant)){ gripPressedCallback(fingerTipPosition); } } @@ -570,7 +530,7 @@ } function checkTabletHasFocus() { - var controllerPose = isLeftHandDominant + var controllerPose = _isLeftHandDominant ? getControllerWorldLocation(Controller.Standard.LeftHand, true) : getControllerWorldLocation(Controller.Standard.RightHand, true); @@ -580,18 +540,18 @@ origin: fingerTipPosition, direction: Quat.getUp(fingerTipRotation) } - var overlays = Overlays.findRayIntersection(pickRay, false, [HMD.tabletID], [inkSourceOverlay.overlayID]); + var overlays = Overlays.findRayIntersection(pickRay, false, [HMD.tabletID], [_inkSourceOverlay.overlayID]); if (overlays.intersects && HMD.tabletID == overlays.overlayID) { - if (!isTabletFocused) { - isTabletFocused = true; - Overlays.editOverlay(inkSourceOverlay, {visible: false}); + if (!_isTabletFocused) { + _isTabletFocused = true; + Overlays.editOverlay(_inkSourceOverlay, {visible: false}); updateHandAnimations(); pauseProcessing(); } } else { - if (isTabletFocused) { - isTabletFocused = false; - Overlays.editOverlay(inkSourceOverlay, {visible: true}); + if (_isTabletFocused) { + _isTabletFocused = false; + Overlays.editOverlay(_inkSourceOverlay, {visible: true}); resumeProcessing(); updateHandFunctions(); } @@ -599,39 +559,13 @@ } function onUpdate() { - - //update ink Source - // var strokeColor = leftBrush.getStrokeColor(); - // var strokeWidth = leftBrush.getStrokeWidth()*0.06; - - // var position = MyAvatar.getJointPosition(isLeftHandDominant ? "LeftHandIndex4" : "RightHandIndex4"); - // if (inkSource){ - - - // Entities.editEntity(inkSource, { - // color : strokeColor, - // position : position, - // dimensions : { - // x: strokeWidth, - // y: strokeWidth, - // z: strokeWidth} - - // }); - // } else{ - // var inkSourceProps = { - // type: "Sphere", - // name: "inkSource", - // color: strokeColor, - // position: position, - // ignoreForCollisions: true, - - // dimensions: {x: strokeWidth, y:strokeWidth, z:strokeWidth} - // } - // inkSource = Entities.addEntity(inkSourceProps); - // } - if (HMD.tabletID && (((leftBrush == null || rightBrush == null) || (!leftBrush.isDrawing() && !rightBrush.isDrawing())))) { + if (HMD.tabletID + && (((_leftBrush == null || _rightBrush == null) + || (!_leftBrush.isDrawingLine() && !_rightBrush.isDrawingLine())))) { + checkTabletHasFocus(); } + updateTriggerPress(); updateGripPress(); } @@ -645,11 +579,6 @@ function tearDown() { // Nothing to do. - //Entities - //if (inkSource){ - // Entities.deleteEntity(inkSource); - // inkSource = null; - //} } return { @@ -663,7 +592,7 @@ function updateHandFunctions() { // Update other scripts' hand functions. - var enabled = !isFingerPainting || isTabletDisplayed; + var enabled = !_isFingerPainting || _isTabletDisplayed; Messages.sendMessage(HIFI_GRAB_DISABLE_MESSAGE_CHANNEL, JSON.stringify({ holdEnabled: enabled, @@ -674,14 +603,7 @@ Messages.sendMessage(HIFI_POINTER_DISABLE_MESSAGE_CHANNEL, JSON.stringify({ pointerEnabled: false - }), true); - - // Messages.sendMessage(HIFI_POINTER_DISABLE_MESSAGE_CHANNEL, JSON.stringify({ - // pointerEnabled: enabled - //}), true); - //}), true); - - + }), true); Messages.sendMessage(HIFI_POINT_INDEX_MESSAGE_CHANNEL, JSON.stringify({ pointIndex: !enabled @@ -689,9 +611,9 @@ } function updateHandAnimations(){ - var ANIM_URL = (isLeftHandDominant? LEFT_ANIM_URL: RIGHT_ANIM_URL ); - var ANIM_OPEN = (isLeftHandDominant? LEFT_ANIM_URL_OPEN: RIGHT_ANIM_URL_OPEN ); - var handLiteral = (isLeftHandDominant? "left": "right" ); + var ANIM_URL = (_isLeftHandDominant? LEFT_ANIM_URL: RIGHT_ANIM_URL ); + var ANIM_OPEN = (_isLeftHandDominant? LEFT_ANIM_URL_OPEN: RIGHT_ANIM_URL_OPEN ); + var handLiteral = (_isLeftHandDominant? "left": "right" ); //Clear previous hand animation override restoreAllHandAnimations(); @@ -716,15 +638,13 @@ Messages.sendLocalMessage("Hifi-Hand-Disabler", "none"); Messages.sendLocalMessage("Hifi-Hand-Disabler", handLiteral); - - //update ink Source - var strokeColor = leftBrush.getStrokeColor(); - var strokeWidth = leftBrush.getStrokeWidth()*0.06; - if (inkSourceOverlay == null){ - inkSourceOverlay = Overlays.addOverlay("sphere", { parentID: MyAvatar.sessionUUID, parentJointIndex: MyAvatar.getJointIndex(handLiteral === "left" ? "LeftHandIndex4" : "RightHandIndex4"), localPosition: { x: 0, y: 0, z: 0 }, size: strokeWidth, color: strokeColor , solid: true }); + var strokeColor = _leftBrush.getStrokeColor(); + var strokeWidth = _leftBrush.getStrokeWidth()*0.06; + if (_inkSourceOverlay == null){ + _inkSourceOverlay = Overlays.addOverlay("sphere", { parentID: MyAvatar.sessionUUID, parentJointIndex: MyAvatar.getJointIndex(handLiteral === "left" ? "LeftHandIndex4" : "RightHandIndex4"), localPosition: { x: 0, y: 0, z: 0 }, size: strokeWidth, color: strokeColor , solid: true }); } else { - Overlays.editOverlay(inkSourceOverlay, { + Overlays.editOverlay(_inkSourceOverlay, { parentJointIndex: MyAvatar.getJointIndex(handLiteral === "left" ? "LeftHandIndex4" : "RightHandIndex4"), localPosition: { x: 0, y: 0, z: 0 }, size: strokeWidth, @@ -789,20 +709,20 @@ function enableProcessing() { // Connect controller API to handController objects. - leftHand = handController("left"); - rightHand = handController("right"); + _leftHand = handController("left"); + _rightHand = handController("right"); // Connect handController outputs to paintBrush objects. - leftBrush = paintBrush("left"); - leftHand.setUp(leftBrush.startLine, leftBrush.drawLine, leftBrush.finishLine, leftBrush.eraseClosestLine); - rightBrush = paintBrush("right"); - rightHand.setUp(rightBrush.startLine, rightBrush.drawLine, rightBrush.finishLine, rightBrush.eraseClosestLine); + _leftBrush = paintBrush("left"); + _leftHand.setUp(_leftBrush.startLine, _leftBrush.drawLine, _leftBrush.finishLine, _leftBrush.eraseClosestLine); + _rightBrush = paintBrush("right"); + _rightHand.setUp(_rightBrush.startLine, _rightBrush.drawLine, _rightBrush.finishLine, _rightBrush.eraseClosestLine); var controllerMapping = Controller.newMapping(CONTROLLER_MAPPING_NAME); - controllerMapping.from(Controller.Standard.LT).to(leftHand.onTriggerPress); - controllerMapping.from(Controller.Standard.LeftGrip).to(leftHand.onGripPress); - controllerMapping.from(Controller.Standard.RT).to(rightHand.onTriggerPress); - controllerMapping.from(Controller.Standard.RightGrip).to(rightHand.onGripPress); + controllerMapping.from(Controller.Standard.LT).to(_leftHand.onTriggerPress); + controllerMapping.from(Controller.Standard.LeftGrip).to(_leftHand.onGripPress); + controllerMapping.from(Controller.Standard.RT).to(_rightHand.onTriggerPress); + controllerMapping.from(Controller.Standard.RightGrip).to(_rightHand.onGripPress); Controller.enableMapping(CONTROLLER_MAPPING_NAME); //Change to finger paint hand animation @@ -814,158 +734,86 @@ Messages.subscribe(HIFI_POINTER_DISABLE_MESSAGE_CHANNEL); // Update hand controls. - Script.update.connect(leftHand.onUpdate); - Script.update.connect(rightHand.onUpdate); - - - // enable window palette - /*window = new OverlayWindow({ - title: 'Paint Window', - source: qml, - width: 600, height: 600, - });*/ - - // 75 - //50 - //window.setPosition(75, 100); - //window.closed.connect(function() { - //Script.stop(); - //}); uncomment for qml interface - - /*window.fromQml.connect(function(message){ - if (message[0] === "color"){ - leftBrush.changeStrokeColor(message[1], message[2], message[3]); - rightBrush.changeStrokeColor(message[1], message[2], message[3]); - Overlays.editOverlay(inkSourceOverlay, { - color: {red: message[1], green: message[2], blue: message[3]} - }); - return; - } - if (message[0] === "width"){ - print("changing brush width " + message[1]); - var dim = message[1]*2 +0.1; - print("changing brush dim " + dim); - //var dim2 = Math.floor( Math.random()*40 + 5); - leftBrush.changeStrokeWidthMultiplier(dim); - rightBrush.changeStrokeWidthMultiplier(dim); - Overlays.editOverlay(inkSourceOverlay, { - size: dim * 0.06 - - }); - return; - } - if (message[0] === "brush"){ - print("changing brush to qml " + message[1]); - - //var dim2 = Math.floor( Math.random()*40 + 5); - leftBrush.changeTexture(message[1]); - rightBrush.changeTexture(message[1]); - - if (message[1] === "content/brushes/paintbrush1.png") { - leftBrush.changeUVMode(true); - rightBrush.changeUVMode(true); - }else if (message[1] === "content/brushes/paintbrush3.png") { - leftBrush.changeUVMode(true); - rightBrush.changeUVMode(true); - }else{ - leftBrush.changeUVMode(false); - rightBrush.changeUVMode(false); - } - return; - } - if (message[0] === "undo"){ - leftBrush.undo(); - rightBrush.undo(); - return; - } - if (message[0] === "hand"){ - isLeftHandDominant = !isLeftHandDominant; - updateHandAnimations(); - return; - } - });*/ //uncomment for qml interface + Script.update.connect(_leftHand.onUpdate); + Script.update.connect(_rightHand.onUpdate); } function disableProcessing() { - if (leftHand && rightHand) { - Script.update.disconnect(leftHand.onUpdate); - Script.update.disconnect(rightHand.onUpdate); + if (_leftHand && _rightHand) { + Script.update.disconnect(_leftHand.onUpdate); + Script.update.disconnect(_rightHand.onUpdate); Controller.disableMapping(CONTROLLER_MAPPING_NAME); Messages.sendLocalMessage("Hifi-Hand-Disabler", "none"); - leftBrush.tearDown(); - leftBrush = null; - leftHand.tearDown(); - leftHand = null; + _leftBrush.tearDown(); + _leftBrush = null; + _leftHand.tearDown(); + _leftHand = null; - rightBrush.tearDown(); - rightBrush = null; - rightHand.tearDown(); - rightHand = null; + _rightBrush.tearDown(); + _rightBrush = null; + _rightHand.tearDown(); + _rightHand = null; Messages.unsubscribe(HIFI_POINT_INDEX_MESSAGE_CHANNEL); Messages.unsubscribe(HIFI_GRAB_DISABLE_MESSAGE_CHANNEL); Messages.unsubscribe(HIFI_POINTER_DISABLE_MESSAGE_CHANNEL); - //Restores and clears hand animations restoreAllHandAnimations(); //clears Overlay sphere - Overlays.deleteOverlay(inkSourceOverlay); - inkSourceOverlay = null; - - // disable window palette - //window.close(); //uncomment for qml interface + Overlays.deleteOverlay(_inkSourceOverlay); + _inkSourceOverlay = null; } } //Load last fingerpaint settings function restoreLastValues() { - savedSettings = new Object(); - savedSettings.currentColor = Settings.getValue("currentColor", {red: 250, green: 0, blue: 0, origin: "custom"}), - savedSettings.currentStrokeWidth = Settings.getValue("currentStrokeWidth", 0.25); - savedSettings.currentTexture = Settings.getValue("currentTexture", {brushID: 0}); - savedSettings.currentDrawingHand = Settings.getValue("currentDrawingHand", MyAvatar.getDominantHand() == "left"); - savedSettings.currentAnimatedBrushes = Settings.getValue("currentAnimatedBrushes", []); - savedSettings.customColors = Settings.getValue("customColors", []); - savedSettings.currentTab = Settings.getValue("currentTab", 0); - savedSettings.currentTriggerWidthEnabled = Settings.getValue("currentTriggerWidthEnabled", true); - savedSettings.currentDynamicBrushes = Settings.getValue("currentDynamicBrushes", new Object()); - savedSettings.currentIsContinuous = Settings.getValue("currentIsContinuous", false); - savedSettings.undoDisable = undoStack.length == 0; - isLeftHandDominant = savedSettings.currentDrawingHand; + _savedSettings = new Object(); + _savedSettings.currentColor = Settings.getValue("currentColor", {red: 250, green: 0, blue: 0, origin: "custom"}), + _savedSettings.currentStrokeWidth = Settings.getValue("currentStrokeWidth", 0.25); + _savedSettings.currentTexture = Settings.getValue("currentTexture", {brushID: 0}); + _savedSettings.currentDrawingHand = Settings.getValue("currentDrawingHand", MyAvatar.getDominantHand() == "left"); + _savedSettings.currentAnimatedBrushes = Settings.getValue("currentAnimatedBrushes", []); + _savedSettings.customColors = Settings.getValue("customColors", []); + _savedSettings.currentTab = Settings.getValue("currentTab", 0); + _savedSettings.currentTriggerWidthEnabled = Settings.getValue("currentTriggerWidthEnabled", true); + _savedSettings.currentDynamicBrushes = Settings.getValue("currentDynamicBrushes", new Object()); + _savedSettings.currentIsContinuous = Settings.getValue("currentIsContinuous", false); + _savedSettings.currentIsBrushColored = Settings.getValue("currentIsBrushColored", false); + _savedSettings.undoDisable = _undoStack.length == 0; + //set some global variables + _isLeftHandDominant = _savedSettings.currentDrawingHand; + _isBrushColored = _savedSettings.currentIsBrushColored; } function onButtonClicked() { restoreLastValues(); - //isFingerPainting = false; - var wasFingerPainting = isFingerPainting; + var wasFingerPainting = _isFingerPainting; + _isFingerPainting = !_isFingerPainting; - isFingerPainting = !isFingerPainting; - //print("isFingerPainting: " + isFingerPainting); - if (!isFingerPainting) { + if (!_isFingerPainting) { tablet.gotoHomeScreen(); } - button.editProperties({ isActive: isFingerPainting }); + button.editProperties({ isActive: _isFingerPainting }); if (wasFingerPainting) { - leftBrush.cancelLine(); - rightBrush.cancelLine(); + _leftBrush.cancelLine(); + _rightBrush.cancelLine(); } - if (isFingerPainting) { - //print("opening tablet fingerpaint app"); - tablet.gotoWebScreen(APP_URL + "?" + encodeURIComponent(JSON.stringify(savedSettings))); + if (_isFingerPainting) { + tablet.gotoWebScreen(APP_URL + "?" + encodeURIComponent(JSON.stringify(_savedSettings))); enableProcessing(); - savedSettings = null; + _savedSettings = null; } updateHandFunctions(); - if (!isFingerPainting) { + if (!_isFingerPainting) { disableProcessing(); Controller.mousePressEvent.disconnect(mouseStartLine); Controller.mouseMoveEvent.disconnect(mouseDrawLine); @@ -979,31 +827,31 @@ function onTabletScreenChanged(type, url) { var TABLET_SCREEN_CLOSED = "Closed"; - isTabletDisplayed = type !== TABLET_SCREEN_CLOSED; - isFingerPainting = type === "Web" && url.indexOf("fingerPaint/html/main.html") > -1; - if (!isFingerPainting) { + _isTabletDisplayed = type !== TABLET_SCREEN_CLOSED; + _isFingerPainting = type === "Web" && url.indexOf("fingerPaint/html/main.html") > -1; + if (!_isFingerPainting) { disableProcessing(); } - if (shouldRestoreTablet) { - shouldRestoreTablet = false; - isFingerPainting = false; //in order for it to be re enabled + if (_shouldRestoreTablet) { + _shouldRestoreTablet = false; + _isFingerPainting = false; //in order for it to be re enabled onButtonClicked(); HMD.openTablet(); } - button.editProperties({ isActive: isFingerPainting }); + button.editProperties({ isActive: _isFingerPainting }); updateHandFunctions(); } function onWebEventReceived(event){ - print("Received Web Event: " + event); if (typeof event === "string") { event = JSON.parse(event); } + switch (event.type) { case "appReady": - isTabletFocused = false; //make sure we can set the focus on the tablet again + _isTabletFocused = false; //make sure we can set the focus on the tablet again break; case "changeTab": @@ -1011,29 +859,26 @@ break; case "changeColor": - if (!isBrushColored) { - var changeStrokeColorEvent = {type: "changeStrokeColor", value: event}; - tablet.emitScriptEvent(JSON.stringify(changeStrokeColorEvent)); + if (!_isBrushColored) { + var setStrokeColorEvent = {type: "changeStrokeColor", value: event}; + tablet.emitScriptEvent(JSON.stringify(setStrokeColorEvent)); Settings.setValue("currentColor", event); - //print("changing color..."); - leftBrush.changeStrokeColor(event.red, event.green, event.blue); - rightBrush.changeStrokeColor(event.red, event.green, event.blue); - Overlays.editOverlay(inkSourceOverlay, { + _leftBrush.setStrokeColor(event.red, event.green, event.blue); + _rightBrush.setStrokeColor(event.red, event.green, event.blue); + Overlays.editOverlay(_inkSourceOverlay, { color: {red: event.red, green: event.green, blue: event.blue} }); } break; case "switchTriggerPressureWidth": - //print("changing pressure sensitive width..."); Settings.setValue("currentTriggerWidthEnabled", event.enabled); - leftBrush.setTriggerPressureWidthEnabled(event.enabled); - rightBrush.setTriggerPressureWidthEnabled(event.enabled); + _leftBrush.setIsTriggerWidthEnabled(event.enabled); + _rightBrush.setIsTriggerWidthEnabled(event.enabled); break; case "addCustomColor": - //print("Adding custom color"); var customColors = Settings.getValue("customColors", []); customColors.push({red: event.red, green: event.green, blue: event.blue}); if (customColors.length > event.maxColors) { @@ -1044,55 +889,44 @@ case "changeBrush": - //print("abrushType: " + event.brushType); Settings.setValue("currentTexture", event); + Settings.setValue("currentIsBrushColored", event.isColored); + if (event.brushType === "repeat") { - //print("brushType: " + event.brushType); - leftBrush.changeUVMode(false); - rightBrush.changeUVMode(false); + _leftBrush.setUVMode(false); + _rightBrush.setUVMode(false); + } else if (event.brushType === "stretch") { - //print("brushType: " + event.brushType); - leftBrush.changeUVMode(true); - rightBrush.changeUVMode(true); + _leftBrush.setUVMode(true); + _rightBrush.setUVMode(true); } - isBrushColored = event.isColored; - if (event.isColored) { - Settings.setValue("currentColor", {red: 255, green: 255, blue: 255}); - leftBrush.changeStrokeColor(255, 255, 255); - rightBrush.changeStrokeColor(255, 255, 255); - Overlays.editOverlay(inkSourceOverlay, { - color: {red: 255, green: 255, blue: 255} - }); - } - //print("changing brush to " + event.brushName); + + _isBrushColored = event.isColored; event.brushName = CONTENT_PATH + "/" + event.brushName; - leftBrush.changeTexture(event.brushName); - rightBrush.changeTexture(event.brushName); + _leftBrush.setTexture(event.brushName); + _rightBrush.setTexture(event.brushName); break; case "changeLineWidth": Settings.setValue("currentStrokeWidth", event.brushWidth); var dim = event.brushWidth * 2 + 0.1; - //print("changing brush width dim to " + dim); - //var dim2 = Math.floor( Math.random()*40 + 5); - leftBrush.changeStrokeWidthMultiplier(dim); - rightBrush.changeStrokeWidthMultiplier(dim); - Overlays.editOverlay(inkSourceOverlay, { + _leftBrush.setStrokeWidthMultiplier(dim); + _rightBrush.setStrokeWidthMultiplier(dim); + Overlays.editOverlay(_inkSourceOverlay, { size: dim * 0.06 }); break; case "undo": - //print("Going to undo"); //The undo is called only on the right brush because the undo stack is global, meaning that //calling undo on both the left and right brush would cause the stack to pop twice. //Using the leftBrush instead of the rightBrush would have the exact same effect. - rightBrush.undo(); + _rightBrush.undo(); break; case "changeBrushHand": Settings.setValue("currentDrawingHand", event.DrawingHand == "left"); - isLeftHandDominant = event.DrawingHand == "left"; + _isLeftHandDominant = event.DrawingHand == "left"; updateHandAnimations(); break; @@ -1107,20 +941,20 @@ Settings.setValue("currentAnimatedBrushes", animatedBrushes); AnimatedBrushesInfo[event.animatedBrushName].isEnabled = event.enabled; AnimatedBrushesInfo[event.animatedBrushName].settings = event.settings; - //print("SEtting animated brush" + JSON.stringify(AnimatedBrushesInfo[event.animatedBrushName])); break; case "switchDynamicBrush": var dynamicBrushes = Settings.getValue("currentDynamicBrushes", new Object()); dynamicBrushes[event.dynamicBrushId] = event.enabled; Settings.setValue("currentDynamicBrushes", dynamicBrushes); - rightBrush.setDynamicEffects(dynamicBrushes); - leftBrush.setDynamicEffects(dynamicBrushes); + _rightBrush.setDynamicEffects(dynamicBrushes); + _leftBrush.setDynamicEffects(dynamicBrushes); break; + case "switchIsContinuous": Settings.setValue("currentIsContinuous", event.enabled); - rightBrush.switchIsContinuous(event.enabled); - leftBrush.switchIsContinuous(event.enabled); + _rightBrush.setIsContinuousLine(event.enabled); + _leftBrush.setIsContinuousLine(event.enabled); break; default: @@ -1132,7 +966,6 @@ Object.keys(AnimatedBrushesInfo).forEach(function(animationName) { print(animationName); if (AnimatedBrushesInfo[animationName].isEnabled) { - //print("Adding animation " + animationName); var prevUserData = Entities.getEntityProperties(entityID).userData; prevUserData = prevUserData == "" ? new Object() : JSON.parse(prevUserData); //preserve other possible user data if (prevUserData.animations == null) { @@ -1143,7 +976,6 @@ AnimatedBrushesInfo[animationName].settings, entityID); Entities.editEntity(entityID, {userData: JSON.stringify(prevUserData)}); - //print("Added animation: " + JSON.stringify(Entities.getEntityProperties(entityID))); } }); } @@ -1153,29 +985,25 @@ var undoDisableEvent = {type: "undoDisable", value: false}; tablet.emitScriptEvent(JSON.stringify(undoDisableEvent)); - if (undoStack.length + 1 > UNDO_STACK_SIZE) { - undoStack.splice(0, 1); + if (_undoStack.length + 1 > UNDO_STACK_SIZE) { + _undoStack.splice(0, 1); } - undoStack.push(item); + _undoStack.push(item); } function onHmdChanged(isHMDActive) { var HMDInfo = Settings.getValue("wasFingerPaintingWhenHMDClosed", {isHMDActive: true, wasFingerPainting: false}); - // if (isHMDActive && !isFingerPainting && HMDInfo.wasFingerPainting) { only reopen in hmd mode - if (!isFingerPainting && HMDInfo.wasFingerPainting) { - //print("Restarting fingerPaint app!"); - shouldRestoreTablet = true; + if (!_isFingerPainting && HMDInfo.wasFingerPainting) { + _shouldRestoreTablet = true; HMD.openTablet(); } if (isHMDActive != HMDInfo.isHMDActive) { //check if state is different as some times it will be the same //onHmdChanged seems to be called twice (once before and once after fingerpaint is over) - Settings.setValue("wasFingerPaintingWhenHMDClosed", {isHMDActive: isHMDActive, wasFingerPainting: isFingerPainting}); - //print("Saving finger painting value " + isFingerPainting); + Settings.setValue("wasFingerPaintingWhenHMDClosed", {isHMDActive: isHMDActive, wasFingerPainting: _isFingerPainting}); } } function setUp() { - //print("Setting button..."); tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); if (!tablet) { return; @@ -1186,9 +1014,9 @@ icon: "icons/tablet-icons/finger-paint-i.svg", activeIcon: "icons/tablet-icons/finger-paint-a.svg", text: BUTTON_NAME, - isActive: isFingerPainting + isActive: _isFingerPainting }); - //print("button-1 : " + JSON.stringify(button.getProperties())); + button.clicked.connect(onButtonClicked); // Track whether tablet is displayed or not. tablet.screenChanged.connect(onTabletScreenChanged); @@ -1200,8 +1028,8 @@ return; } - if (isFingerPainting) { - isFingerPainting = false; + if (_isFingerPainting) { + _isFingerPainting = false; updateHandFunctions(); disableProcessing(); } @@ -1218,16 +1046,15 @@ } function mouseDrawLine(event){ - if (rightBrush && rightBrush.isDrawing()) { - rightBrush.drawLine(getFingerPosition(event.x, event.y), MAX_LINE_WIDTH); + if (_rightBrush && _rightBrush.isDrawingLine()) { + _rightBrush.drawLine(getFingerPosition(event.x, event.y), MAX_LINE_WIDTH); } } function mouseStartLine(event){ - //print(JSON.stringify(event)); - if (event.isLeftButton && rightBrush) { - isMouseDrawing = true; - rightBrush.startLine(getFingerPosition(event.x, event.y), MAX_LINE_WIDTH); + if (event.isLeftButton && _rightBrush) { + _isMouseDrawing = true; + _rightBrush.startLine(getFingerPosition(event.x, event.y), MAX_LINE_WIDTH); } //Note: won't work until findRayIntersection works with polylines // @@ -1249,9 +1076,9 @@ } function mouseFinishLine(event){ - isMouseDrawing = false; - if (rightBrush && rightBrush.isDrawing()) { - rightBrush.finishLine(getFingerPosition(event.x, event.y), MAX_LINE_WIDTH); + _isMouseDrawing = false; + if (_rightBrush && _rightBrush.isDrawingLine()) { + _rightBrush.finishLine(getFingerPosition(event.x, event.y), MAX_LINE_WIDTH); } } diff --git a/scripts/system/fingerPaint/html/brushesTab.html b/scripts/system/fingerPaint/html/brushesTab.html index d613484e14..e755190e51 100644 --- a/scripts/system/fingerPaint/html/brushesTab.html +++ b/scripts/system/fingerPaint/html/brushesTab.html @@ -159,37 +159,6 @@ - -
- - @@ -234,16 +203,16 @@
Oil
- - @@ -255,37 +224,37 @@
Koons
- - - - - @@ -304,52 +273,51 @@
Gradient B
- - - - - - - - @@ -361,407 +329,31 @@
Stars
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - \ No newline at end of file diff --git a/scripts/system/fingerPaint/html/colorsTab.html b/scripts/system/fingerPaint/html/colorsTab.html index 73409da78e..9b106f9e73 100644 --- a/scripts/system/fingerPaint/html/colorsTab.html +++ b/scripts/system/fingerPaint/html/colorsTab.html @@ -8,23 +8,32 @@ #colorPicker { display: grid; } + .colorPickerCell { border: none; width: 20px; height: 20px; display: inline-block; } + #colorPickerTable { margin-top: 24px; border-collapse:collapse } + #customColorPicker { height: 50px; } + .colorPickerCell { position: relative; } + #selectedOverlay { + text-align: center; + font-size: 12px; + line-height: 20px; + color: white; background-color: rgba(16, 128, 184, 0.3); top:0; left:0; @@ -38,6 +47,7 @@ background-size: contain; } +
@@ -45,6 +55,7 @@ +