initial commit
This commit is contained in:
114
main.qml
Normal file
114
main.qml
Normal file
@@ -0,0 +1,114 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Window 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import bla 1.0
|
||||
|
||||
Window {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("Hello World")
|
||||
|
||||
property var valuesX: [];
|
||||
property var valuesY: [];
|
||||
|
||||
property int numBalls: 3;
|
||||
|
||||
|
||||
|
||||
Painty {
|
||||
|
||||
id: painty;
|
||||
anchors.fill: parent;
|
||||
|
||||
Row {
|
||||
Button {
|
||||
text: "+";
|
||||
onClicked: {
|
||||
++numBalls;
|
||||
}
|
||||
}
|
||||
Button {
|
||||
text: "-";
|
||||
onClicked: {
|
||||
--numBalls;
|
||||
}
|
||||
}
|
||||
Slider {
|
||||
from: 10;
|
||||
to: 200;
|
||||
onValueChanged: {
|
||||
painty.setSigma(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
|
||||
model: numBalls;
|
||||
|
||||
Rectangle {
|
||||
width: 16;
|
||||
height: 16;
|
||||
x: (index+3) * 32;
|
||||
y: (index+3) * 32;
|
||||
color: "red"
|
||||
//Drag.active: parent
|
||||
MouseArea {
|
||||
anchors.fill: parent;
|
||||
drag.target: parent;
|
||||
onPositionChanged: {
|
||||
//valuesX[index] = parent.x;
|
||||
//valuesY[index] = parent.y;
|
||||
//console.log(parent.x + " " + parent.y);
|
||||
//can.requestPaint();
|
||||
painty.setXY(index, parent.x, parent.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
onPaint: {
|
||||
var ctx = getContext("2d");
|
||||
ctx.fillStyle = Qt.rgba(0, 0, 0, 1);
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
|
||||
var w = 300;
|
||||
var h = 300;
|
||||
var img = context.createImageData(w, h);
|
||||
var s = 1;
|
||||
|
||||
for (var y = 0; y < h; ++y) {
|
||||
for (var x = 0; x < w; ++x) {
|
||||
var sum = 0;
|
||||
for (var idx in valuesX) {
|
||||
var x1 = valuesX[idx];
|
||||
var y1 = valuesY[idx];
|
||||
var dx = x-x1;
|
||||
var dy = y-y1;
|
||||
var dist = Math.sqrt(dx*dx + dy*dy);
|
||||
//var p = 1/Math.sqrt(2*Math.PI*s*s)*Math.exp(-(dist*dist)/(2*s*s));
|
||||
sum += 0;
|
||||
}
|
||||
img.data[(x+y*w)*4+0] = 128;
|
||||
img.data[(x+y*w)*4+1] = 64;
|
||||
img.data[(x+y*w)*4+2] = 32;
|
||||
img.data[(x+y*w)*4+3] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
ctx.putImageData(img, 0, 0);
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user