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
@@ -263,81 +263,38 @@
updateStockValueText();
var pointA = graphPoints[graphIndex];
var pointB = graphPoints[graphIndex + 1];
var nextSegmentRotation = Math.atan2(pointB.y - pointA.y, pointB.x - pointA.x); // Calculate next segment rotation based on pointA and pointB coordinates
- var lastSegment = graphSegments.length > 0 ? graphSegments[graphSegments.length - 1] : null;
- console.log("drawNextSegment " + graphIndex + '-' + (graphIndex + 1) + ' w=' + segmentWidth);
- var lastSegmentEndX = lastSegment ? lastSegment.x + Math.cos(lastSegment.rotation) * lastSegment.width : graphPoints[graphIndex].x;
- var lastSegmentEndY = lastSegment ? lastSegment.y + Math.sin(lastSegment.rotation) * lastSegment.width : graphPoints[graphIndex].y;
- var pointAXMovement = lastSegmentEndX - pointA.x;
- var pointAYMovement = lastSegmentEndY - pointA.y;
- console.log("pointAXMovement " + graphIndex + '-' + (graphIndex + 1) + ' Dx=' + Math.floor(pointAXMovement), ' Dy=' + Math.floor(pointAYMovement));
- pointA.x = lastSegmentEndX;
- pointA.y = lastSegmentEndY;
- if (graphIndex > 0) {
- //pointB.x += Math.abs(pointAXMovement) > 0 ? Math.min(-160, pointAXMovement) : -160;
- }
- //pointB.y += pointAYMovement;
- // test with ax
- pointB.y += horizontalAxis.y - game.height * 0.75;
- var currentYDelta = Math.abs(horizontalAxis.y - game.height * 0.75);
- var upperLimit = game.height * 0.25 - currentYDelta;
- var lowerLimit = game.height * 0.75 - currentYDelta;
- verticalSlideAmount = upperLimit - pointB.y;
- if (pointB.y < upperLimit) {
- moveSegmentsVertically = true;
- console.log("Will Slide Down to augment Y by " + verticalSlideAmount);
- } else if (pointB.y > upperLimit && stockValuesHistory[graphIndex + 1] >= 100) {
- moveSegmentsVertically = true;
- console.log("Will Slide Up to reduce Y by " + verticalSlideAmount);
- }
+ var distance = Math.sqrt(Math.pow(pointB.x - pointA.x, 2) + Math.pow(pointB.y - pointA.y, 2)); // Calculate the distance between points A and B
var delay = 0.5; // Reduce delay to speed up the drawing of segments
drawingInProgress = true;
- drawSegment(game, graphIndex, pointA.x, pointA.y, pointB.x, pointB.y, delay);
+ drawSegment(game, graphIndex, pointA.x, pointA.y, nextSegmentRotation, distance, delay);
graphIndex++;
}
}
-function drawSegment(gameRef, index, x1, y1, x2, y2, delay) {
+function drawSegment(gameRef, index, x1, y1, rotation, width, delay) {
var segment = gameRef.addChild(new GraphSegment());
segment.stockValue1 = stockValuesHistory[index];
segment.stockValue2 = stockValuesHistory[index + 1];
segment.x1 = x1;
segment.y1 = y1;
- segment.x2 = x2;
- segment.y2 = y2;
- // Adjust segment's y position if vertical movement is enabled
- if (moveSegmentsVertically) {
- //segment.y += moveSegmentsVertically && y1 < verticalSlideThreshold ? slideAmountVertical : 0;
- }
+ segment.rotation = rotation;
+ segment.width = 1; // Start with a width of 1 and animate to the target width
+ segment.height = 20;
// Add the new segment to the global graphSegments array
graphSegments.push(segment);
- console.log('new segment index=' + index + '-' + (index + 1) + " " + stockValuesHistory[index] + "-" + stockValuesHistory[index + 1] + "$", Math.floor(x1), Math.floor(y1), Math.floor(x2), Math.floor(y2));
+ console.log('new segment index=' + index + '-' + (index + 1) + " " + stockValuesHistory[index] + "-" + stockValuesHistory[index + 1] + "$", Math.floor(x1), Math.floor(y1), 'rotation=' + rotation, 'width=' + width);
segment.x = x1;
segment.y = y1;
- segment.width = 1;
- segment.height = 20;
- var deltaX = x2 - x1;
- var deltaY = y2 - y1;
- if (deltaX === 0 && deltaY === 0) {
- console.error('Invalid deltaX and deltaY for rotation calculation.');
- return;
- }
- var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
- console.log('distance =' + distance);
- segment.rotation = Math.atan2(deltaY, deltaX);
- /*console.log('segment.rotation ' + (graphSegments.length - 1), {
- deltaY: deltaY,
- deltaX: deltaX
- }, segment.rotation);*/
var startTime = Date.now();
var endTime = startTime + delay * 1000 * secondsPerSegment;
var updateWidth = function updateWidth() {
if (!running) {
return;
}
var currentTime = Date.now();
var timeElapsed = currentTime - startTime;
- var newWidth = Math.min(timeElapsed / (delay * 1000 * secondsPerSegment) * distance, distance);
+ var newWidth = Math.min(timeElapsed / (delay * 1000 * secondsPerSegment) * width, width);
segment.width = newWidth;
if (currentTime < endTime) {
LK.setTimeout(updateWidth, 16);
} else {
@@ -346,9 +303,8 @@
console.log("Past center !");
}
segment.isFinished = true;
drawingInProgress = false;
- //graphIndex++;
}
};
updateWidth();
}
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.