feat: sync all remaining python source board configurations

This commit is contained in:
yczpf2019
2026-01-24 16:19:55 +08:00
parent 1990bee9a1
commit 20bde81bbb
519 changed files with 93119 additions and 0 deletions

View File

@@ -0,0 +1,311 @@
/**
* Debugger support for skulpt module
*/
import './skulpt.min.js';
function hasOwnProperty(obj, prop) {
var proto = obj.constructor.prototype;
return (prop in obj) &&
(!(prop in proto) || proto[prop] !== obj[prop]);
}
class Breakpoint {
constructor(filename, lineno, colno) {
this.filename = filename;
this.lineno = lineno;
this.colno = colno;
this.enabled = true;
this.ignore_count = 0;
}
}
export default class Debugger {
constructor(filename, output_callback) {
this.dbg_breakpoints = {};
this.tmp_breakpoints = {};
this.suspension_stack = [];
this.current_suspension = -1;
this.eval_callback = null;
this.suspension = null;
this.output_callback = output_callback;
this.step_mode = false;
this.filename = filename;
}
print(txt) {
if (this.output_callback != null) {
this.output_callback.print(txt);
}
}
get_source_line(lineno) {
if (this.output_callback != null) {
return this.output_callback.get_source_line(lineno);
}
return "";
}
move_up_the_stack() {
this.current_suspension = Math.min(this.current_suspension + 1, this.suspension_stack.length - 1);
}
move_down_the_stack() {
this.current_suspension = Math.max(this.current_suspension - 1, 0);
}
enable_step_mode() {
this.step_mode = true;
}
disable_step_mode() {
this.step_mode = false;
}
get_suspension_stack() {
return this.suspension_stack;
}
get_active_suspension() {
if (this.suspension_stack.length === 0) {
return null;
}
return this.suspension_stack[this.current_suspension];
}
generate_breakpoint_key(filename, lineno) {
var key = filename + "-" + lineno;
return key;
}
check_breakpoints(filename, lineno, colno) {
// If Step mode is enabled then ignore breakpoints since we will just break
// at every line.
if (this.step_mode === true) {
return true;
}
var key = this.generate_breakpoint_key(filename, lineno, colno);
if (hasOwnProperty(this.dbg_breakpoints, key) &&
this.dbg_breakpoints[key].enabled === true) {
var bp = null;
if (hasOwnProperty(this.tmp_breakpoints, key)) {
delete this.dbg_breakpoints[key];
delete this.tmp_breakpoints[key];
return true;
}
this.dbg_breakpoints[key].ignore_count -= 1;
this.dbg_breakpoints[key].ignore_count = Math.max(0, this.dbg_breakpoints[key].ignore_count);
bp = this.dbg_breakpoints[key];
if (bp.ignore_count === 0) {
return true;
}
return false;
}
return false;
}
get_breakpoints_list() {
return this.dbg_breakpoints;
}
disable_breakpoint(filename, lineno, colno) {
var key = this.generate_breakpoint_key(filename, lineno, colno);
if (hasOwnProperty(this.dbg_breakpoints, key)) {
this.dbg_breakpoints[key].enabled = false;
}
}
enable_breakpoint(filename, lineno, colno) {
var key = this.generate_breakpoint_key(filename, lineno, colno);
if (hasOwnProperty(this.dbg_breakpoints, key)) {
this.dbg_breakpoints[key].enabled = true;
}
}
clear_breakpoint(filename, lineno, colno) {
var key = this.generate_breakpoint_key(filename, lineno, colno);
if (hasOwnProperty(this.dbg_breakpoints, key)) {
delete this.dbg_breakpoints[key];
return null;
}
return "Invalid breakpoint specified: " + filename + " line: " + lineno;
}
clear_all_breakpoints() {
this.dbg_breakpoints = {};
this.tmp_breakpoints = {};
}
set_ignore_count(filename, lineno, colno, count) {
var key = this.generate_breakpoint_key(filename, lineno, colno);
if (hasOwnProperty(this.dbg_breakpoints, key)) {
var bp = this.dbg_breakpoints[key];
bp.ignore_count = count;
}
}
set_condition(filename, lineno, colno, lhs, cond, rhs) {
var key = this.generate_breakpoint_key(filename, lineno, colno);
var bp;
if (hasOwnProperty(this.dbg_breakpoints, key)) {
// Set a new condition
bp = this.dbg_breakpoints[key];
} else {
bp = new Breakpoint(filename, lineno, colno);
}
bp.condition = new window.Sk.Condition(lhs, cond, rhs);
this.dbg_breakpoints[key] = bp;
}
print_suspension_info(suspension) {
var filename = suspension.filename;
var lineno = suspension.lineno;
var colno = suspension.colno;
this.print("Hit Breakpoint at <" + filename + "> at line: " + lineno + " column: " + colno + "\n");
this.print("----------------------------------------------------------------------------------\n");
this.print(" ==> " + this.get_source_line(lineno - 1) + "\n");
this.print("----------------------------------------------------------------------------------\n");
}
set_suspension(suspension) {
var parent = null;
if (!hasOwnProperty(suspension, "filename") && suspension.child instanceof window.Sk.misceval.Suspension) {
suspension = suspension.child;
}
// Pop the last suspension of the stack if there is more than 0
if (this.suspension_stack.length > 0) {
this.suspension_stack.pop();
this.current_suspension -= 1;
}
// Unroll the stack to get each suspension.
while (suspension instanceof window.Sk.misceval.Suspension) {
parent = suspension;
this.suspension_stack.push(parent);
this.current_suspension += 1;
suspension = suspension.child;
}
suspension = parent;
this.print_suspension_info(suspension);
}
add_breakpoint(filename, lineno, colno, temporary) {
var key = this.generate_breakpoint_key(filename, lineno, colno);
this.dbg_breakpoints[key] = new Breakpoint(filename, lineno, colno);
if (temporary) {
this.tmp_breakpoints[key] = true;
}
}
suspension_handler(susp) {
return new Promise(function (resolve, reject) {
try {
resolve(susp.resume());
} catch (e) {
reject(e);
}
});
}
resume() {
// Reset the suspension stack to the topmost
this.current_suspension = this.suspension_stack.length - 1;
if (this.suspension_stack.length === 0) {
this.print("No running program");
} else {
var promise = this.suspension_handler(this.get_active_suspension());
promise.then(this.success.bind(this), this.error.bind(this));
}
}
pop_suspension_stack() {
this.suspension_stack.pop();
this.current_suspension -= 1;
}
success(r) {
if (r instanceof window.Sk.misceval.Suspension) {
this.set_suspension(r);
} else {
if (this.suspension_stack.length > 0) {
// Current suspension needs to be popped of the stack
this.pop_suspension_stack();
if (this.suspension_stack.length === 0) {
this.print("Program execution complete");
return;
}
var parent_suspension = this.get_active_suspension();
// The child has completed the execution. So override the child's resume
// so we can continue the execution.
parent_suspension.child.resume = function () {
return r;
};
this.resume();
} else {
this.print("Program execution complete");
}
}
}
error(e) {
this.print("Traceback (most recent call last):");
for (var idx = 0; idx < e.traceback.length; ++idx) {
this.print(" File \"" + e.traceback[idx].filename + "\", line " + e.traceback[idx].lineno + ", in <module>");
var code = this.get_source_line(e.traceback[idx].lineno - 1);
code = code.trim();
code = " " + code;
this.print(code);
}
var err_ty = e.constructor.tp$name;
for (idx = 0; idx < e.args.v.length; ++idx) {
this.print(err_ty + ": " + e.args.v[idx].v);
}
}
asyncToPromise(suspendablefn, suspHandlers, debugger_obj) {
return new Promise(function (resolve, reject) {
try {
var r = suspendablefn();
(function handleResponse(r) {
try {
while (r instanceof window.Sk.misceval.Suspension) {
debugger_obj.set_suspension(r);
return;
}
resolve(r);
} catch (e) {
reject(e);
}
})(r);
} catch (e) {
reject(e);
}
});
}
execute(suspendablefn) {
var r = suspendablefn();
if (r instanceof window.Sk.misceval.Suspension) {
this.suspensions.concat(r);
this.eval_callback(r);
}
}
}

