Giter Site home page Giter Site logo

ht.js's Introduction

ht.js

Hyperbolic tessellations in the 2D plane in JavaScript.






Overview

This is a direct port of roice3/Honeycombs from CSharp to TypeScript. It is in the process of being developed over the next few years.

Inspiration

Papers

Notes

Dev

import { Tiling } from './src/Geometry/Tiling'
import { TilingConfig } from './src/Geometry/Tiling'
import { SVG } from './src/Format/SVG'

const config = new TilingConfig(3, 7, 10000)
const tiling = new Tiling(config)
tiling.Generate()
const polygons = tiling.m_tiles.map(tile => tile.Boundary)
SVG.WritePolygons('example.svg', polygons)
# count files with extension
find . -name "*.ts" -type f | wc -l

# count lines in files with extension
find . -name '*.ts' -type f | xargs wc -l

Ideas

The ideal is to have tiles, faces, points, and edges, and work with each tile like that.

const tessellation = new Tessellation(3, 7, {
  point: {
    visibility: 'hidden',
  },
  edge: {
    width: 8,
    fill: 'black',
  },
  face: {
    fill: 'gray',
  },
})

tiling.center(tile)
tiling.lock()
tiling.unlock()
// inch toward another block
tiling.move()
tiling.rotate()
tiling.querySelectorAll('face')
tiling.base
tiline.base.neighbors
tiline.base.points
tiline.base.edges
tiline.base.face
tiline.base.face.style.fill = 0x00ff00
tiline.base.face.addEventListener

tessellation.addEventListener('keyup', e => {
  if (e.key === 'up') {
    tessellation.center(tessellation.center.tiles[0])
  }
})

tessellation.addEventListener('tile:click', event => {
  tessellation.focus(event.currentTarget)
})

tessellation.addEventListener('tile:dblclick', event => {
  tessellation.orient(event.currentTarget)
})

tessellation.rotate(90)

tessellation.addEventListener('tile:remove')
tessellation.addEventListener('tile:create')
tessellation.addEventListener('tile:mouseover')
tessellation.addEventListener('tile:mouseupoutside')
tessellation.addEventListener('tile:click')
tessellation.addEventListener('tile:touchstart')
tessellation.addEventListener('tile:touchend')
tessellation.addEventListener('resize')
tessellation.addEventListener('hover')

tessellation.center.edges.forEach(point => {
  point.style.fill = 'red'
})

function render() {
  tessellation.render()
  requestAnimationFrame(render)
}

ht.js's People

Contributors

kayzethegeek avatar lancejpollard avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

kayzethegeek

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.