npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lambdataro/akashic-primitives

v1.0.0

Published

Graphics drawing primitives for Akashic Engine

Downloads

3

Readme

akashic-primitives

akashic-primitives は直線や楕円といったグラフィックプリミティブを akashic-engine で利用するためのライブラリです。

このライブラリは A. Schiffler 氏による SDL_gfx/SDL2_gfx ライブラリ のコードやアルゴリズムを元に作られています。 SDL_gfx ライブラリと SDL2_gfx ライブラリはどちらも zlib license で公開されています。

SDL2_gfx:

(C) A. Schiffler, aschiffler [at] ferzkopp.net 2012-2018, licensed under the zlib license

SDL_gfx:

(C) A. Schiffler, aschiffler [at] ferzkopp.net 1999-2018, licensed under the zlib license

akashic-primitivesg.Renderer_getImageData_putImageData を利用して描画を行います。 Canvas レンダラでこれらのメソッドが利用できる一方、WebGL レンダラでは利用できないので、 game.jsonrenderers["canvas"] の指定が必要となります。

{
    ...
    "renderers": ["canvas"]
}

プリミティブ一覧

  • pixel(): ピクセルを描く

  • hline(): 水平線を描く
  • vline(): 垂直線を描く
  • line(): 線を描く
  • arc(): 円弧を描く
  • bezier(): ベジェ曲線を描く

図形

  • rectangle(): 長方形を描く
  • ellipse(): 楕円を描く
  • circle(): 円を描く
  • roundedRectangle(): 角丸長方形を描く
  • polygon(): ポリゴンを描く
  • trigon(): 三角形を描く
  • pie(): 扇形を描く

塗りつぶした図形

  • box(): 塗りつぶした長方形を描く
  • filledEllipse(): 塗りつぶした楕円を描く
  • filledCircle(): 塗りつぶした円を描く
  • roundedBox(): 塗りつぶした角丸長方形を描く
  • filledPolygon(): 塗りつぶしたポリゴンを描く
  • filledTrigon(): 塗りつぶした三角形を描く
  • filledPie(): 塗りつぶした扇形を描く

使い方

線を引くには以下のようにします。

var lib = require("@lambdataro/akashic-primitives");

function main() {
	var scene = new g.Scene({ game: g.game });
	scene.onLoad.addOnce(function () {
		var surface = g.game.resourceFactory.createSurface(200, 200);
		var rgba = new Uint8ClampedArray([0, 0, 255, 255]);
		lib.primitives.line(surface.renderer(), 50, 50, 150, 100, rgba);
		new g.Sprite({
			scene: scene,
			parent: scene,
			src: surface,
		});
	});
	g.game.pushScene(scene);
}

module.exports = main;

他の形状は test/ 以下を参照してください。

ビルド方法

$ npm install
$ npm run build

テスト方法

$ npm run prepare
$ npm test