View File

@@ -0,0 +1,6 @@
var $builtinmodule = function(name)
{
var matplotlib = {};
return matplotlib;
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
var $builtinmodule = function (name) {
let pgzhelper= {__name__: new Sk.builtin.str("pgzhelper")};
return pgzhelper;
}

View File

@@ -0,0 +1,393 @@
var $builtinmodule = function(name) {
function fill(arr, val) {
if (Array.prototype.fill) {
return Array.prototype.fill.bind(arr)(val, arguments[2], arguments[3]);
}
// Steps 1-2.
if (arr == null) {
throw new TypeError('arr is null or not defined');
}
var O = Object(arr);
// Steps 3-5.
var len = O.length >>> 0;
// Steps 6-7.
var start = arguments[2];
var relativeStart = start >> 0;
// Step 8.
var k = relativeStart < 0 ?
Math.max(len + relativeStart, 0) :
Math.min(relativeStart, len);
// Steps 9-10.
var end = arguments[3];
var relativeEnd = end === undefined ?
len : end >> 0;
// Step 11.
var final = relativeEnd < 0 ?
Math.max(len + relativeEnd, 0) :
Math.min(relativeEnd, len);
// Step 12.
while (k < final) {
O[k] = value;
k++;
}
// Step 13.
return O;
}
var mod = {};
var COLORS = [
[255, 89, 149], [182, 227, 84], [254, 237, 108], [140, 237, 255],
[158, 111, 254], [137, 156, 161], [248, 248, 242], [191, 70, 70],
[81, 96, 131], [249, 38, 114], [130, 180, 20], [253, 151, 31],
[86, 194, 214], [128, 131, 132], [140, 84, 254], [70, 84, 87]
];
var KWARGS = ['title', 'width', 'height', 'range', 'include_x_axis', 'x_title', 'y_title', 'title_font_size', 'fill', 'stroke', 'x_labels'];
function Chart(options) {
this._options = options;
this._data = [];
}
function rgba(rgb, a) {
return 'rgba(' + rgb.join(',') + ',' + a + ')';
}
Chart.prototype.add = function(label, values) {
this._data.unshift({
name: label,
color: rgba(COLORS[this._data.length%COLORS.length], 0.75),
data: values,
marker : {
symbol: 'circle'
},
stack : 1
});
return '';
}
Chart.prototype.render = function(renderer) {
var options = this._options;
var $elem = Sk.domOutput('<div></div>');
var title_style = {
color: '#FFFFFF'
};
if (options.title_font_size) {
title_style['font-size'] = options.title_font_size + 'px';
}
var xPlotLines = [];
var yPlotLines = [];
if (options.range) {
yPlotLines.push({
value: options.range.min,
width: 1,
color: '#FFFFFF'
});
}
var defaultWidth = Sk.availableWidth || 400;
var defaultHeight = Math.min(defaultWidth, Sk.availableHeight || 300);
var chart = {
chart: {
width : options.width || defaultWidth,
height: options.height || defaultHeight,
backgroundColor: '#000'
},
credits: {
enabled: false
},
title: {
text: options.title,
style : title_style
},
xAxis: {
title: {
text: options.x_title || null,
style : title_style,
margin: 20
},
categories: options.x_labels,
labels : {
enabled: options.x_labels ? true : false
},
tickLength: 0
},
yAxis: {
startOnTick: false,
title: {
text: options.y_title || null,
style : title_style,
margin: 20
},
plotLines: yPlotLines,
min : options.include_x_axis
? 0
: options.range
? options.range.min
: null,
max : options.range ? options.range.max : null,
gridLineDashStyle : 'ShortDash',
gridLineColor: '#DDD',
tickLength: 0
},
legend: {
itemStyle : {
color : '#FFFFFF'
},
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
y: 50,
borderWidth: 0
},
labels : {
style : {
color: '#FFFFFF'
}
},
series: this._data
};
for(var i = 0; i < chart.series.length; i++) {
chart.series[i].legendIndex = chart.series.length - i;
chart.series[i].index = chart.series.length - i;
}
if (renderer) {
chart = renderer(options, chart);
}
$elem.highcharts(chart);
return '';
}
function some(val) {
return val && val !== Sk.builtin.none.none$;
}
function kwfunc(impl, kwargs) {
if (kwargs && kwargs.length) {
impl.co_varnames = ['__self__'].concat(kwargs);
impl.$defaults = fill(new Array(kwargs.length), Sk.builtin.none.none$);
}
return new Sk.builtin.func(impl);
}
function createChartType(type, renderer) {
mod[type] = Sk.misceval.buildClass(mod, function($gbl, $loc) {
$loc.__init__ = kwfunc(
function(self, title, width, height, range, include_x_axis, x_title, y_title, title_font_size, fill, stroke, x_labels) {
var options = {};
if (some(title)) options.title = title.v;
if (some(width)) options.width = width.v;
if (some(height)) options.height = height.v;
if (some(range)) options.range = {
min: range.v[0].v,
max: range.v[1].v
};
if (some(include_x_axis)) options.include_x_axis = include_x_axis.v;
if (some(x_title)) options.x_title = x_title.v;
if (some(y_title)) options.y_title = y_title.v;
if (some(title_font_size)) options.title_font_size = title_font_size.v;
if (some(fill)) options.fill = fill.v;
if (some(stroke)) options.stroke = stroke.v;
if (some(x_labels)) options.x_labels = x_labels.v;
self.instance = new Chart(options);
}, KWARGS
);
$loc.add = new Sk.builtin.func(function(self, label, values) {
values = (values instanceof Sk.builtin.list)
? Sk.ffi.remapToJs(values)
: [values.v];
return self.instance.add(label.v, values);
});
$loc.render = new Sk.builtin.func(function(self) {
var i, key, val;
for (i = 0; i < KWARGS.length; i++) {
key = KWARGS[i];
val = self.tp$getattr(key);
if (typeof val !== "undefined") {
self.instance._options[key] = Sk.ffi.remapToJs(val);
}
}
return self.instance.render(renderer);
});
}, type, []);
}
createChartType('Line', function(options, chart) {
chart.chart.type = options.fill ? 'area' : 'line';
return chart;
});
createChartType('StackedLine', function(options, chart) {
chart.chart.type = options.fill ? 'area' : 'line';
chart.plotOptions = {
area : {
stacking : 'percent'
},
series : {
stacking : 'percent'
}
};
return chart;
});
createChartType('Bar', function(options, chart) {
chart.chart.type = 'column';
return chart;
});
createChartType('StackedBar', function(options, chart) {
chart.chart.type = 'column';
chart.plotOptions = {
column : {
stacking: 'percent'
}
};
return chart;
});
createChartType('HorizontalBar', function(options, chart) {
chart.chart.type = 'bar';
return chart;
});
createChartType('StackedHorizontalBar', function(options, chart) {
chart.chart.type = 'bar';
chart.plotOptions = {
bar : {
stacking: 'percent'
}
};
return chart;
});
createChartType('XY', function(options, chart) {
if (options.stroke === false) {
chart.chart.type = 'scatter'
}
else {
chart.chart.type = options.fill ? 'area' : 'line';
}
chart.xAxis.labels.enabled = true;
return chart;
});
createChartType('Radar', function(options, chart) {
chart.chart.polar = true;
chart.chart.type = 'line';
chart.xAxis = {
categories: options.x_labels,
tickmarkPlacement: 'on',
lineWidth: 0
}
chart.yAxis = {
gridLineInterpolation: 'polygon',
lineWidth: 0,
min: 0,
gridLineDashStyle : 'ShortDash',
gridLineColor: '#DDD'
}
for(var i = 0; i < chart.series.length; i++) {
chart.series[i].pointPlacement = 'on';
}
return chart;
});
createChartType('Pie', function(options, chart) {
chart.chart.type = 'pie';
var slices = [];
var breakdown = [];
var useBreakdown = false;
for(var i = 0; i < chart.series.length; i++) {
var slice = chart.series[i];
if (slice.data.length === 1) {
slices.unshift({
name : slice.name,
color : slice.color,
borderColor : slice.color,
legendIndex : slice.legendIndex,
y : slice.data[0]
});
breakdown.unshift({
name : slice.name,
color : slice.color,
borderColor : slice.color,
y : slice.data[0]
});
}
else {
useBreakdown = true;
var sum = 0;
var maxDecimal = 0;
for(var j = 0; j < slice.data.length; j++) {
var parts = slice.data[j].toString().split('.');
maxDecimal = Math.max(maxDecimal, parts[1] ? parts[1].length : 0);
sum += slice.data[j];
breakdown.unshift({
name: slice.name,
color: 'rgba(0,0,0,0)',
borderColor : slice.color,
y: slice.data[j]
});
}
slices.unshift({
name : slice.name,
color : slice.color,
borderColor : slice.color,
legendIndex : slice.legendIndex,
y : parseFloat(sum.toFixed(maxDecimal))
});
}
}
chart.tooltip = {
formatter: function() {
return this.key + ': ' + this.y;
}
};
chart.plotOptions = {
pie: {
allowPointSelect: !useBreakdown,
cursor: useBreakdown ? null : 'pointer',
shadow: false,
center: ['50%', '50%'],
dataLabels: {
enabled: false
}
}
};
chart.series = [{
name: ' ',
data: slices,
showInLegend: true
}];
if (useBreakdown) {
chart.series.push({
name: ' ',
data: breakdown,
innerSize: '90%',
showInLegend: false
});
}
return chart;
});
return mod;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,229 @@
var $builtinmodule = function (name) {
var sprite = {__name__: new Sk.builtin.str("sprite")};
sprite.createBackground = new Sk.builtin.func(function(img) {
img=Sk.ffi.remapToJs(img);
return Sk.ffi.remapToPy(SPRITE.CreateBackground(img));
});
sprite.Sprite = Sk.misceval.buildClass(sprite, function($gbl, $loc) {
$loc.__init__ = new Sk.builtin.func(function(self, img, x, y, name) {
img=Sk.ffi.remapToJs(img);
x=Sk.ffi.remapToJs(x);
y=Sk.ffi.remapToJs(y);
name=Sk.ffi.remapToJs(name);
self.v$name = Sk.ffi.remapToPy(SPRITE.CreateASprite(img, x, y, name));
});
$loc.show = new Sk.builtin.func(function(self) {
var name = Sk.ffi.remapToJs(self.v$name);
var t = SPRITE.sprites[name];
t.show();
});
$loc.hide = new Sk.builtin.func(function(self) {
var name = Sk.ffi.remapToJs(self.v$name);
var t = SPRITE.sprites[name];
t.hide();
});
$loc.enlarge = new Sk.builtin.func(function(self, s) {
var name = Sk.ffi.remapToJs(self.v$name);
var s = Sk.ffi.remapToJs(s);
var t = SPRITE.sprites[name];
t.enlarge(s);
});
$loc.enlargeTo = new Sk.builtin.func(function(self, s) {
var name = Sk.ffi.remapToJs(self.v$name);
var s = Sk.ffi.remapToJs(s);
var t = SPRITE.sprites[name];
t.enlargeTo(s);
});
$loc.expandTo = new Sk.builtin.func(function(self, s, time) {
var name = Sk.ffi.remapToJs(self.v$name);
var s = Sk.ffi.remapToJs(s);
var t = SPRITE.sprites[name];
return t.expandTo(s, time);
});
$loc.move = new Sk.builtin.func(function(self, step) {
var name = Sk.ffi.remapToJs(self.v$name);
step=Sk.ffi.remapToJs(step);
var t = SPRITE.sprites[name];
t.move(step);
});
$loc.moveTo = new Sk.builtin.func(function(self, x, y) {
var name = Sk.ffi.remapToJs(self.v$name);
x=Sk.ffi.remapToJs(x);
y=Sk.ffi.remapToJs(y);
var t = SPRITE.sprites[name];
t.moveTo(x, y);
});
$loc.slideTo = new Sk.builtin.func(function(self, x, y, time) {
var name = Sk.ffi.remapToJs(self.v$name);
x=Sk.ffi.remapToJs(x);
y=Sk.ffi.remapToJs(y);
time=Sk.ffi.remapToJs(time);
var t = SPRITE.sprites[name];
return t.slideTo(x, y, time);
});
$loc.addX = new Sk.builtin.func(function(self, step) {
var name = Sk.ffi.remapToJs(self.v$name);
step = Sk.ffi.remapToJs(step);
var t = SPRITE.sprites[name];
t.addX(step);
});
$loc.addY = new Sk.builtin.func(function(self, step) {
var name = Sk.ffi.remapToJs(self.v$name);
step = Sk.ffi.remapToJs(step);
var t = SPRITE.sprites[name];
t.addY(step);
});
$loc.getX = new Sk.builtin.func(function(self) {
var name = Sk.ffi.remapToJs(self.v$name);
var t = SPRITE.sprites[name];
return Sk.ffi.remapToPy(t.x);
});
$loc.getY = new Sk.builtin.func(function(self) {
var name = Sk.ffi.remapToJs(self.v$name);
var t = SPRITE.sprites[name];
return Sk.ffi.remapToPy(t.y);
});
$loc.rotate = new Sk.builtin.func(function(self, degree) {
var name = Sk.ffi.remapToJs(self.v$name);
degree=Sk.ffi.remapToJs(degree);
var t = SPRITE.sprites[name];
t.rotate(degree);
});
$loc.rotateTo = new Sk.builtin.func(function(self, degree) {
var name = Sk.ffi.remapToJs(self.v$name);
degree=Sk.ffi.remapToJs(degree);
var t = SPRITE.sprites[name];
t.rotateTo(degree);
});
$loc.circleTo = new Sk.builtin.func(function(self, degree, time) {
var name = Sk.ffi.remapToJs(self.v$name);
degree=Sk.ffi.remapToJs(degree);
var t = SPRITE.sprites[name];
return t.circleTo(degree);
});
$loc.hit = new Sk.builtin.func(function(self, sprite2) {
var name = Sk.ffi.remapToJs(self.v$name);
var name2 = Sk.ffi.remapToJs(sprite2.v$name);
var t = SPRITE.sprites[name];
var t2 = SPRITE.sprites[name2];
return Sk.ffi.remapToPy(t.hit(t2));
});
$loc.outOfScreen = new Sk.builtin.func(function(self) {
var name = Sk.ffi.remapToJs(self.v$name);
var t = SPRITE.sprites[name];
return Sk.ffi.remapToPy(t.outOfScreen());
});
$loc.mouseAction = new Sk.builtin.func(function(self, calc) {
var name = Sk.ffi.remapToJs(self.v$name);
var t = SPRITE.sprites[name];
t.mouseAction(()=>{Sk.misceval.callsim(calc)});
});
$loc.isClicked = new Sk.builtin.func(function(self) {
var name = Sk.ffi.remapToJs(self.v$name);
var t = SPRITE.sprites[name];
return Sk.ffi.remapToPy(t.isDown);
});
// new
$loc.setScale = new Sk.builtin.func(function(self, h, w) {
var name = Sk.ffi.remapToJs(self.v$name);
var t = SPRITE.sprites[name];
t.setScale(h, w);
});
$loc.filterGray = new Sk.builtin.func(function(self) {
var name = Sk.ffi.remapToJs(self.v$name);
var t = SPRITE.sprites[name];
t.filterGray();
});
$loc.filterBrighter = new Sk.builtin.func(function(self) {
var name = Sk.ffi.remapToJs(self.v$name);
var t = SPRITE.sprites[name];
t.filterBrighter();
});
$loc.filterOrigin = new Sk.builtin.func(function(self) {
var name = Sk.ffi.remapToJs(self.v$name);
var t = SPRITE.sprites[name];
t.filterOrigin();
});
}, 'Sprite', []);
sprite.Text = Sk.misceval.buildClass(sprite, function($gbl, $loc) {
$loc.__init__ = new Sk.builtin.func(function(self, text, x, y, name) {
text=Sk.ffi.remapToJs(text);
x=Sk.ffi.remapToJs(x);
y=Sk.ffi.remapToJs(y);
name=Sk.ffi.remapToJs(name);
self.v$name = Sk.ffi.remapToPy(SPRITE.CreateText(text, x, y, name));
});
$loc.changeText = new Sk.builtin.func(function(self, text) {
var name = Sk.ffi.remapToJs(self.v$name);
text=Sk.ffi.remapToJs(text);
var t = SPRITE.texts[name];
t.changeText(text);
});
$loc.show = new Sk.builtin.func(function(self) {
var name = Sk.ffi.remapToJs(self.v$name);
var t = SPRITE.texts[name];
t.show();
});
$loc.hide = new Sk.builtin.func(function(self) {
var name = Sk.ffi.remapToJs(self.v$name);
var t = SPRITE.texts[name];
t.hide();
});
}, 'Text', []);
sprite.clearAllSprites = new Sk.builtin.func(function() {
return Sk.ffi.remapToPy(SPRITE.ClearAllSprites());
});
sprite.repeat = new Sk.builtin.func(function(calc = new Function()) {
SPRITE.Repeat(()=>{Sk.misceval.callsim(calc)});
});
sprite.keyboardListener = new Sk.builtin.func(function(key, calc = new Function()) {
key = Sk.ffi.remapToJs(key);
SPRITE.KeyboardListener(key,()=>{Sk.misceval.callsim(calc)});
});
sprite.isKeyboardHit = new Sk.builtin.func(function(keyvalue) {
keyvalue = Sk.ffi.remapToJs(keyvalue);
return Sk.ffi.remapToPy(SPRITE.IsKeyboardHit(keyvalue));
});
sprite.getTime = new Sk.builtin.func(function() {
return Sk.ffi.remapToPy(Math.floor(SPRITE.timer/1000));
});
sprite.clearTimer = new Sk.builtin.func(function() {
SPRITE.ClearTimer();
});
return sprite;
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
import './skulpt.min.js';
import './skulpt-stdlib.js';
export default window.Sk;

File diff suppressed because it is too large Load Diff