Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vega-scenegraph

Package Overview
Dependencies
Maintainers
2
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-scenegraph

Vega scenegraph and renderers.

  • 2.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
144K
decreased by-5.44%
Maintainers
2
Weekly downloads
 
Created

What is vega-scenegraph?

The vega-scenegraph npm package is a low-level library for rendering and manipulating scene graphs, which are hierarchical structures representing graphical scenes. It is part of the Vega ecosystem, which is designed for creating, sharing, and exploring data visualizations. The package provides tools for creating and managing graphical elements, handling rendering contexts, and performing hit testing.

What are vega-scenegraph's main functionalities?

Creating and Managing Scene Graphs

This feature allows you to create and manage scene graphs. The code sample demonstrates how to create a new scene graph, add a rectangle mark to it, and append the rectangle to the scene.

const vega = require('vega-scenegraph');

// Create a new scenegraph
const scene = new vega.Scenegraph();

// Add a rectangle mark
const rect = scene.mark('rect').item({
  x: 10,
  y: 10,
  width: 100,
  height: 50,
  fill: 'blue'
});

// Add the rectangle to the scene
scene.root.append(rect);

Rendering Contexts

This feature provides tools for creating rendering contexts. The code sample shows how to create a new scene graph, initialize a canvas rendering context, and render the scene.

const vega = require('vega-scenegraph');

// Create a new scenegraph
const scene = new vega.Scenegraph();

// Create a rendering context
const renderer = new vega.CanvasRenderer().initialize(document.querySelector('canvas'), 500, 500);

// Render the scene
renderer.render(scene.root);

Hit Testing

This feature allows for hit testing, which is the process of determining whether a point or area intersects with graphical elements. The code sample demonstrates how to create a scene graph, add a rectangle, and perform a hit test to check if a point is within the rectangle.

const vega = require('vega-scenegraph');

// Create a new scenegraph
const scene = new vega.Scenegraph();

// Add a rectangle mark
const rect = scene.mark('rect').item({
  x: 10,
  y: 10,
  width: 100,
  height: 50,
  fill: 'blue'
});

// Add the rectangle to the scene
scene.root.append(rect);

// Create a hit test
const hitTest = new vega.HitTest(scene.root);

// Check if a point is within the rectangle
const hit = hitTest.test(20, 20);
console.log(hit); // true if the point (20, 20) is within the rectangle

Other packages similar to vega-scenegraph

FAQs

Package last updated on 17 Jul 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc