@usman404/crowjs 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/sketch.js ADDED
@@ -0,0 +1,65 @@
1
+ import { Root } from "./Core/Root.js";
2
+ import { Label } from "./UIComponents/Label.js";
3
+
4
+
5
+ /** @type {Root} */
6
+ let root;
7
+ let clickTimes=0;
8
+
9
+ window.setup = function(){
10
+ createCanvas(windowWidth, windowHeight);
11
+ root = new Root();
12
+
13
+ let btnWidth = 200;
14
+ let btnHeight = 100;
15
+
16
+ let btn = new Label((windowWidth/2)-(btnWidth/2), (windowHeight/2)-(btnHeight/2), 200, 100, "Hello! 👋",
17
+ {cornerRadius: 20,
18
+ backgroundColor: "rgba(0, 0, 0, 1)",
19
+ textColor: "rgba(255, 255, 255, 1)",
20
+ });
21
+
22
+ btn.addEventListener("click", (event)=>{
23
+ clickTimes+=1;
24
+ event.target.setText(`You clicked ${clickTimes} \ntimes!`);
25
+ });
26
+
27
+ root.add(btn);
28
+ }
29
+
30
+ window.draw = function () {
31
+ background('rgba(255,255,255,255)');
32
+ root.show();
33
+ root.mouseEnterEventListeners(mouseX, mouseY);
34
+ root.hoverEventListeners(mouseX, mouseY);
35
+ root.mouseLeaveEventListeners(mouseX, mouseY);
36
+ root.keyDownEventListeners(mouseX, mouseY);
37
+ }
38
+
39
+ window.mouseDragged = function (){
40
+ root.mouseDraggedEventListeners(mouseX, mouseY);
41
+ }
42
+
43
+ window.mouseClicked = function(){
44
+ root.mouseClickedEventListeners(mouseX, mouseY);
45
+ }
46
+
47
+ window.mousePressed = function(){
48
+ root.mousePressedEventListeners(mouseX, mouseY);
49
+ }
50
+
51
+ window.mouseReleased = function(){
52
+ root.mouseReleasedEventListeners(mouseX, mouseY);
53
+ }
54
+
55
+ window.mouseWheel = function(event){
56
+ root.mouseWheelEventListeners(mouseX, mouseY, event);
57
+ }
58
+
59
+ window.keyPressed = function(event){
60
+ if (keyCode === UP_ARROW || keyCode === DOWN_ARROW || keyCode === LEFT_ARROW || keyCode === RIGHT_ARROW) {
61
+ event.preventDefault();
62
+ }
63
+
64
+ root.keyPressedEventListeners(mouseX, mouseY);
65
+ }