Docs update

Some more stuff for docs
This commit is contained in:
Robert Jelic
2022-10-09 14:00:35 +02:00
parent 681d54b406
commit bf1b008084
12 changed files with 189 additions and 1 deletions

View File

@@ -1,4 +1,12 @@
With animations, you can create a beautiful experience for users while interacting with your program.<br>
With animations, you can create a beautiful experience for users while interacting with your program.
There are 2 types of animations, predefined animations and custom animations. By using add and wait you can create custom
animations (calls). Pre-defined methods are for example move, offset, size, changeText,...
:setObject always sets the object on what pre-defined methods should apply on.
When calling a pre-defined animation it will check what is safed as object (:setObject) and will calculate the animation methods based on that which means you won't
be able to change the object on the fly - you will always have to recreate the animation itself
| | |
|---|---|
@@ -6,6 +14,8 @@ With animations, you can create a beautiful experience for users while interacti
|[wait](objects/Animation/wait.md)|Adds a amount to the animation time
|[play](objects/Animation/play.md)|Plays the animation
|[cancel](objects/Animation/cancel.md)|Cancels the animation
|[addMode](objects/Animation/addMode.md)|Adds custom easings
|[setMode](objects/Animation/setMode.md)|Changes the current easing-calculation
|[setObject](objects/Animation/setObject.md)|Sets an object on which predefined animations should work on
|[move](objects/Animation/move.md)|Predefined animation: moves the object to a new position
|[offset](objects/Animation/offset.md)|Predefined animation: Changes the offset of that object
@@ -18,4 +28,5 @@ With animations, you can create a beautiful experience for users while interacti
| | |
|---|---|
|[onStart](objects/Animation/onStart.md)|Gets called as soon as the animation is started
|[onDone](objects/Animation/onDone.md)|Gets called as soon as the animation has finished

View File

@@ -0,0 +1,30 @@
## addMode
Adds a new easing curve into the available easing list. Checkout the animation object if you want to know how this works.
#### Parameters:
1. `string` - The name of the curve you want to use.
2. `functon` - The function to call
#### Returns:
1. `animation` Animation in use
#### Usage:
* Creates a new curve
```lua
local mainFrame = basalt.createFrame()
local testButton = mainFrame:addButton("buttonToAnimate")
local aAnimation = mainFrame:addAnimation():setObject(testButton)
local function easeInBack(t) -- t is the time from 0 to 1
local c1 = 1.70158;
local c3 = c1 + 1
return c3*t^3-c1*t^2
end
aAnimation:addMode("coolEaseInBack", easeInBack)
aAnimation:setMode("coolEaseInBack"):move(15,3,2):play()
```

View File

@@ -0,0 +1,16 @@
## onStart
`onStart(self)`<br>
This is a event which gets fired as soon as the animation is started.
```lua
local basalt = require("Basalt")
local mainFrame = basalt.createFrame()
local testButton = mainFrame:addButton("buttonToAnimate")
local aAnimation = mainFrame:addAnimation():setObject(testButton):changeTextColor({colors.red, colors.yellow, colors.green}, 2)
aAnimation:onStart(function()
basalt.debug("The animation is started")
end)
aAnimation:play()
```

View File

@@ -0,0 +1,36 @@
## setMode
Changes the easing curve. If you want to test them, here is a interesting website: https://easings.co
#### Parameters:
1. `string` - The name of the curve you want to use.
#### Returns:
1. `animation` Animation in use
#### Usage:
* Takes 2 seconds to move the object from its current position to x15 y3
```lua
local mainFrame = basalt.createFrame()
local testButton = mainFrame:addButton("buttonToAnimate")
local aAnimation = mainFrame:addAnimation():setObject(testButton):setMode("easeInBounce"):move(15,3,2):play()
```
## Easing Curve List
Here is a list of all available easing curves:
| | | |
|---|---|---|
|linear||
|easIn|easeOut|easeInOut
|easeInSine|easeOutSine|easeInOutSine
|easeInBack|easeOutBack|easeInOutBack
|easeInCubic|easeOutCubic|easeInOutCubic
|easeInElastic|easeOutElastic|easeInOutElastic
|easeInExpo|easeOutExpo|easeInOutExpo
|easeInBack|easeOutBack|easeInOutBack
|easeInQuad|easeOutQuad|easeInOutQuad
|easeInQuint|easeOutQuint|easeInOutQuint
|easeInQuart|easeOutQuart|easeInOutQuart
|easeInCirc|easeOutCirc|easeInOutCirc
|easeInBounce|easeOutBounce|easeInOutBounce

View File

