$\math{A}$

add a bit to x(PStart) so that it always rounds in the right direction when half way between 2 numbers.

$\math{A}$

#4D4D4D

Reset app

#006758

#B00020

#252525

#757575

#949494

#E44461

#DA2570

#E66B9E

#3A6ED6

#5991FF

#008475

#0F8538

#00a83c

#5145A8

#6557D2

#8575FF

#903D14

#BD6C43

#C75000

#E07415

#eeeeee

#2E006758

#2EB00020

$\textbf\textsf{ROUND}$

$\textbf\textsf{PRUEBA OTRO}$

\text{Arrastra el punto para seleccionar un número y observa cómo se redondea.}

randomValues = RandomUniform(1, 20, 100)
randomUnits = Shuffle({1, 2, 3, 4, 5, 6})
randomTenths = Shuffle({1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 5, 5, 5, 5})
roundingIndex = 1
heightA = -0.5795306837967054
roundDecimals: roundingIndex - 1
randomIndex = 98
BUMPLEFT: -1
BUMPRIGHT: 1
randomNums = Zip(round(A), A, randomValues)
minX = Element(randomNums, randomIndex)
animateControl = 0 (slider from 0 to 3)
animateStage1 = If(animateControl < 1, animateControl, 1)
heightD: 1
heightC: heightA + (1 / 2 * (heightD - heightA))
heightB: heightA + (1 / 4 * (heightD - heightA))
physicalX = Sequence(1, 7)
zigZag = PolyLine(Flatten[Sequence[{(K, heightB), If[K ≠ physicalX(-1), (K + 0.5, heightC)]}, K, physicalX(1), physicalX(-1)]])
tickIncrement: 0.1
allTickPositions = Sequence(physicalX(1), physicalX(-1), tickIncrement)
PStart = Point(Zip[(A, heightD), A, allTickPositions])
currentNum: minX + ((x(PStart) - 1) * 10^((-roundDecimals)))
bumpDirection = If(currentNum < 0, BUMPLEFT, BUMPRIGHT)
roundedPhysical: round(x(PStart) + If[bumpDirection ≟ BUMPRIGHT, 0.00001, -0.00001])
pathPoints: {PStart, Intersect[Line[PStart, yAxis], zigZag] + (0, 0.1), Intersect[Line[(roundedPhysical, y(PStart)), yAxis], zigZag] + (0, 0.1), (roundedPhysical, heightA)}
dropDistance: y(PStart) - y(pathPoints(-1))
ballPath = PolyLine(pathPoints)
stopDistance: y(PStart) - y(pathPoints(2))
bumpNeeded = IsInteger(x(PStart + 0.5))
animateStage2 = If(animateControl < 1 ∨ (¬bumpNeeded), 0, If[animateControl > 2, 1, animateControl - 1])
heightLineNoBump = Line(pathPoints(1) - (0, If[bumpNeeded, (stopDistance * animateStage1) + ((1 - stopDistance) * animateStage2), (animateControl / 3 * dropDistance)]), xAxis)
animateStage3 = If(animateControl < 1 + bumpNeeded, 0, If[animateControl > 2 + bumpNeeded, 1, animateControl - 1 - bumpNeeded])
heightLineBump = Line(pathPoints(1) - (0, (animateStage1 * stopDistance) + (animateStage3 * (dropDistance - stopDistance))), xAxis)
trailingZeros = Sum(Sequence["0", i, 1, roundDecimals])
labelIncrement: 10^((-roundDecimals))
roundedNumber: round(((roundedPhysical - 1) * labelIncrement) + minX, 2)
displayRounded = If(roundedPhysical ≟ 1 ∧ roundDecimals > 0, ((("" * roundedNumber) * ".") * trailingZeros), ("" * roundedNumber))
PMove = Intersect(If[bumpNeeded, heightLineBump, heightLineNoBump], ballPath)
validate = false
showanswer = false
showsolution = false
showbuttons = true
pixelsRight: 16
pixelsLeft: 16
pixelsBottom: 16
pixelsTop: 24
basketPoints: {((-2 * tickIncrement), (tickIncrement * 2)), ((-1.5 * tickIncrement), (-1.5 * tickIncrement)), ((1.5 * tickIncrement), (-1.5 * tickIncrement)), ((tickIncrement * 2), (tickIncrement * 2))}
maxX: minX + 7
displayX = Sequence(i, i, minX, maxX, labelIncrement)
tickSize = Zip(If[IsInteger[CLIPBOARDmagicSTRINGA], 0.15, If[IsInteger[(CLIPBOARDmagicSTRINGA * 2)], 0.1, 0.05]], CLIPBOARDmagicSTRINGA, allTickPositions)
speed: 8
showPMove: y(PMove) < heightD
holes = Zip(Circle[(CLIPBOARDmagicSTRINGA, heightB), 0.12], CLIPBOARDmagicSTRINGA, physicalX)
bumpPoints: {(x(pathPoints(2)) + ((If[x(PStart) > 0, -1, 1] * 2) * labelIncrement), y(pathPoints(2))), pathPoints(2)}
BumpStart: (0, y(pathPoints(2)))
BumpEnd: (x(BumpStart) + ((animateStage2 - Max[0, animateStage3 - 0.2]) * (x(PStart) - x(BumpStart))), y(BumpStart))
bumper = Segment(BumpStart, BumpEnd)
PlaceHolder: PStart
currentPath = PolyLine(Append[RemoveUndefined[Zip[If[y(A) > y(PMove), A], A, pathPoints]], PMove])
textResultContents: "\(" + (LaTeX[currentNum]) + "\) redondeado al " + (LaTeX[Element[{"entero", "décimo", "centésimo"}, roundingIndex]]) + " más próximo es \(" + (LaTeX[displayRounded]) + "\)."
textResultCentered: "\text{" + (LaTeX[centerText["800px", textResultContents]]) + "}"
tabOrder: {textCurrentNumber, bRound, PStart, textResultCentered, bReset}
digits1 = Zip(Text[(("" * A) * If[B ≟ 1 ∧ roundDecimals > 0, ("." * trailingZeros), ""]), (B, heightD - 0.1), true, true, 0, -1], A, displayX, B, physicalX)
digits2 = Zip(Text[(("" * A) * If[B ≟ 1 ∧ roundDecimals > 0, ("." * trailingZeros), ""]), (B, heightA - 0.1), true, true, 0, -1], A, displayX, B, physicalX)
numberLine1 = Segment((physicalX(1) - 0.5, heightD), (physicalX(-1) + 0.5, heightD))
numberLine2 = Segment((physicalX(1) - 0.5, heightA), (physicalX(-1) + 0.5, heightA))
lblPoint = Text(("" * currentNum), PStart + (0, 0.3), false, true, 0, 0)
pulsing = 0.6 (slider from 0 to 1, step 0.1)
pulsingCircle = circlePixels(PStart, 7 + (7 * pulsing), Corner[1], Corner[3], Corner[5])
pulsingSpeed: 8
onboarding = true
speedFunc(x) = (If[bumpNeeded, 1, 3] * x) + 3
ticks1 = Zip(Segment[(A, heightD - B), (A, heightD + B)], A, allTickPositions, B, tickSize)
ticks2 = Zip(Segment[(A, heightA - 0.15), (A, heightA)], A, physicalX)

