GeezerVison is showing github.com — Rewrite skeleton codes · byplus/algorithm-visualizer@2b0bea9
File treeExpand file treeCollapse file tree Open diff view settings src/frontend/files/skeletons
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +33-3Lines changed: 33 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// import visualization libraries | | 2 | +#include "algorithm-visualizer/Array2DTracer.h" | 1 | 3 | #include "algorithm-visualizer/LogTracer.h" | 2 | 4 |
| 3 | | -int main() { | 4 | | - LogTracer logTracer = LogTracer("Scratch Paper"); | | 5 | +#include <vector> | | 6 | +#include <string> | | 7 | + | | 8 | +// define tracer variables | | 9 | +Array2DTracer array2dTracer = Array2DTracer("Grid"); | | 10 | +LogTracer logTracer = LogTracer("Console"); | 5 | 11 |
| 6 | | - logTracer.print("Visualize your own algorithm here!"); | | 12 | +// define input variables | | 13 | +std::vector<std::string> messages{ | | 14 | + "Visualize", | | 15 | + "your", | | 16 | + "own", | | 17 | + "code", | | 18 | + "here!", | | 19 | +}; | 7 | 20 |
| | 21 | +// highlight each line of messages recursively | | 22 | +void highlight(int line) { | | 23 | + if (line >= messages.size()) return; | | 24 | + std::string message = messages[line]; | | 25 | + { | | 26 | + logTracer.print(message); | | 27 | + array2dTracer.selectRow(line, 0, message.size() - 1).delay(); | | 28 | + array2dTracer.deselectRow(line, 0, message.size() - 1); | | 29 | + } | | 30 | + highlight(line + 1); | | 31 | +} | | 32 | + | | 33 | +int main() { | | 34 | + { | | 35 | + array2dTracer.set(messages).delay(); | | 36 | + } | | 37 | + highlight(0); | 8 | 38 | return 0; | 9 | 39 | } |
Collapse file Copy file name to clipboard +34-3Lines changed: 34 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// import visualization libraries | 1 | 2 | import org.algorithm_visualizer.*; | 2 | 3 |
| 3 | 4 | class Main { | 4 | | - public static void main(String[] args) { | 5 | | - LogTracer logTracer = new LogTracer("Scratch Paper"); | | 5 | + // define tracer variables | | 6 | + Array2DTracer array2dTracer = new Array2DTracer("Grid"); | | 7 | + LogTracer logTracer = new LogTracer("Console"); | | 8 | + | | 9 | + // define input variables | | 10 | + String[] messages = { | | 11 | + "Visualize", | | 12 | + "your", | | 13 | + "own", | | 14 | + "code", | | 15 | + "here!", | | 16 | + }; | | 17 | + | | 18 | + // highlight each line of messages recursively | | 19 | + void highlight(int line) { | | 20 | + if (line >= messages.length) return; | | 21 | + String message = messages[line]; | | 22 | + { | | 23 | + logTracer.print(message); | | 24 | + array2dTracer.selectRow(line, 0, message.length() - 1).delay(); | | 25 | + array2dTracer.deselectRow(line, 0, message.length() - 1); | | 26 | + } | | 27 | + highlight(line + 1); | | 28 | + } | 6 | 29 |
| 7 | | - logTracer.print("Visualize your own algorithm here!"); | | 30 | + Main() { | | 31 | + { | | 32 | + array2dTracer.set(messages).delay(); | | 33 | + } | | 34 | + highlight(0); | | 35 | + } | | 36 | + | | 37 | + public static void main(String[] args) { | | 38 | + new Main(); | 8 | 39 | } | 9 | 40 | } |
Collapse file Copy file name to clipboard +32-3Lines changed: 32 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import { LogTracer } from 'algorithm-visualizer'; | | 1 | +// import visualization libraries | | 2 | +import { Array2DTracer, LogTracer } from 'algorithm-visualizer'; | 2 | 3 |
| 3 | | -const logTracer = new LogTracer('Scratch Paper'); | | 4 | +// define tracer variables | | 5 | +const array2dTracer = new Array2DTracer('Grid'); | | 6 | +const logTracer = new LogTracer('Console'); | 4 | 7 |
| 5 | | -logTracer.print('Visualize your own algorithm here!'); | | 8 | +// define input variables | | 9 | +const messages = [ | | 10 | + 'Visualize', | | 11 | + 'your', | | 12 | + 'own', | | 13 | + 'code', | | 14 | + 'here!', | | 15 | +]; | | 16 | + | | 17 | +// highlight each line of messages recursively | | 18 | +function highlight(line) { | | 19 | + if (line >= messages.length) return; | | 20 | + const message = messages[line]; | | 21 | + { | | 22 | + logTracer.print(message); | | 23 | + array2dTracer.selectRow(line, 0, message.length - 1).delay(); | | 24 | + array2dTracer.deselectRow(line, 0, message.length - 1); | | 25 | + } | | 26 | + highlight(line + 1); | | 27 | +} | | 28 | + | | 29 | +(function main() { | | 30 | + { | | 31 | + array2dTracer.set(messages).delay(); | | 32 | + } | | 33 | + highlight(0); | | 34 | +})(); |
|