Socket
Book a DemoInstallSign in
Socket

golf-2d-graphs-prototype

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

golf-2d-graphs-prototype

Visualisation module for golf statistics

latest
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

Golf 2D Graphs Prototype

Golf statistics and graph visualisations using the Canvas API.

Adding further visualisations

Any new canvas visualisation can be added as a new static method on the Golf2DGraphs class, prefixed with "render" and passed as an argument to Golf2DGraphs.init. This method can render anything the the canvas context (Golf2DGraphs.ctx).

For elements and coordinates needing to be resized, use the util functions getShapeSize() to set them dynamically based on the window size.

NOTE - Perspective

Overall view perspective is controlled using the constant VIEW_PERPECTIVE, which will be applied to all elements drawn with the transformByPerspective() util.

For elements drawn without perspective (ie arcs and markers), their coordinates must be passed to the getTransformedCoordinates() util, unless their y coordinate is the canvas centre (in the case of flags and balls) so transformation doesn't apply.

Adding trees

Trees are rendered via the Tree class, which utilises 2 images converted to base64 and stored within the treeImages object (in src/images.ts). They are indexed using the name taken from the golf 3D assets repo, which is passed to the Tree class when instantiating, ie med5.

Upon instantiating an optional colour string parameter can be passed for leaf colour.

Images are saved as a black and white desaturated image with the _leaves suffix, and a coloured trunk image _trunk. These are saved as PNG-8 with 4 or 8 colours, and cropped to >=250 pixels width with the trunk centred, before base64 conversion.

FAQs

Package last updated on 22 Sep 2021

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.