Tool: PixelsToPoint
PixelsToPoint(Corner1,Corner3,Corner5,PixelCoords)
Input: Corner1, Corner3, Corner5, InputPixels
Output: OutputPoint

InputPixels: (100, 200)
xRight: x(Corner3)
xLeft: x(Corner1)
yTop: y(Corner3)
yBottom: y(Corner1)
yCoord: yTop - (y(InputPixels) / y(Corner5) * (yTop - yBottom))
xCoord: (x(InputPixels) / x(Corner5) * (xRight - xLeft)) + xLeft
OutputPoint: (xCoord, yCoord)

Tool: PixelsToPoint (command PixelsToPoint1)
PixelsToPoint(Corner1,Corner3,Corner5,PixelCoords)
Input: Corner1, Corner3, Corner5, InputPixels
Output: OutputPoint

InputPixels: (100, 200)
xRight: x(Corner3)
xLeft: x(Corner1)
yTop: y(Corner3)
yBottom: y(Corner1)
yCoord: yTop - (y(InputPixels) / y(Corner5) * (yTop - yBottom))
xCoord: (x(InputPixels) / x(Corner5) * (xRight - xLeft)) + xLeft
OutputPoint: (xCoord, yCoord)

Tool: centerText
centerText(sizeStr,textStr)
Input: sizeStr, textString
Output: centeredLatex

this is dynamic centered text

centeredLatex: (((("\begin{tabular}\hspace{" * sizeStr) * "}\\") * textString) * "\end{tabular}")

Tool: circlePixels
circlePixels(A,pixelRadius,Corner1,Corner3,Corner5
Input: A, pixelRadius, Corner1, Corner3, Corner5
Output: newCircle

pointRadius: (pixelRadius / x(Corner5) * (x(Corner3) - x(Corner1)))
newCircle = Circle(A, pointRadius)