Options
All
  • Public
  • Public/Protected
  • All
Menu

Vector.js

Vector.js is a Javascript library for creating interactive graphics on the web. The library uses the existing web standards: HTML, SVG, and CSS and has no dependencies. See the Website for getting started, examples, and more.

Development

Clone the repository to your local environment.

git clone https://github.com/vector-js/vector.git

Install NPM dependencies

npm install

Build the library

npm run build

Then start a local server to view the examples in the "index.html" page.

npm start

Web Site Development

Navigate into the website folder

cd website

Serve a local version of the site

hugo server

Tools

Acknowledgements

Big shout out to Tania Rascia for her SCSS boilerplate, New Moon Syntax Theme, and inspiration.

Index

Type aliases

CoreAttributes

CoreAttributes: "id" | "tabindex" | "style" | "class" | "lang" | "autofocus" | "xml:space" | "transform"

These global attributes are associated with every SVG element in the DOM. TODO: probably remove transform from this list

ShapeAttributes

ShapeAttributes: "marker-start" | "marker-mid" | "marker-end" | "transform"

TextAttributes

TextAttributes: "baseline-shift" | "text-anchor" | "alignment-baseline"

Functions

PointWhereTwoLinesIntersect

  • Returns the point where two lines intersect. The first line is defined by the points p1 and p2. The second line is defined by the points p3 and p4.

    Parameters

    Returns Point

download

  • download(id: string, filename: string): void
  • Downloads the current drawing as an svg file.

    Parameters

    • id: string
    • filename: string

    Returns void

getScriptName

  • getScriptName(trimExtension?: boolean): string
  • Returns the current script name.

    Parameters

    • Default value trimExtension: boolean = true

    Returns string

getURL

  • getURL(url: string): Promise<string>
  • Returns a promise containing the response object.

    Parameters

    • url: string

    Returns Promise<string>

getUrlParams

  • getUrlParams(str: string): Map<string, string>
  • Gets the URL parameters of the current session.

    Parameters

    • str: string

    Returns Map<string, string>

isPrime

  • isPrime(n: number): boolean
  • Returns true if the number is prime, false otherwise.

    Parameters

    • n: number

    Returns boolean

loadScript

  • loadScript(url: string, element: HTMLElement): Promise<string>
  • Loads the interactive script at the provided url into the provided HTMLElement.

    Parameters

    • url: string
    • element: HTMLElement

    Returns Promise<string>

nextPrime

  • nextPrime(n: number): number
  • Returns the next prime number after the given integer.

    Parameters

    • n: number

    Returns number

parseName

  • parseName(path: string, trimExtension?: boolean): string
  • Returns the filename portion of a file path.

    Parameters

    • path: string
    • Default value trimExtension: boolean = true

    Returns string

parseSVG

  • parseSVG(svg: any): SVGElement
  • Parses and returns the SVG documented represented by the string argument.

    Parameters

    • svg: any

    Returns SVGElement

saveAs

  • saveAs(blob: any, name: any, opts: any): void
  • Parameters

    • blob: any
    • name: any
    • opts: any

    Returns void

saveSVG

  • saveSVG(filename: any, data: any): void
  • Parameters

    • filename: any
    • data: any

    Returns void

setUrlParams

  • setUrlParams(param: string, value: string): void
  • Parameters

    • param: string
    • value: string

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc