Account · Devnet

Track

Cez3iCfq1tHRzCT6yEdQa4mqpeEKzcfDDyDSVJT1xmfJ
Position of this track within its tape.Number#9in tape 52pns...Sw6mN
Bytes stored and the encoding. Inline tracks keep the bytes on-chain.Size484 BInline
The epoch the track became readable.Active epoch301The epoch the tape allocation expires unless extended.Expiry epoch556in 4 days
https://gw.tape.network/track/Cez3iCfq1tHRzCT6yEdQa4mqpeEKzcfDDyDSVJT1xmfJ
HTTP

Ready. Stores src/update.js, 484 B, text/javascript. Download.

Details

Content key
5cTap...S29vt
State
Ready
Type
User
Content-type
text/javascript
Encoding
Inline
Spool group
2
Value hash
9BHoDLpykd11eVBavKcbR6HEv5YisgRoevDGD5QuvB12

Content

00000000  69 6d 70 6f 72 74 20 7b  20 64 65 72 69 76 65 20  |import { derive |
00000010  7d 20 66 72 6f 6d 20 22  2e 2f 73 74 61 74 65 2e  |} from "./state.|
00000020  6a 73 22 3b 0a 0a 65 78  70 6f 72 74 20 66 75 6e  |js";..export fun|
00000030  63 74 69 6f 6e 20 75 70  64 61 74 65 28 73 74 61  |ction update(sta|
00000040  74 65 2c 20 69 6e 70 75  74 29 20 7b 0a 20 20 69  |te, input) {.  i|
00000050  66 20 28 21 73 74 61 74  65 20 7c 7c 20 21 69 6e  |f (!state || !in|
00000060  70 75 74 29 20 72 65 74  75 72 6e 3b 0a 20 20 69  |put) return;.  i|
00000070  66 20 28 69 6e 70 75 74  2e 64 72 61 67 67 69 6e  |f (input.draggin|
00000080  67 20 26 26 20 73 74 61  74 65 2e 70 6f 69 6e 74  |g && state.point|
00000090  65 72 29 20 7b 0a 20 20  20 20 73 74 61 74 65 2e  |er) {.    state.|
000000a0  70 6f 69 6e 74 65 72 2e  78 20 3d 20 4d 61 74 68  |pointer.x = Math|
000000b0  2e 6d 61 78 28 30 2c 20  4d 61 74 68 2e 6d 69 6e  |.max(0, Math.min|
000000c0  28 31 2c 20 4e 75 6d 62  65 72 28 73 74 61 74 65  |(1, Number(state|
000000d0  2e 70 6f 69 6e 74 65 72  2e 78 29 20 7c 7c 20 30  |.pointer.x) || 0|
000000e0  29 29 3b 0a 20 20 20 20  73 74 61 74 65 2e 70 6f  |));.    state.po|
000000f0  69 6e 74 65 72 2e 79 20  3d 20 4d 61 74 68 2e 6d  |inter.y = Math.m|
00000100  61 78 28 30 2c 20 4d 61  74 68 2e 6d 69 6e 28 31  |ax(0, Math.min(1|
00000110  2c 20 4e 75 6d 62 65 72  28 73 74 61 74 65 2e 70  |, Number(state.p|
00000120  6f 69 6e 74 65 72 2e 79  29 20 7c 7c 20 30 29 29  |ointer.y) || 0))|
00000130  3b 0a 20 20 7d 0a 20 20  73 74 61 74 65 2e 62 72  |;.  }.  state.br|
00000140  75 73 68 53 69 7a 65 20  3d 20 4d 61 74 68 2e 6d  |ushSize = Math.m|
00000150  61 78 28 34 2c 20 4d 61  74 68 2e 6d 69 6e 28 32  |ax(4, Math.min(2|
00000160  34 30 2c 20 4e 75 6d 62  65 72 28 73 74 61 74 65  |40, Number(state|
00000170  2e 62 72 75 73 68 53 69  7a 65 29 20 7c 7c 20 36  |.brushSize) || 6|
00000180  30 29 29 3b 0a 20 20 73  74 61 74 65 2e 73 74 72  |0));.  state.str|
00000190  65 6e 67 74 68 20 3d 20  4d 61 74 68 2e 6d 61 78  |ength = Math.max|
000001a0  28 30 2c 20 4d 61 74 68  2e 6d 69 6e 28 31 30 30  |(0, Math.min(100|
000001b0  2c 20 4e 75 6d 62 65 72  28 73 74 61 74 65 2e 73  |, Number(state.s|
000001c0  74 72 65 6e 67 74 68 29  20 7c 7c 20 30 29 29 3b  |trength) || 0));|
000001d0  0a 20 20 64 65 72 69 76  65 28 73 74 61 74 65 29  |.  derive(state)|
000001e0  3b 0a 7d 0a  |;.}.|