MCPcopy
hub / github.com/tensorflow/playground / drawNode

Function drawNode

src/playground.ts:423–535  ·  view source on GitHub ↗
(cx: number, cy: number, nodeId: string, isInput: boolean,
    container, node?: nn.Node)

Source from the content-addressed store, hash-verified

421}
422
423function drawNode(cx: number, cy: number, nodeId: string, isInput: boolean,
424 container, node?: nn.Node) {
425 let x = cx - RECT_SIZE / 2;
426 let y = cy - RECT_SIZE / 2;
427
428 let nodeGroup = container.append("g")
429 .attr({
430 "class": "node",
431 "id": `node${nodeId}`,
432 "transform": `translate(${x},${y})`
433 });
434
435 // Draw the main rectangle.
436 nodeGroup.append("rect")
437 .attr({
438 x: 0,
439 y: 0,
440 width: RECT_SIZE,
441 height: RECT_SIZE,
442 });
443 let activeOrNotClass = state[nodeId] ? "active" : "inactive";
444 if (isInput) {
445 let label = INPUTS[nodeId].label != null ?
446 INPUTS[nodeId].label : nodeId;
447 // Draw the input label.
448 let text = nodeGroup.append("text").attr({
449 class: "main-label",
450 x: -10,
451 y: RECT_SIZE / 2, "text-anchor": "end"
452 });
453 if (/[_^]/.test(label)) {
454 let myRe = /(.*?)([_^])(.)/g;
455 let myArray;
456 let lastIndex;
457 while ((myArray = myRe.exec(label)) != null) {
458 lastIndex = myRe.lastIndex;
459 let prefix = myArray[1];
460 let sep = myArray[2];
461 let suffix = myArray[3];
462 if (prefix) {
463 text.append("tspan").text(prefix);
464 }
465 text.append("tspan")
466 .attr("baseline-shift", sep === "_" ? "sub" : "super")
467 .style("font-size", "9px")
468 .text(suffix);
469 }
470 if (label.substring(lastIndex)) {
471 text.append("tspan").text(label.substring(lastIndex));
472 }
473 } else {
474 text.append("tspan").text(label);
475 }
476 nodeGroup.classed(activeOrNotClass, true);
477 }
478 if (!isInput) {
479 // Draw the node's bias.
480 nodeGroup.append("rect")

Callers 1

drawNetworkFunction · 0.85

Calls 4

updateHoverCardFunction · 0.85
updateDecisionBoundaryFunction · 0.85
resetFunction · 0.85
updateBackgroundMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…