Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
cytoscape-canvas
Advanced tools
Readme
An extension to create a canvas over or under a Cytoscape graph. Useful for customizing nodes/edges, drawing backgrounds, etc.
var cytoscape = require('cytoscape');
var cyCanvas = require('cytoscape-canvas');
cyCanvas(cytoscape); // Register extension
var cy = cytoscape({/* ... */});
var layer = cy.cyCanvas();
var canvas = layer.getCanvas();
var ctx = canvas.getContext('2d');
cy.on("render cyCanvas.resize", function(evt) {
layer.resetTransform(ctx);
layer.clear(ctx);
// Draw fixed elements
ctx.fillRect(0, 0, 100, 100); // Top left corner
layer.setTransform(ctx);
// Draw model elements
cy.nodes().forEach(function(node) {
var pos = node.position();
ctx.fillRect(pos.x, pos.y, 100, 100); // At node position
});
});
Download the library:
npm install cytoscape-canvas
,bower install cytoscape-canvas
, orrequire()
the library as appropriate for your project:
CommonJS:
var cytoscape = require('cytoscape');
var cyCanvas = require('cytoscape-canvas');
cyCanvas(cytoscape); // Register extension
AMD:
require(['cytoscape', 'cytoscape-canvas'], function(cytoscape, cyCanvas) {
cyCanvas(cytoscape); // Register extension
});
Plain HTML/JS has the extension registered for you automatically, because no require()
is needed.
var cy = cytoscape({/* ... */});
var layer = cy.cyCanvas({
zIndex: 1,
pixelRatio: "auto",
});
layer.getCanvas()
layer.setTransform(ctx)
Set the context transform to match Cystoscape's zoom & pan. Further drawing will be on model position.
layer.resetTransform(ctx)
Reset the context transform. Further drawing will be on rendered position.
layer.clear(ctx)
Clear the entire canvas.
cyCanvas.resize
: When the extension's canvas is resized
FAQs
A Cytoscape extension to enable drawing over and under a graph
The npm package cytoscape-canvas receives a total of 6,569 weekly downloads. As such, cytoscape-canvas popularity was classified as popular.
We found that cytoscape-canvas demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.