@@ -27,6 +27,8 @@ You are now able to access the following list of methods:
|[schedule](objects/Basalt/schedule.md)|Schedules a new task
|[setActiveFrame](objects/Basalt/setActiveFrame.md)|Sets the active frame
|[setTheme](objects/Basalt/setTheme.md)|Changes the base theme of basalt
|[setMouseDragThrottle](objects/Basalt/setMouseDragThrottle.md)|Changes the mouse drag throttle amount
|[setMouseMoveThrottle](objects/Basalt/setMouseMoveThrottle.md)|CraftOS-PC: Changes the mouse move throttle amount
|[setVariable](objects/Basalt/setVariable.md)|Sets a variable which you can access via XML
|[stopUpdate / stop](objects/Basalt/stopUpdate.md)|Stops the currently active event and draw listener
|[update](objects/Basalt/update.md)|Starts the event and draw listener once

View File

@@ -0,0 +1,18 @@
# Basalt
## setMouseDragThrottle
Changes the drag throttle of all drag events. Default value is 50ms - which is 0.05s.
Instead of sending all mouse_drag events to the :onDrag handlers basalt sends every 0.05s (while dragging) the most recent drag event to all
drag handlers. If you need all drag events - just change the value to 0.
### Parameters
1. `number` A number in miliseconds.
### Usage
```lua
local basalt = require("basalt")
basalt.setMouseDragThrottle(0)
```

View File

@@ -0,0 +1,20 @@
# Basalt
## setMouseMoveThrottle
This feature is only available for [CraftOS-PC](https://www.craftos-pc.cc).
CraftOS-PC has a builtin mouse_move event, which is disabled by default. By using this method it will also enable the event for you. Remember - basalt does not disable the event after closing the program, which means the event stays active. If you want to disable the event please use config.set("mouse_move_throttle", -1) in your lua prompt or your program.
Sidenote: a very low amount can make the program laggy - because it litterally spams the mouse_move event. So use it carefully.
### Parameters
1. `number` A number in miliseconds.
### Usage
```lua
local basalt = require("basalt")
basalt.setMouseMoveThrottle(50)
```

View File

@@ -40,6 +40,8 @@ This is a list of all available events for all objects:
|[onRelease](objects/Object/onRelease.md)|Fires as soon as the mouse button gets released
|[onScroll](objects/Object/onScroll.md)|Fires as soon as you scroll with the mousewheel
|[onDrag](objects/Object/onDrag.md)|Fires as soon as the object is beeing dragged
|[onHover](objects/Object/onHover.md)|CraftOS-PC - fires when the mouse hovers over a object
|[onLeave](objects/Object/onLeave.md)|CraftOS-PC - fires when the mouse leaves a object
|[onKey](objects/Object/onKey.md)|Fires when the object is focused and a keyboard key has been clicked
|[onChar](objects/Object/onChar.md)|Fires when the object is focused and a character has been clicked
|[onKeyUp](objects/Object/onKeyUp.md)|Fires when the object is focused and a keyboard key has been released

View File

@@ -0,0 +1,21 @@
# onHover
`onHover(self, event, button, x, y)`<br>
The computercraft event which triggers this method is `mouse_move` - only available in [CraftOS-PC](https://www.craftos-pc.cc).
Here is a example on how to add a onHover event to your button:
```lua
local basalt = require("basalt")
local main = basalt.createFrame()
local button = main:addButton()
:setPosition(3,3)
:setSize(12,3)
:setText("Hover")
function buttonOnHover()
basalt.debug("The mouse hovers over the button!")
end
button:onHover(buttonOnHover)
```

View File

@@ -0,0 +1,21 @@
# onLeave
`onLeave(self, event, button, x, y)`<br>
The computercraft event which triggers this method is `mouse_move` - only available in [CraftOS-PC](https://www.craftos-pc.cc).
Here is a example on how to add a onLeave event to your button:
```lua
local basalt = require("basalt")
local main = basalt.createFrame()
local button = main:addButton()
:setPosition(3,3)
:setSize(12,3)
:setText("Leave")
function buttonOnLeave()
basalt.debug("The mouse left the button!")
end
button:onLeave(buttonOnLeave)
```

View File

@@ -12,6 +12,7 @@ Program objects are here for opening other executable programs in your main prog
|[injectEvent](objects/Program/injectEvent.md)|Injects a event into the program
|[injectEvents](objects/Program/injectEvents.md)|Injects a table of events
|[getQueuedEvents](objects/Program/getQueuedEvents.md)|Returns currently queued events
|[setEnviroment](objects/Program/setEnviroment.md)|CHanges the default enviroment to a custom one
# Events

View File

@@ -0,0 +1,10 @@
## setEnviroment
Changes the default enviroment to a custom enviroment
#### Parameters:
1. `table` - Enviroment table
#### Returns:
1. `program` Program in use