{"id":17011083,"url":"https://github.com/mikuauahdark/kazari","last_synced_at":"2025-04-12T08:34:40.453Z","repository":{"id":64430560,"uuid":"575356246","full_name":"MikuAuahDark/Kazari","owner":"MikuAuahDark","description":"Multitouch gesture and input library.","archived":false,"fork":false,"pushed_at":"2022-12-13T14:40:22.000Z","size":42,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T03:41:41.391Z","etag":null,"topics":["gamedev","love2d","lua","multitouch","touchscreen"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MikuAuahDark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-12-07T10:27:14.000Z","updated_at":"2025-03-03T11:41:58.000Z","dependencies_parsed_at":"2022-12-23T01:14:43.560Z","dependency_job_id":null,"html_url":"https://github.com/MikuAuahDark/Kazari","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikuAuahDark%2FKazari","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikuAuahDark%2FKazari/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikuAuahDark%2FKazari/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikuAuahDark%2FKazari/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MikuAuahDark","download_url":"https://codeload.github.com/MikuAuahDark/Kazari/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248540870,"owners_count":21121442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gamedev","love2d","lua","multitouch","touchscreen"],"created_at":"2024-10-14T06:06:12.606Z","updated_at":"2025-04-12T08:34:40.433Z","avatar_url":"https://github.com/MikuAuahDark.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"Kazari\n=====\n\nKazari is a touch gesture input library.\n\nSetup\n-----\n\nTo start, clone the repository. Say you're in your current project directory (directory where `main.lua` reside), run:\n\n```\ngit clone https://github.com/MikuAuahDark/Kazari libs/kazari\n```\n\nYou can change `libs/kazari` to `libs/hanachirusato` or anywhere else as long as you remember what name to use in `require` later.\n\nTo load the library, use `require`:\n\n```lua\nlocal kazari = require(\"libs.kazari\")\n```\n\nDocumentation\n-----\n\n***********\n\nThese functions are available in Kazari 1.0.0.\n\n### `Constraint`\n\nThis is pseudo-type that can be used to limit where the touch gesture operates on.\n\nThis pseudo-type accept one of these:\n* `nil`, which means touch is unbounded.\n* Array of numbers in order: `{x position, y position, width, height}`\n* Key-value pairs with these structure: `{x = x position, y = y position, w = width, h = height}`\n* [NLay's `BaseConstraint` type](https://github.com/MikuAuahDark/NPad93#nlay)\n\n### `boolean kazari.is(any object, Class\u003c? extends BaseGesture\u003e class)`\n\nCheck if `object` is an instance of `class` where `class` inherits `BaseGesture`.\n\nReturns: is `object` an instance of `class`?\n\nExample:\n```lua\n-- Check if object is an instance of BaseGesture\nprint(kazari.is(object, kazari.BaseGesture))\n```\n\n### `kazari.BaseGesture`\n\nThe `BaseGesture` class. All gesture object inherit this class.\n\n### `boolean BaseGesture:touchpressed(any id, number x, number y, number pressure)`\n\nSend touch pressed event to the gesture. In LÖVE environment, this function should be called in\n[`love.touchpressed`](https://love2d.org/wiki/love.touchpressed) with their arguments passed accordingly.\n\nClass that derive `BaseGesture` may contain `constraint` as their constructor parameter. It's responsible to ensure\nthat only touches at those areas defined by `constraint` are consumed.\n\nReturns: Is the event consumed?\n\n### `boolean BaseGesture:touchmoved(any id, number x, number y, number dx, number dy, number pressure)`\n\nSend touch moved event to the gesture. In LÖVE environment, this function should be called in\n[`love.touchmoved`](https://love2d.org/wiki/love.touchmoved) with their arguments passed accordingly.\n\n### `boolean BaseGesture:touchreleased(any id, number x, number y)`\n\nSend touch released event to the gesture. In LÖVE environment, this function should be called in\n[`love.touchreleased`](https://love2d.org/wiki/love.touchreleased) with their arguments passed accordingly.\n\n### `kazari.ZoomGesture(boolean clip = false, Constraint constraint = nil)`\n\nThe `ZoomGesture` class. This gesture class is responsible of performing pinch zoom using 2 fingers.\nCalling this function creates `ZoomGesture` instance which is derived from `BaseGesture`.\n\nSetting `clip` to `true` restrict each finger movement to the area bounded by `constraint`.\n\n### `void ZoomGesture:onZoom(any context, function func)`\n\nRegister function `func` to be called everytime the zoom ratio is updated, additionally passing\n`context` as the 1st parameter.\n\nThe function signature for `func` must follow this convention:\n\n```\nvoid func(any context, number scale, number midX, number midY)\n```\n\nWhere `scale` always starts at 1 first then increase or decrease based on the finger movement. `midX` and `midY`\nare middle point of the touch position.\n\n### `void ZoomGesture:onZoomComplete(any context, function func)`\n\nSame as above but called when pinch zoom gesture is completed (user lifting their finger).\n\nThe function signature for `func` must follow this convention:\n\n```\nvoid func(any context, number scale)\n```\n\nWhere `scale` is the final scale ratio relative to the first time this gesture is performed.\n\n### `kazari.RotateGesture(Constraint constraint = nil)`\n\nThe `RotateGesture` class. This gesture class is responsible of performing 2-finger rotate gesture.\nCalling this function creates `RotateGesture` instance which is derived from `BaseGesture`.\n\n### `void RotateGesture:onRotate(any context, function func)`\n\nRegister function `func` to be called everytime the angle is updated, additionally passing\n`context` as the 1st parameter.\n\nThe function signature for `func` must follow this convention:\n\n```\nvoid func(any context, number angle, number da)\n```\n\nWhere `angle` always starts at 0 first then increase or decrease based on the finger movement. `angle`\nrange can go above `2 * math.pi` (1 turn clockwise) or below `-2 * math.pi` (1 turn counter-clockwise).\n`da` is angle difference between last angle update. Positive value means clockwise rotation, negative value\nmeans counter-clockwise rotation.\n\n### `void RotateGesture:onRotateComplete(any context, function func)`\n\nSame as above but called when rotate gesture is completed (user lifting their finger) and passes\nthe final value (with the `da` parameter being `nil`).\n\n### `kazari.PanGesture(number minfingers, number maxfingers = minfingers boolean clip = false, Constraint constraint = nil)`\n\nThe `PanGesture` class. This gesture class is responsible of reporting x and y movement from `minfingers`\nfinger(s) (1 included) to `mzxfingers` finger(s) (1 included). Calling this function creates `PanGesture`\ninstance which is derived from `BaseGesture`.\n\nNotes:\n\n* `minfingers` must be at least 1.\n* `maxfingers` must be at least `minfingers` (default).\n* `clip` clips the position of each finger instead of the average.\n\n### `void PanGesture:onMove(any context, function func)`\n\nRegister function `func` to be called everytime the average position is updated, additionally passing\n`context` as the 1st parameter.\n\nThe function signature for `func` must follow this convention:\n\n```\nvoid func(any context, number x, number y, number dx, number dy, number pressure)\n```\n\nWhere `x`, `y` are the relative position of the movement and `pressure` are the average pressure across fingers.\nNote that on pressure-insensitive touchscreens, `pressure` will be always 1. `dx` and `dy` are position differences\nfrom previous call of this function.\n\n### `void PanGesture:onMoveComplete(any context, function func)`\n\nRegister function `func` to be called when user lifting their finger and the amount of fingers registered are less\nthan `minfingers`.\n\nThe function signature for `func` must follow this convention:\n\n```\nvoid func(any context, number x, number y, number pressure)\n```\n\nWhere `x`, `y` are the final relative position of the movement and `pressure` are the average pressure across fingers.\nNote that on pressure-insensitive touchscreens, `pressure` will be always 1.\n\n### `void PanGesture:getTouchCount()`\n\nReturns amount of fingers currently the user has in their screen (depends on the `:touch*` method calls). Returns\nvalue from 0 inclusive to `maxfingers` inclusive.\n\n### `kazari.TapGesture(number nfingers, number moveThreshold = 32, number altDuration = 0, Constraint constraint = nil)`\n\nThe `TapGesture` class. This gesture class is responsible of sending \"tap\" event with at least `nfingers`\nfinger(s) (1 included), additionally with option to have \"alternative\" tap (usually mapped to \"right click\") when\nuser holds their finger(s) for at least `altDuration` _time units_. `altDuration` of 0 means the \"alternative\" tap\nis disabled. `moveThreshold` is the maximum _distance unit_ the user finger can move before the tap is cancelled.\nCalling this function creates `TapGesture` instance which is derived from `BaseGesture`.\n\nThe definition of _time unit_ depends entirely on the units of delta time passed in `:update` function. If user\ntreat the delta time as milliseconds, then the _time unit_ is in milliseconds.\n\nThe definition of _distance unit_ depends entirely on the user. _Distance units_ may be in virtual resolution\nor in pixels, as long as it is a unit that define distance on screen.\n\n### `void TapGesture:update(number dt)`\n\nUpdate the tap gesture for alternate tap. In LÖVE environment, this function should be called in\n[`love.update`](https://love2d.org/wiki/love.update) with their arguments passed accordingly.\n\nNote that it's okay not to call this function if `altDuration` is set to 0 (where alternate tap events is disabled).\n\n### `void TapGesture:onStart(any context, function func)`\n\nRegister function `func` to be called when a tap is initiated, additionally passing `context` as the 1st parameter.\n\n\"Tap\" is initiated when at least `nfingers` finger(s) are in the bound defined by `constraint`, not moving at all.\n\nThe function signature for `func` must follow this convention:\n\n```\nvoid func(any context)\n```\n\n### `void TapGesture:onCancel(any context, function func)`\n\nRegister function `func` to be called when a tap is cancelled, additionally passing `context` as the 1st parameter.\n\n\"Tap\" is cancelled when the average position of the fingers moves more than `moveThreshold` _distance units_.\n\nThe function signature for `func` must follow this convention:\n\n```\nvoid func(any context, number duration)\n```\n\nWhere `duration` is how long user fingers was on the screen before it was cancelled, in _time units_.\n\n### `void TapGesture:onTap(any context, function func)`\n\nRegister function `func` to be called when a tap is successfully initiated, additionally passing `context` as the\n1st parameter.\n\n\"Tap\" is considered success when the average position of the finger moves less than `moveThreshold` _distance units_\nand then user release one or more of their finger(s).\n\nThe function signature for `func` must follow this convention:\n\n```\nvoid func(any context, boolean alternate, number duration)\n```\n\nWhere `alternate` is `true` if `duration` is longer than or equal to `altDuration` (except where `altDuration` is\n0, `alternate` will always be `false`) and `duration` is how long user fingers was on the screen before the user\nreleases one or more of their finger(s) on the screen, in _time units_.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikuauahdark%2Fkazari","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikuauahdark%2Fkazari","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikuauahdark%2Fkazari/lists"}