Code edit (3 edits merged)
Please save this source code
User prompt
make markerAxis transparent
Code edit (2 edits merged)
Please save this source code
User prompt
update the line distance = distance; to Adjust distance to ensure segment's end doesn't exeed lowerLimit
Code edit (9 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: lowerLimit is not defined' in or related to this line: 'pointA.y = Math.max(lowerLimit, lastSegmentEndY);' Line Number: 288
User prompt
Fix Bug: 'Timeout.tick error: lowerLimiy is not defined' in or related to this line: 'pointA.y = Math.max(lowerLimiy, lastSegmentEndY);' Line Number: 288
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
in console log "new segment index=..." convert rotation to degrees
Code edit (1 edits merged)
Please save this source code
User prompt
update drawSegment and drawSegment call to transmit rotation and width instead of x2,y2
Code edit (4 edits merged)
Please save this source code
User prompt
complete the line : var nextSegmentRotation = 0; // Calculate next segment rotation based on pointA and pointB coordinates
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (18 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: currentDelta is not defined' in or related to this line: 'console.log(self.stockValue1 + '->' + self.stockValue2, ' Y1: ' + Math.floor(self.y1) + ' < Y: ' + Math.floor(self.y) + ' < Y2: ' + Math.floor(self.y2), ' / targetY: ' + Math.floor(targetY) + ' -> deltaY: ' + Math.floor(deltaY) + ' Axis: +' + Math.floor(currentDelta));' Line Number: 31
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: segment is not defined' in or related to this line: 'if (moveSegmentsVertically && segment.isFinished) {' Line Number: 19
Code edit (5 edits merged)
Please save this source code
User prompt
add a new independent and fixed horizontal Marker axis at y = game.height *0.25
Code edit (14 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -2,28 +2,32 @@
* Classes
****/
var GraphSegment = Container.expand(function () {
var self = Container.call(this);
+ self.index1 = null;
self.stockValue1 = 0;
self.stockValue2 = 0;
self.x1 = 0;
self.y1 = 0;
self.x2 = 0;
self.y2 = 0;
self.isFinished = false;
var verticalSlideRatio = 1;
- var interpolationSpeed = 1; //0.04; // Adjust this value for speed
+ var interpolationSpeed = 0.04; // Adjust this value for speed
self.updateSlide = function () {
if (moveSegments) {
self.x -= slideAmount * 1;
}
- if (self.isFinished) {
+ if (moveSegmentsVertically) {
//moveSegmentsVertically) {
var currentDelta = horizontalAxis.y - game.height * 0.75;
- var targetY = self.y1 + currentDelta;
+ var targetY = game.height * 0.75 - dollarToYPixelRatio * self.stockValue1 + currentDelta;
var deltaY = (targetY - self.y) * interpolationSpeed;
+ if (self.index1 == 6) {
+ //console.log(self.stockValue1 + '->' + self.stockValue2, ' Y1: ' + Math.floor(self.y1) + ' < Y: ' + Math.floor(self.y) + ' < Y2: ' + Math.floor(self.y2), ' / targetY: ' + Math.floor(targetY) + ' -> deltaY: ' + Math.floor(deltaY));
+ }
self.y += deltaY;
- if (Math.abs(deltaY) < 1) {
+ if (Math.abs(deltaY) <= 1) {
self.y = targetY;
}
//self.y = self.y + currentDelta;
// Current stock value excedent over 100$ (ignore below 100$)
@@ -90,9 +94,9 @@
}
//console.log('moveSegmentsVertically ' + moveSegmentsVertically + ' && self.y (' + self.y + ') == Y0 Axe', moveSegmentsVertically && self.y <= lowerLimit);
if (moveSegmentsVertically && self.y <= lowerLimit) {
self.y = lowerLimit;
- console.log('Ok stop Up movement. Stock value:', Math.floor(stockValuesHistory[graphIndex]), 'Axis Y:', Math.floor(self.y), 'Normal Y:', horizontalAxis.yValue);
+ //console.log('Ok stop Up movement. Stock value:', Math.floor(stockValuesHistory[graphIndex]), 'Axis Y:', Math.floor(self.y), 'Normal Y:', horizontalAxis.yValue);
moveSegmentsVertically = false;
}
}
};
@@ -145,14 +149,14 @@
****/
function setDebugValues() {
stockValuesHistory = [];
var series = [0, 25, 50, 75, 100, 125, 150, 175, 200, 175, 150, 125, 100, 75, 50, 25, 0, 0, 0];
- series = [0, 25, 50, 75, 100, 125, 125, 125, 100, 75, 50, 25, 0, 0, 0];
+ series = [0, 25, 50, 75, 100, 125, 125, 125, 125, 100, 75, 50, 25, 0, 0, 0];
for (var i = 0; i < 1; i++) {
stockValuesHistory = stockValuesHistory.concat(series);
}
}
-var slideAmount = 5.0;
+var slideAmount = 7.0;
var slideAmountVertical = 0.10; // Reduced speed for smoother vertical movement
var moveSegmentsVertically = false;
var verticalSlideThreshold = 500; // Define a global threshold for vertical sliding
// Create and add background asset
@@ -207,9 +211,9 @@
verticalAxis.height = 10;
verticalAxis.y = 0;
var graphPoints = [];
var graphWidth = game.width;
-var segmentWidth = graphWidth / 6; //; / stockValuesHistory.length;
+var segmentWidth = graphWidth / 5; //; / stockValuesHistory.length;
var x, y;
// Compute the coordinates for the graph based on stockValuesHistory
var dollarToYPixelRatio = game.height * 0.5 / 100;
for (var i = 0; i < stockValuesHistory.length; i++) {
@@ -281,16 +285,25 @@
var pointAXMovement = lastSegmentEndX - pointA.x;
var pointAYMovement = lastSegmentEndY - pointA.y;
pointA.x = lastSegmentEndX;
pointA.y = lastSegmentEndY;
+ var upperLimit = game.height * 0.25;
+ if (pointA.y < upperLimit) {
+ moveSegmentsVertically = true;
+ //console.log("Will Slide Down to augment Y by " + verticalSlideAmount);
+ } else if (pointA.y > upperLimit && stockValuesHistory[graphIndex + 1] >= 100) {
+ moveSegmentsVertically = true;
+ //console.log("Will Slide Up to reduce Y by " + verticalSlideAmount);
+ }
var delay = 0.5; // Reduce delay to speed up the drawing of segments
drawingInProgress = true;
drawSegment(game, graphIndex, pointA.x, pointA.y, nextSegmentRotation, distance, delay);
//graphIndex++;
}
}
function drawSegment(gameRef, index, x1, y1, rotation, width, delay) {
var segment = gameRef.addChild(new GraphSegment());
+ segment.index1 = index;
segment.stockValue1 = stockValuesHistory[index];
segment.stockValue2 = stockValuesHistory[index + 1];
segment.x1 = x1;
segment.y1 = y1;
A Technical dark background. Nothing just a gradiant of colors from black to dark blue. Theme : stock market. background
A modern clean empty rectangular button without borders. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
without shadow
a basic empty ui popup with a black background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.