Skip to content

Releases: codehs/chs-js-lib

0.3.5

18 Nov 02:12
a94a406
Compare
Choose a tag to compare

What's Changed

  • Decouple Groups' bounds from their position to fix anchoring issues by @anderoonies in #142
  • call resetDimensions on Text when we update the label by @zgalant in #147

New Contributors

Full Changelog: 0.3.4...0.3.5

0.3.4

08 Apr 23:51
Compare
Choose a tag to compare

What's Changed

Don't print the prompt and result of readLineAsync. input, the public configuration of Console, should handle the prompt message as the argument to the passed function.

0.3.3

08 Apr 23:16
Compare
Choose a tag to compare

What's Changed

Only print the parsed result of readNumber for synchronous input. Asynchronous input prints itself before awaiting input.

0.3.2

08 Apr 22:48
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 0.3.1...0.3.2

0.3.1

07 Apr 05:02
Compare
Choose a tag to compare

What's Changed

Full Changelog: 0.3.0...0.3.1

0.3.0

07 Apr 02:56
Compare
Choose a tag to compare

What's Changed

Asynchronous Input

0.3.0 changes the public API of the Console class. It is now configured with input, output, and clear.

input configures how the asynchronous input methods readLineAsync, readIntAsync, readFloatAsync, and readBooleanAsync receive input. In CodeHS, they receive input via the postMessage API, but the docs have some examples of how you might implement input with an input element. Blocking input with prompt is, for better or worse, the expectation for how many CodeHS programs work, so configuring the default readLine behavior isn't an important option.

output configures how print and println emit output. By default this is console.log, but you can configure it however you'd like. This replaces the previous onPrint option.

clear configures how clear functions. By default this is console.clear. This replaces the previous onClear option.

To read more about asynchronous input, check out this tutorial.

Full Changelog: 0.2.22...0.3.0

0.2.22

20 Mar 04:18
Compare
Choose a tag to compare

What's Changed

  • Improved JSDoc documentation and some module reorganization to support documentation
  • Fix re-sorting to prevent single-frame blips of incorrect sort by @anderoonies in #133

Re-Sorting Fix

This was a tricky little issue that was a result of a performance trade-off that was made for how re-sorting happened in the Graphics manager.

The Graphics manager draws elements from bottom to top, so it requires elements to be sorted from lowest layer to highest layer, and for elements with .alive = true to come before those with .alive = false.

As an optimization, elements' layer would be checked during the redraw loop. As an element was drawn, its _sortInvalidated property was checked to see if its layer had changed. If it had, the Graphics manager would re-sort its elements after the draw. This would cause a single frame where an invalid layering would happen.

To fix this, the Graphics manager now loops over its elements at least twice: once to check for layer changes or .alive changes, once to draw elements, and a potential third time for sorting.

Here's a recording of an example that illustrates this issue, and the accompanying code:

let top = new Rectangle(getWidth(), getHeight());
top.setColor('orange');
top.layer = 2;
add(top);

setTimer(() => {
    let circle = new Circle(30);
    circle.setPosition(getWidth() / 2, getHeight() / 2);
    add(circle);
}, 250);

flicker
You can see that, although the orange rectangle has the higher layer, the first frame that a circle is drawn it will appear above the Rectangle. In this release, that behavior has been removed.

Full Changelog: 0.2.21...0.2.22

0.2.21

04 Mar 23:01
Compare
Choose a tag to compare

What's Changed

Full Changelog: 0.2.20...0.2.21

0.2.20

28 Feb 22:27
Compare
Choose a tag to compare

What's Changed

Full Changelog: 0.2.19...0.2.20

0.2.19

21 Feb 22:55
Compare
Choose a tag to compare

What's Changed

Full Changelog: 0.2.18...0.2.19