You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
3.4 KiB

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="semantic/semantic.min.css">
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<script src="semantic/semantic.min.js"></script>
<script src="https://unpkg.com/konva@6.0.0/konva.min.js"></script>
<script src="js/func.js"></script>
<meta charset="utf-8" />
<title>Custom Shape</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
background-color: #f0f0f0;
}
</style>
</head>
<body>
<div class="ui menu">
<div class="item">
<div class="ui primary button">Jouer</div>
</div>
<div class="item">
<div class="ui button">Aide</div>
</div>
<div class="item">
<div class="ui button">Createur</div>
</div>
<div class="item">
<div class="ui button">Records</div>
</div>
</div>
<div id="container" style="border:1px solid red;"></div>
<script>
var stage = new Konva.Stage({
container: 'container',
width: window.innerWidth/2,
height: window.innerHeight/2,
});
var etlogique = {
entre1 : createEtLogique(300,50, "pd"),
entre2 : "200",
sortie : "500",
}
var layer = new Konva.Layer();
/*
* create a triangle shape by defining a
* drawing function which draws a triangle
*/
// add the triangle shape to the layer
var imageObj2 = new Image();
imageObj2.onload = function () {
var yoda = new Konva.Image({
x: 500,
y: 50,
image: imageObj2,
width: 50,
height: 50,
id : "et",
});
// add the shape to the layer
layer.add(yoda);
layer.batchDraw();
};
imageObj2.src = 'img/idea_white.png';
var rect1 = new Konva.Rect({
x: 20,
y: 20,
width: 100,
height: 50,
stroke: 'black',
strokeWidth: 4,
id : "rect",
});
// add the shape to the layer
layer.add(rect1);
console.log(rect1);
var simpleText = new Konva.Text({
x: 20,
y: 20,
text: '0',
fontSize: 30,
fontFamily: 'Calibri',
fill: 'black',
id : "text",
});
layer.add(simpleText);
rect1.on('click', function () {
var et = stage.findOne("#text");
var line = stage.findOne("#line");
var text = et.text() == '1' ? '0' : '1';
var colorline = et.text() == '1' ? 'black' : 'blue';
line.stroke(colorline);
et.text(text);
layer.draw();
});
var redLine = new Konva.Line({
points: [120, 45, 300, 66],
stroke: 'black',
strokeWidth: 3,
lineCap: 'round',
lineJoin: 'round',
id : "line",
});
layer.add(redLine);
var lineFinal = new Konva.Line({
points: [400, 75, 500, 75],
stroke: 'black',
strokeWidth: 3,
lineCap: 'round',
lineJoin: 'round',
id : "lineFinal",
});
layer.add(lineFinal);
// add the layer to the stage
stage.add(layer);
console.log(layer);
</script>
</body>
</html>