Building ports framework
This commit is contained in:
parent
5e311fd29c
commit
1267aa4c84
25
README.md
25
README.md
@ -1,5 +1,6 @@
|
||||
# Ronin
|
||||
Ronin is a simple open-source graphic design tool.
|
||||
|
||||
<img src='https://raw.githubusercontent.com/hundredrabbits/Ronin/master/PREVIEW.jpg' width='600'/>
|
||||
## Modules
|
||||
## brush
|
||||
@ -9,14 +10,11 @@ Ronin is a simple open-source graphic design tool.
|
||||
- `opacity`, default 1
|
||||
### Methods
|
||||
### Ports
|
||||
- `speed`, no details.
|
||||
- `distance`, no details.
|
||||
- `red`, no details.
|
||||
- `green`, no details.
|
||||
- `blue`, no details.
|
||||
- `alpha`, no details.
|
||||
- `x`, no details.
|
||||
- `noise`, no details.
|
||||
- `->speed`{false,true}, **0/50** The cursor speed.
|
||||
- `->distance`{false,true}, **0/null** The cursor distance.
|
||||
- `->red`{true,true}, **0/255** The brush color value(red).
|
||||
- `->green`{true,true}, **0/255** The brush color value(green).
|
||||
- `->blue`{true,true}, **0/255** The brush color value(blue).
|
||||
## eraser
|
||||
### Settings
|
||||
### Methods
|
||||
@ -26,17 +24,16 @@ Ronin is a simple open-source graphic design tool.
|
||||
- `width`, default 930
|
||||
- `height`, default 540
|
||||
### Methods
|
||||
- `resize`, no details.
|
||||
- `rescale`, no details.
|
||||
- `crop`, no details.
|
||||
- `resize:`, no details.
|
||||
- `rescale:`, no details.
|
||||
- `crop:`, no details.
|
||||
### Ports
|
||||
## line
|
||||
### Settings
|
||||
- `steps`, default 100
|
||||
### Methods
|
||||
- `tween`, no details.
|
||||
- `stroke`, no details.
|
||||
- `tween:`, no details.
|
||||
- `stroke:`, no details.
|
||||
### Ports
|
||||
- `index`, no details.
|
||||
## License
|
||||
See the [LICENSE](LICENSE.md) file for license rights and limitations (CC).
|
||||
|
@ -1,5 +0,0 @@
|
||||
frame.resize 795x450
|
||||
source.load /target.jpg x450
|
||||
source:format jpg
|
||||
source:quality 0.9
|
||||
source.save
|
@ -1,45 +0,0 @@
|
||||
frame.resize 800x800
|
||||
type:size 13
|
||||
type:font DIN Medium
|
||||
type:color #ffffff
|
||||
|
||||
~ PART 1
|
||||
layer.fill #b3b3b3
|
||||
source.load /duomic_1.jpg x700 -90,100
|
||||
type.write 400,67 "OPAL INQUISITORS"
|
||||
|
||||
~ PART 2
|
||||
~ layer.fill #a6a6a6
|
||||
~ source.load /duomic_2.jpg x700 -65,100
|
||||
~ type.write 400,67 "PORTALION"
|
||||
|
||||
~ PART 3
|
||||
~ layer.fill #b3b3b3
|
||||
~ source.load /duomic_3.jpg x700 -75,100
|
||||
~ type.write 400,67 "DEI DAIN"
|
||||
|
||||
source.load /nataniev.small.white.svg x40 50,50
|
||||
type.write 250,67 "ALICEFFEKT"
|
||||
type.write 110,67 "DUOMIC"
|
||||
type:font DIN
|
||||
type:size 10
|
||||
|
||||
~ PART 1
|
||||
type.write 250,82 "2015.09"
|
||||
type.write 400,82 "4 TRACKS"
|
||||
type.write 110,83 "PART 1"
|
||||
|
||||
~ PART 2
|
||||
~ type.write 250,82 "2016.10"
|
||||
~ type.write 400,82 "4 TRACKS"
|
||||
~ type.write 110,83 "PART 2"
|
||||
|
||||
~ PART 3
|
||||
~ type.write 250,82 "2013.06"
|
||||
~ type.write 400,82 "10 TRACKS"
|
||||
~ type.write 110,83 "PART 3"
|
||||
|
||||
~ Save
|
||||
source:format jpg
|
||||
source:quality 1
|
||||
source.save
|
@ -1,56 +0,0 @@
|
||||
frame.resize 800x800
|
||||
type:size 13
|
||||
type:font DIN Medium
|
||||
type:color #000
|
||||
layer.fill #A1A1A1
|
||||
|
||||
~ PART 1
|
||||
type.write 400,67 "SUPERVISITOR"
|
||||
|
||||
~ PART 2
|
||||
~ type.write 400,67 "SUPERWORKER"
|
||||
|
||||
source.load /nataniev.small.black.svg x40 50,50
|
||||
type.write 250,67 "ALICEFFEKT"
|
||||
type.write 110,67 "DEMO"
|
||||
type:font DIN
|
||||
type:size 10
|
||||
|
||||
~ PART 1
|
||||
type.write 250,82 "2012.04"
|
||||
type.write 400,82 "4 TRACKS"
|
||||
type.write 110,83 "MICROBRUTE"
|
||||
path:line_color black ;
|
||||
path:line_width 20 ;
|
||||
path:line_cap square ;
|
||||
path.stroke M240,400 l60,0 a20,20 0 0,1 20,20 a-20,20 0 0,1 -20,20 l-60,0 M300,440 a20,20 0 0,1 20,20 l0,20 M240,400 l0,80 ;
|
||||
path.stroke M360,400 l0,60 a20,20 0 0,0 20,20 l40,0 a20,-20 0 0,0 20,-20 l0,-60 M440,460 l0,20 ;
|
||||
path.stroke M480,400 l80,0 M520,400 l0,80 ;
|
||||
path.stroke M120,400 l60,0 a20,20 0 0,1 20,20 a-20,20 0 0,1 -20,20 l-60,0 M180,440 a20,20 0 0,1 20,20 a-20,20 0 0,1 -20,20 l-60,0 ;
|
||||
path:line_color #A1A1A1 ;
|
||||
path:line_cap round ;
|
||||
path:line_width 1 ;
|
||||
path.stroke M110,400 l70,0 a20,20 0 0,1 20,20 a-20,20 0 0,1 -20,20 l-70,0 M180,440 a20,20 0 0,1 20,20 a-20,20 0 0,1 -20,20 l-70,0 M240,490 l0,-90 l60,0 a20,20 0 0,1 20,20 a-20,20 0 0,1 -20,20 l-60,0 M300,440 a20,20 0 0,1 20,20 l0,30 M360,390 l0,70 a20,20 0 0,0 20,20 l40,0 a20,-20 0 0,0 20,-20 l0,-70 l0,100 M470,400 l100,0 M520,400 l0,90 ;
|
||||
type:size 20
|
||||
type.write 110,550 "ARTURIA'S MICROBRUTE"
|
||||
|
||||
~ PART 2
|
||||
~ type.write 250,82 "2017.04"
|
||||
~ type.write 400,82 "3 TRACKS"
|
||||
~ type.write 110,83 "オフィス"
|
||||
~ magnet.grid 20x20 4,4
|
||||
~ path:line_color black
|
||||
~ path:line_width 20
|
||||
~ path:line_cap butt
|
||||
~ path.stroke M280,400 a40,40 0 0,1 40,40 a-40,40 0 0,1 -40,40 l0,0 a-40,-40 0 0,1 -40,-40 a40,-40 0 0,1 40,-40 M120,490 l0,-90 l60,0 a20,20 0 0,1 20,20 a-20,20 0 0,1 -20,20 l-60,0 M350,400 l70,0 a20,20 0 0,1 20,20 a-20,20 0 0,1 -20,20 l-40,0 a-20,20 0 0,0 -20,20 l0,20 l90,0 M480,390 l0,30 a20,20 0 0,0 20,20 l60,0 M560,390 l0,100 ;
|
||||
~ path:line_color #A1A1A1
|
||||
~ path:line_cap round
|
||||
~ path:line_width 1
|
||||
~ path.stroke M280,400 a40,40 0 0,1 40,40 a-40,40 0 0,1 -40,40 l0,0 a-40,-40 0 0,1 -40,-40 a40,-40 0 0,1 40,-40 M120,490 l0,-90 l60,0 a20,20 0 0,1 20,20 a-20,20 0 0,1 -20,20 l-60,0 M350,400 l70,0 a20,20 0 0,1 20,20 a-20,20 0 0,1 -20,20 l-40,0 a-20,20 0 0,0 -20,20 l0,20 l90,0 M480,390 l0,30 a20,20 0 0,0 20,20 l60,0 M560,390 l0,100 ;
|
||||
~ type:size 20
|
||||
~ type.write 110,550 "TEENAGE ENGINEERING'S POCKET OPERATOR 24"
|
||||
|
||||
~ Save
|
||||
source:format jpg
|
||||
source:quality 1
|
||||
source.save
|
@ -1,45 +0,0 @@
|
||||
frame.resize 800x800
|
||||
type:size 13
|
||||
type:font DIN Medium
|
||||
type:color #ffffff
|
||||
|
||||
~ PART 1
|
||||
~ layer.fill #b3b3b3
|
||||
~ source.load /duomic_1.jpg x700 -90,100
|
||||
~ type.write 400,67 "OPAL INQUISITORS"
|
||||
|
||||
~ PART 2
|
||||
~ layer.fill #a6a6a6
|
||||
~ source.load /duomic_2.jpg x700 -65,100
|
||||
~ type.write 400,67 "PORTALION"
|
||||
|
||||
~ PART 3
|
||||
layer.fill #b3b3b3
|
||||
source.load /duomic_3.jpg x700 -75,100
|
||||
type.write 400,67 "DEI DAIN"
|
||||
|
||||
source.load /nataniev.small.white.svg x40 50,50
|
||||
type.write 250,67 "ALICEFFEKT"
|
||||
type.write 110,67 "DUOMIC"
|
||||
type:font DIN
|
||||
type:size 10
|
||||
|
||||
~ PART 1
|
||||
~ type.write 250,82 "2015.09"
|
||||
~ type.write 400,82 "4 TRACKS"
|
||||
~ type.write 110,83 "PART 1"
|
||||
|
||||
~ PART 2
|
||||
~ type.write 250,82 "2016.10"
|
||||
~ type.write 400,82 "4 TRACKS"
|
||||
~ type.write 110,83 "PART 2"
|
||||
|
||||
~ PART 3
|
||||
type.write 250,82 "2013.06"
|
||||
type.write 400,82 "10 TRACKS"
|
||||
type.write 110,83 "PART 3"
|
||||
|
||||
~ Save
|
||||
source:format jpg
|
||||
source:quality 1
|
||||
source.save
|
@ -1,43 +0,0 @@
|
||||
frame.resize 800x800
|
||||
type:size 13
|
||||
type:font DIN Medium
|
||||
type:color #fff
|
||||
layer.fill #1a1a1a
|
||||
|
||||
~ PART 1
|
||||
~ source.load /soundtrack_oquonie.jpg x800 -235,0
|
||||
~ type.write 400,67 "IMPOSSIBLE SPACES"
|
||||
|
||||
~ PART 2
|
||||
~ source.load /soundtrack_rabbits.jpg x800 0,0
|
||||
~ type.write 400,67 "RABBITS"
|
||||
|
||||
~ PART 3
|
||||
source.load /extra_4.jpg x800 0,20
|
||||
type.write 400,67 "DAMOISEAU CANALX"
|
||||
|
||||
source.load /nataniev.small.white.svg x40 50,50
|
||||
type.write 250,67 "ALICEFFEKT"
|
||||
type.write 110,67 "EXTRA"
|
||||
type:font DIN
|
||||
type:size 10
|
||||
|
||||
~ PART 1
|
||||
~ type.write 250,82 "2014.02"
|
||||
~ type.write 400,82 "18 TRACKS"
|
||||
~ type.write 110,83 "OQUONIE"
|
||||
|
||||
~ PART 2
|
||||
~ type.write 250,82 "2014.03"
|
||||
~ type.write 400,82 "OPEN"
|
||||
~ type.write 110,83 "HUNDRED RABBITS"
|
||||
|
||||
~ PART 3
|
||||
type.write 250,82 "2014.08"
|
||||
type.write 400,82 "4 TRACKS"
|
||||
type.write 110,83 "PART 4"
|
||||
|
||||
~ Save
|
||||
source:format jpg
|
||||
source:quality 1
|
||||
source.save
|
@ -1,42 +0,0 @@
|
||||
frame.resize 800x800
|
||||
type:size 13
|
||||
type:font DIN Medium
|
||||
type:color #000
|
||||
|
||||
~ PART 1
|
||||
~ source.load /laeisth_1.jpg x800 -250,0
|
||||
~ type.write 400,67 "CHILDREN OF BRAMBLE"
|
||||
|
||||
~ PART 2
|
||||
source.load /laeisth_2.jpg x800 -250,0
|
||||
type.write 400,67 "KNOWN MAGYE"
|
||||
|
||||
~ PART 3
|
||||
~ source.load /laeisth_3.jpg x800 -250,0
|
||||
~ type.write 400,67 "EXTENDED SLEEP"
|
||||
|
||||
source.load /nataniev.small.black.svg x40 50,50
|
||||
type.write 250,67 "ALICEFFEKT"
|
||||
type.write 110,67 "LAEISTHIC"
|
||||
type:font DIN
|
||||
type:size 10
|
||||
|
||||
~ PART 1
|
||||
~ type.write 250,82 "2012.04"
|
||||
~ type.write 400,82 "4 TRACKS"
|
||||
~ type.write 110,83 "PART 1"
|
||||
|
||||
~ PART 2
|
||||
type.write 250,82 "2014.03"
|
||||
type.write 400,82 "6 TRACKS"
|
||||
type.write 110,83 "PART 2"
|
||||
|
||||
~ PART 3
|
||||
~ type.write 250,82 "2015.05"
|
||||
~ type.write 400,82 "4 TRACKS"
|
||||
~ type.write 110,83 "PART 3"
|
||||
|
||||
~ Save
|
||||
source:format jpg
|
||||
source:quality 1
|
||||
source.save
|
@ -1,25 +0,0 @@
|
||||
frame.resize 800x800
|
||||
type:size 13
|
||||
type:font DIN Medium
|
||||
type:color #ffffff
|
||||
|
||||
~ PART 1
|
||||
layer.fill #72dec2
|
||||
source.load /malice_1.jpg x800 -90,0
|
||||
type.write 400,67 "COLLECTED WORKS"
|
||||
|
||||
source.load /nataniev.small.white.svg x40 50,50
|
||||
type.write 250,67 "害意"
|
||||
type.write 110,67 "MALICE"
|
||||
type:font DIN
|
||||
type:size 10
|
||||
|
||||
~ PART 1
|
||||
type.write 250,82 "2016.07"
|
||||
type.write 400,82 "4 TRACKS"
|
||||
type.write 110,83 "2008-2015"
|
||||
|
||||
~ Save
|
||||
source:format jpg
|
||||
source:quality 1
|
||||
source.save
|
@ -1,42 +0,0 @@
|
||||
frame.resize 800x800
|
||||
type:size 13
|
||||
type:font DIN Medium
|
||||
type:color #000
|
||||
|
||||
~ PART 1
|
||||
~ source.load /soundtrack_oquonie.jpg x800 -235,0
|
||||
~ type.write 400,67 "IMPOSSIBLE SPACES"
|
||||
|
||||
~ PART 2
|
||||
~ source.load /soundtrack_rabbits.jpg x800 0,0
|
||||
~ type.write 400,67 "RABBITS"
|
||||
|
||||
~ PART 3
|
||||
source.load /soundtrack_purgateus.jpg x800 0,0
|
||||
type.write 400,67 "WHERE UNDERWATER IS"
|
||||
|
||||
source.load /nataniev.small.black.svg x40 50,50
|
||||
type.write 250,67 "ALICEFFEKT"
|
||||
type.write 110,67 "SOUNDTRACK"
|
||||
type:font DIN
|
||||
type:size 10
|
||||
|
||||
~ PART 1
|
||||
~ type.write 250,82 "2014.02"
|
||||
~ type.write 400,82 "18 TRACKS"
|
||||
~ type.write 110,83 "OQUONIE"
|
||||
|
||||
~ PART 2
|
||||
~ type.write 250,82 "2014.03"
|
||||
~ type.write 400,82 "OPEN"
|
||||
~ type.write 110,83 "HUNDRED RABBITS"
|
||||
|
||||
~ PART 3
|
||||
type.write 250,82 "2014.05"
|
||||
type.write 400,82 "6 TRACKS"
|
||||
type.write 110,83 "PURGATEUS"
|
||||
|
||||
~ Save
|
||||
source:format jpg
|
||||
source:quality 1
|
||||
source.save
|
@ -1,7 +0,0 @@
|
||||
frame.resize 500x500
|
||||
layer.fill #eeeeee
|
||||
brush:color #000000
|
||||
brush:size 3
|
||||
frame.select main
|
||||
brush.add 1,1
|
||||
brush.add -1,-1
|
@ -1,21 +0,0 @@
|
||||
frame.resize 300x300
|
||||
layer.fill #000000
|
||||
path:line_width 28
|
||||
path:line_cap butt
|
||||
magnet:color #999
|
||||
magnet.grid 15x15 4,4
|
||||
frame.select logo~
|
||||
brush:color #72dec2
|
||||
path:line_cap round
|
||||
path.stroke M150,240 l0,-30 a60,-60 0 0,1 60,-60 l30,0 l0,30 l-30,0 a-30,30 0 0,0 -30,30 l0,30 l30,0 l0,-30
|
||||
path.stroke M150,60 l0,30 a-60,60 0 0,1 -60,60 l-30,0 l0,-30 l30,0 a30,-30 0 0,0 30,-30 l0,-30 l-30,0 l0,30
|
||||
path.stroke M120,240 l0,-30 a-30,-30 0 0,0 -30,-30 l-30,0 l0,30 l30,0
|
||||
path.stroke M180,60 l0,30 a30,30 0 0,0 30,30 l30,0 l0,-30 l-30,0
|
||||
path:line_cap square
|
||||
path.stroke M150,75 l0,-15 M180,75 l0,-15 M150,225 l0,15 M120,225 l0,15
|
||||
path:line_cap round
|
||||
path.stroke M90,210 l0,30 M210,210 l30,0 M210,90 l0,-30 M90,90 l-30,0
|
||||
path.stroke M90,240 l-30,0 M60,90 l0,-30 M210,60 l30,0 M240,210 l0,30
|
||||
path:line_cap square
|
||||
path.stroke M240,225 l0,15 M75,240 l-15,0 M60,75 l0,-15 M225,60 l15,0
|
||||
magnet.clear
|
@ -1,13 +0,0 @@
|
||||
frame.resize 300x300
|
||||
frame.select background
|
||||
~ layer.fill #f1f1f1
|
||||
frame.select main
|
||||
frame.select logo
|
||||
path:line_width 30
|
||||
path:line_color #000
|
||||
path.stroke M60,60 l120,0 a60,60 0 0,1 60,60 a-60,60 0 0,1 -60,60 l-120,0 M180,180 a60,60 0 0,1 60,60
|
||||
magnet.grid 15x15 4,4
|
||||
magnet.clear
|
||||
brush:color #72dec2
|
||||
brush:size 10
|
||||
source.save
|
@ -1,23 +0,0 @@
|
||||
frame.resize 420x420 ;
|
||||
brush:color #ff0000 ;
|
||||
magnet.grid 15x15 4,4 ;
|
||||
frame.select main ;
|
||||
path:line_width 30 ;
|
||||
path:line_color #ffffff ;
|
||||
path.stroke M240,180 l0,-90 a30,-30 0 0,1 30,-30 a30,30 0 0,1 30,30 a-30,30 0 0,1 -30,30 l-180,0 a-30,-30 0 0,1 -30,-30 a30,-30 0 0,1 30,-30 a30,30 0 0,1 30,30 l0,180 a-30,30 0 0,1 -30,30 a-30,-30 0 0,1 -30,-30 a30,-30 0 0,1 30,-30 l180,0 a30,30 0 0,1 30,30 a-30,30 0 0,1 -30,30 a-30,-30 0 0,1 -30,-30 l0,-90 ;
|
||||
path:line_width 1 ;
|
||||
path:line_color #000000 ;
|
||||
path.stroke M240,180 l0,-90 a30,-30 0 0,1 30,-30 a30,30 0 0,1 30,30 a-30,30 0 0,1 -30,30 l-180,0 a-30,-30 0 0,1 -30,-30 a30,-30 0 0,1 30,-30 a30,30 0 0,1 30,30 l0,180 a-30,30 0 0,1 -30,30 a-30,-30 0 0,1 -30,-30 a30,-30 0 0,1 30,-30 l180,0 a30,30 0 0,1 30,30 a-30,30 0 0,1 -30,30 a-30,-30 0 0,1 -30,-30 l0,-90 ;
|
||||
path:line_color #ffffff ;
|
||||
path:line_width 4 ;
|
||||
path:line_cap butt ;
|
||||
path.stroke M105,120 l30,0 M240,105 l0,30 M225,240 l30,0 M120,225 l0,30 ;
|
||||
path:line_width 1 ;
|
||||
path:line_color #000000 ;
|
||||
path.stroke M120,105 l0,30 M225,120 l30,0 M240,225 l0,30 M135,240 l-30,0 ;
|
||||
path:line_width 10 ;
|
||||
path:line_color #cccccc ;
|
||||
path.stroke M100,105 l0,30 M140,105 l0,30 M260,225 l0,30 M220,225 l0,30 M225,100 l30,0 M225,140 l30,0 M105,220 l30,0 M105,260 l30,0;
|
||||
magnet.grid 1x1 ;
|
||||
layer.rotate 180,180 45' ;
|
||||
layer.translate 30,30 ;
|
@ -1,10 +0,0 @@
|
||||
frame.resize 300x300
|
||||
layer.fill #111111
|
||||
magnet.grid 15x15 4,4
|
||||
path:line_color #ffffff
|
||||
path:line_width 10
|
||||
path.stroke M60,60 A1,1 0 0,0 240,60 A1,1 0 0,0 240,240
|
||||
path.stroke M240,240 A1,1 0 0,0 60,240 A1,1 0 0,0 60,60
|
||||
magnet.grid 1x1
|
||||
brush.add_pointer #ff0000 1
|
||||
source.save
|
@ -1,15 +0,0 @@
|
||||
frame.resize 300x300
|
||||
~ layer.fill #A1A1A1
|
||||
brush:color #ff0000
|
||||
path:line_width 28
|
||||
path:line_color #000
|
||||
path:line_cap butt
|
||||
magnet.grid 15x15 4,4
|
||||
frame.select work
|
||||
~ OQUONIE
|
||||
~ path.stroke M45,60 l210,0 M45,240 l210,0 M255,60 a-15,15 0 0,0 -15,15 a-15,-15 0 0,0 -15,-15 M75,60 a-15,15 0 0,0 -15,15 a-15,-15 0 0,0 -15,-15 M255,240 a-15,-15 0 0,1 -15,-15 a-15,15 0 0,1 -15,15 M75,240 a-15,-15 0 0,1 -15,-15 a-15,15 0 0,1 -15,15 M60,75 l0,150 M240,75 l0,150 M60,150 l180,0
|
||||
~ THOUSAND ROOMS
|
||||
~ path.stroke M45,60 l210,0 M45,240 l210,0 M255,60 a-15,15 0 0,0 -15,15 a-15,-15 0 0,0 -15,-15 M75,60 a-15,15 0 0,0 -15,15 a-15,-15 0 0,0 -15,-15 M255,240 a-15,-15 0 0,1 -15,-15 a-15,15 0 0,1 -15,15 M75,240 a-15,-15 0 0,1 -15,-15 a-15,15 0 0,1 -15,15 M240,75 l0,150 M60,75 l0,150 M180,60 l0,180 M60,180 l180,0 M195,60 a-15,15 0 0,0 -15,15 a-15,-15 0 0,0 -15,-15 M165,240 a15,-15 0 0,0 15,-15 a15,15 0 0,0 15,15
|
||||
~ DONSOL
|
||||
~ path.stroke M150,60 l-90,90 l90,90 l90,-90 l-90,-90
|
||||
source.save
|
@ -1,6 +0,0 @@
|
||||
frame.resize 360x360
|
||||
frame.select background
|
||||
layer.fill #A1A1A1
|
||||
brush:color #ff0000
|
||||
magnet.grid 15x15 4,4
|
||||
frame.select main
|
@ -1,10 +0,0 @@
|
||||
frame.resize 315x250
|
||||
layer.fill #111
|
||||
magnet:color #999
|
||||
magnet.grid 15x15 3,4
|
||||
path:line_color #ffffff
|
||||
path:line_width 5
|
||||
path:line_cap square
|
||||
path:fill_color #fff
|
||||
source.load /badge.donsol.png 82.5,45 150x
|
||||
source.save
|
@ -1,16 +0,0 @@
|
||||
~ TRY 1
|
||||
frame.resize 420x330
|
||||
layer.fill #EEE
|
||||
brush:color #ff0000
|
||||
path:line_color #222
|
||||
magnet.grid 15x15 4,4
|
||||
frame.select work
|
||||
path:line_cap butt
|
||||
path:line_width 60
|
||||
path.stroke M60,60 a30,30 0 0,1 30,30 l0,120 a30,30 0 0,0 30,30 a30,-30 0 0,0 30,-30 l0,-120 a30,-30 0 0,1 30,-30 a30,30 0 0,1 30,30 l0,120 a30,30 0 0,0 30,30 a30,-30 0 0,0 30,-30 l0,-120 a30,-30 0 0,1 30,-30
|
||||
path:line_cap butt
|
||||
path:line_width 1
|
||||
path:line_color #EEE
|
||||
path.stroke M90,60 a30,30 0 0,1 30,30 l0,120 a30,30 0 0,0 30,30 a30,-30 0 0,0 30,-30 l0,-120 a30,-30 0 0,1 30,-30 a30,30 0 0,1 30,30 l0,120 a30,30 0 0,0 30,30 a30,-30 0 0,0 30,-30 l0,-120 a30,-30 0 0,1 30,-30
|
||||
path.stroke M90,60 a-30,30 0 0,0 -30,30
|
||||
magnet.clear
|
@ -1,8 +0,0 @@
|
||||
frame.resize 300x300
|
||||
layer.fill #ff0000
|
||||
path:line_width 28
|
||||
path:line_cap round
|
||||
magnet.grid 30x30 2,2
|
||||
frame.select logo
|
||||
path.stroke M60,60 l60,0 a60,60 0 0,1 60,60 M240,60 l0,60 a-60,60 0 0,1 -60,60 M240,240 l-60,0 a-60,-60 0 0,1 -60,-60 M60,240 l0,-60 a60,-60 0 0,1 60,-60 M60,90 l60,0 a30,30 0 0,1 30,30 M210,60 l0,60 a-30,30 0 0,1 -30,30 M240,210 l-60,0 a-30,-30 0 0,1 -30,-30 M90,240 l0,-60 a30,-30 0 0,1 30,-30
|
||||
magnet.grid 1x1 2,2
|
@ -1,12 +0,0 @@
|
||||
frame.resize 300x300
|
||||
layer.fill #ff0000
|
||||
path:line_width 28
|
||||
path:line_cap butt
|
||||
magnet.grid 15x15 4,4
|
||||
frame.select logo
|
||||
path.stroke M60,60 l60,0 a60,60 0 0,1 60,60 M240,60 l0,60 a-60,60 0 0,1 -60,60 M240,240 l-60,0 a-60,-60 0 0,1 -60,-60 M60,240 l0,-60 a60,-60 0 0,1 60,-60 M90,240 l0,-60 a30,-30 0 0,1 30,-30 M60,90 l60,0 a30,30 0 0,1 30,30 M210,60 l0,60 a-30,30 0 0,1 -30,30 M240,210 l-60,0 a-30,-30 0 0,1 -30,-30
|
||||
path.stroke M45,60 l15,0 M45,90 l15,0 M210,45 l0,15 M240,45 l0,15 M255,210 l-15,0 M255,240 l-15,0 M90,255 l0,-15 M60,255 l0,-15
|
||||
path:line_cap round
|
||||
path.stroke M120,60 a60,60 0 0,1 60,60 M240,120 a-60,60 0 0,1 -60,60 M180,240 a-60,-60 0 0,1 -60,-60 M60,180 a60,-60 0 0,1 60,-60
|
||||
path.stroke M120,90 a30,30 0 0,1 30,30 M210,120 a-30,30 0 0,1 -30,30 M180,210 a-30,-30 0 0,1 -30,-30 M90,180 a30,-30 0 0,1 30,-30
|
||||
magnet.grid 1x1 4,4
|
@ -1,12 +0,0 @@
|
||||
frame.resize 300x300
|
||||
frame.select background
|
||||
layer.fill #f1f1f1
|
||||
frame.select main
|
||||
frame.select logo
|
||||
path:line_width 30
|
||||
path:line_color #000
|
||||
~ path.stroke M60,60 l120,0 a60,60 0 0,1 60,60 a-60,60 0 0,1 -60,60 l-120,0 M180,180 a60,60 0 0,1 60,60
|
||||
magnet.grid 15x15 4,4
|
||||
~ magnet.grid 1x1 4,4
|
||||
brush:color #72dec2
|
||||
brush:size 10
|
@ -1,12 +0,0 @@
|
||||
frame.resize 300x300
|
||||
layer.fill #000
|
||||
path:line_width 28
|
||||
path:line_cap square
|
||||
magnet.grid 30x30 2,2
|
||||
frame.select logo
|
||||
path.stroke M120,60 a0,90 0 0,0 0,90 a30,30 0 0,0 30,30 M90,60 l0,90 a60,60 0 0,0 60,60 M60,60 l0,90 a90,90 0 0,0 90,90 M180,240 l0,-90 a-30,-30 0 0,0 -30,-30 M210,240 l0,-90 a-60,-60 0 0,0 -60,-60 M240,240 l0,-90 a-90,-90 0 0,0 -90,-90
|
||||
magnet.grid 1x1 2,2
|
||||
type:size 30
|
||||
type:color white
|
||||
type.write "∴" 45,255
|
||||
source.save
|
@ -1,7 +0,0 @@
|
||||
frame.resize 795x450
|
||||
frame.select "photo"
|
||||
frame.select "logo"
|
||||
source.load /hundred.rabbits.logo.white.svg 70x70 0,380
|
||||
frame.select "photo"
|
||||
source:format jpg
|
||||
source:quality 0.9
|
@ -1,22 +0,0 @@
|
||||
frame.resize 500x500
|
||||
brush:color #000000
|
||||
|
||||
~ Radial 45'
|
||||
~ brush.add 250,250 45'
|
||||
~ brush.add 250,250 90'
|
||||
~ brush.add 250,250 135'
|
||||
~ brush.add 250,250 180'
|
||||
~ brush.add 250,250 225'
|
||||
~ brush.add 250,250 270'
|
||||
~ brush.add 250,250 315'
|
||||
|
||||
~ Radial 72'
|
||||
brush.add 250,250 72'
|
||||
brush.add 250,250 144'
|
||||
brush.add 250,250 216'
|
||||
brush.add 250,250 288'
|
||||
|
||||
~ Radial 90'
|
||||
~ brush.add 250,250 90'
|
||||
~ brush.add 250,250 180'
|
||||
~ brush.add 250,250 270'
|
@ -1,14 +0,0 @@
|
||||
frame.resize 640x400
|
||||
layer.fill #000000
|
||||
path:line_width 28
|
||||
path:line_cap butt
|
||||
magnet.grid 15x15 4,4
|
||||
frame.select logo
|
||||
path.stroke M60,60 l60,0 a60,60 0 0,1 60,60 M240,60 l0,60 a-60,60 0 0,1 -60,60 M240,240 l-60,0 a-60,-60 0 0,1 -60,-60 M60,240 l0,-60 a60,-60 0 0,1 60,-60 M90,240 l0,-60 a30,-30 0 0,1 30,-30 M60,90 l60,0 a30,30 0 0,1 30,30 M210,60 l0,60 a-30,30 0 0,1 -30,30 M240,210 l-60,0 a-30,-30 0 0,1 -30,-30
|
||||
path.stroke M45,60 l15,0 M45,90 l15,0 M210,45 l0,15 M240,45 l0,15 M255,210 l-15,0 M255,240 l-15,0 M90,255 l0,-15 M60,255 l0,-15
|
||||
path:line_cap round
|
||||
path.stroke M120,60 a60,60 0 0,1 60,60 M240,120 a-60,60 0 0,1 -60,60 M180,240 a-60,-60 0 0,1 -60,-60 M60,180 a60,-60 0 0,1 60,-60
|
||||
path.stroke M120,90 a30,30 0 0,1 30,30 M210,120 a-30,30 0 0,1 -30,30 M180,210 a-30,-30 0 0,1 -30,-30 M90,180 a30,-30 0 0,1 30,-30
|
||||
magnet.grid 1x1 4,4
|
||||
layer.translate 170,40
|
||||
source.save
|
@ -1,4 +0,0 @@
|
||||
frame.resize 240x360
|
||||
layer.fill #A1A1A1
|
||||
magnet.grid 15x15 4,4
|
||||
path:line_color #ffffff
|
@ -1,13 +0,0 @@
|
||||
frame.resize 800x400
|
||||
frame.select background
|
||||
layer.fill #fff
|
||||
frame.select drawing
|
||||
brush:color #000000
|
||||
brush:size 3
|
||||
brush.clear
|
||||
brush.add 0,0
|
||||
brush.add 1,1
|
||||
brush.add -1,-1
|
||||
brush.add 0,0 mirror_x=400
|
||||
brush.add 1,1 mirror_x=400
|
||||
brush.add -1,-1 mirror_x=400
|
@ -1,149 +0,0 @@
|
||||
function Command(content)
|
||||
{
|
||||
this.content = content;
|
||||
this.parts = content.split(" ");
|
||||
|
||||
this.module_name = null;
|
||||
this.method_name = null;
|
||||
this.setting_name = null;
|
||||
this.module = null;
|
||||
this.setthing = null;
|
||||
|
||||
this.module = function()
|
||||
{
|
||||
var module_name = null;
|
||||
|
||||
if(this.parts[0].indexOf(".") > -1){
|
||||
module_name = this.parts[0].split(" ")[0].split(".")[0]
|
||||
}
|
||||
else if(this.parts[0].indexOf(":") > -1){
|
||||
module_name = this.parts[0].split(" ")[0].split(":")[0]
|
||||
}
|
||||
else{
|
||||
module_name = this.parts[0].split(" ")[0];
|
||||
}
|
||||
return ronin.modules[module_name] ? ronin.modules[module_name] : null;
|
||||
}
|
||||
|
||||
this.method = function()
|
||||
{
|
||||
var module = this.module();
|
||||
if(!module || content.indexOf(".") < 0){ return null; }
|
||||
|
||||
var method_name = content.indexOf(".") > -1 ? content.split(" ")[0].split(".")[1] : "default";
|
||||
return module.methods[method_name] ? module.methods[method_name] : null;
|
||||
}
|
||||
|
||||
this.setting = function()
|
||||
{
|
||||
var content = this.content;
|
||||
var module = this.module();
|
||||
|
||||
if(!module){ return null; }
|
||||
if(content.indexOf(":") < 0){ return null; }
|
||||
|
||||
var setting_name = this.parts[0].split(":")[1];
|
||||
return module.settings[setting_name] ? setting_name : null;
|
||||
}
|
||||
|
||||
this.values = function()
|
||||
{
|
||||
var a = this.content.split(" ");
|
||||
a.shift();
|
||||
return a.join(" ").trim();
|
||||
}
|
||||
|
||||
|
||||
this.inject_position = function(injection)
|
||||
{
|
||||
console.log("> "+injection);
|
||||
console.log("- "+content);
|
||||
}
|
||||
|
||||
// Parser
|
||||
|
||||
this.any = function()
|
||||
{
|
||||
return new Any(this.content);
|
||||
}
|
||||
|
||||
this.rect = function()
|
||||
{
|
||||
for (i = 0; i < this.parts.length; i++) {
|
||||
if(this.parts[i].indexOf("x") >= 0 && this.parts[i].indexOf("/") < 0){ return new Rect(this.parts[i]); }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
this.position = function()
|
||||
{
|
||||
for (i = 0; i < this.parts.length; i++) {
|
||||
if(this.parts[i].indexOf(",") >= 0){ return new Position(this.parts[i]); }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
this.color = function()
|
||||
{
|
||||
for (i = 0; i < this.parts.length; i++) {
|
||||
if(this.parts[i].indexOf("#") >= 0){ return new Color(this.parts[i]); }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
this.filepath = function()
|
||||
{
|
||||
for (i = 0; i < this.parts.length; i++) {
|
||||
if(this.parts[i].indexOf("/") >= 0){ return new Filepath(this.parts[i]); }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
this.value = function()
|
||||
{
|
||||
for (i = 0; i < this.parts.length; i++) {
|
||||
var test = /[^$\-\d]/.test(this.parts[i]);
|
||||
if(!test && this.parts[i] !== ""){ return new Value(this.parts[i]); }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
this.range = function()
|
||||
{
|
||||
for (i = 0; i < this.parts.length; i++) {
|
||||
if(this.parts[i].indexOf("..") >= 0){ return new Range(this.parts[i]); }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
this.option = function(name)
|
||||
{
|
||||
for (i = 0; i < this.parts.length; i++) {
|
||||
if(this.parts[i].indexOf(name+"=") >= 0){ return new Option(this.parts[i]); }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
this.bang = function()
|
||||
{
|
||||
for (i = 0; i < this.parts.length; i++) {
|
||||
if(this.parts[i].indexOf("!") >= 0){ return new Bang(); }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
this.angle = function()
|
||||
{
|
||||
for (i = 0; i < this.parts.length; i++) {
|
||||
if(this.parts[i].indexOf("'") >= 0){ return new Angle(this.parts[i]); }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
this.text = function()
|
||||
{
|
||||
var content_str = this.parts.join(" ");
|
||||
if(content_str.indexOf("\"") < 0){ return null; }
|
||||
return content_str.split("\"")[1];
|
||||
}
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
function Keyboard()
|
||||
{
|
||||
this.shift_held = false;
|
||||
this.alt_held = false;
|
||||
|
||||
this.listen_onkeydown = function(event)
|
||||
{
|
||||
if(event.shiftKey == true){
|
||||
this.shift_held = true;
|
||||
}
|
||||
if(event.altKey == true){
|
||||
this.alt_held = true;
|
||||
}
|
||||
|
||||
// Autocomplete with tab
|
||||
if(event.keyCode === 9){
|
||||
event.preventDefault();
|
||||
var ac = ronin.terminal.find_autocomplete();
|
||||
if(ac){
|
||||
ronin.terminal.input.value += ac;
|
||||
}
|
||||
}
|
||||
|
||||
ronin.cursor.update(event);
|
||||
ronin.widget.update();
|
||||
ronin.terminal.update();
|
||||
}
|
||||
|
||||
this.listen_onkeyup = function(event)
|
||||
{
|
||||
this.shift_held = false;
|
||||
this.alt_held = false;
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
switch (event.key || event.keyCode || event.which) {
|
||||
case "Enter": this.key_enter(); break;
|
||||
case "ArrowUp": this.key_arrow_up(); break;
|
||||
case "ArrowDown": this.key_arrow_down(); break;
|
||||
case "ArrowLeft": this.key_arrow_left(); break;
|
||||
case "ArrowRight": this.key_arrow_right(); break;
|
||||
case "]": ronin.brush.size_up(); break;
|
||||
case "[": ronin.brush.size_down(); break;
|
||||
case ":": this.key_colon(); break;
|
||||
case "Escape": this.key_escape(); break;
|
||||
case 13: this.key_enter(); break;
|
||||
case 186: if(event.shiftKey){this.key_colon();} break;
|
||||
case 27: this.key_escape(); break;
|
||||
case 219: ronin.brush.size_up(); break;
|
||||
case 221: ronin.brush.size_down(); break;
|
||||
case 38: this.key_arrow_up(); break;
|
||||
case 40: this.key_arrow_down(); break;
|
||||
case 8: this.key_delete(); break;
|
||||
}
|
||||
|
||||
console.log(event)
|
||||
|
||||
// Passive
|
||||
ronin.widget.update();
|
||||
ronin.terminal.update();
|
||||
ronin.cursor.update();
|
||||
};
|
||||
|
||||
this.key_tab = function()
|
||||
{
|
||||
}
|
||||
|
||||
this.key_enter = function()
|
||||
{
|
||||
ronin.terminal.run();
|
||||
}
|
||||
|
||||
this.key_space = function()
|
||||
{
|
||||
}
|
||||
|
||||
this.key_arrow_up = function()
|
||||
{
|
||||
ronin.frame.select_layer(ronin.frame.layer_above());
|
||||
}
|
||||
|
||||
this.key_arrow_down = function()
|
||||
{
|
||||
ronin.frame.select_layer(ronin.frame.layer_below());
|
||||
}
|
||||
|
||||
this.key_arrow_left = function()
|
||||
{
|
||||
if(ronin.module){ ronin.module.key_arrow_left(); }
|
||||
}
|
||||
|
||||
this.key_arrow_right = function()
|
||||
{
|
||||
if(ronin.module){ ronin.module.key_arrow_right(); }
|
||||
}
|
||||
|
||||
this.key_colon = function()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.key_escape = function()
|
||||
{
|
||||
ronin.overlay.key_escape();
|
||||
|
||||
for(var key in ronin.modules){
|
||||
ronin.modules[key].key_escape();
|
||||
}
|
||||
}
|
||||
|
||||
this.key_delete = function()
|
||||
{
|
||||
if(ronin.module){ ronin.module.key_delete(); }
|
||||
}
|
||||
}
|
@ -1,175 +0,0 @@
|
||||
function Ronin()
|
||||
{
|
||||
this.modules = {};
|
||||
this.element = document.getElementById('ronin');
|
||||
|
||||
this.default = new Default("`");
|
||||
|
||||
this.frame = new Frame("@");
|
||||
this.path = new Path("+");
|
||||
this.type = new Type("&");
|
||||
this.brush = new Brush("-");
|
||||
|
||||
this.source = new Source("$");
|
||||
|
||||
this.eye = new Eye("*");
|
||||
this.render = new Render("%");
|
||||
this.magnet = new Magnet("^");
|
||||
|
||||
this.overlay = new Overlay("|");
|
||||
this.terminal = new Terminal(">");
|
||||
this.cursor = new Cursor(".");
|
||||
this.widget = new Widget("?");
|
||||
|
||||
this.modules[this.frame.name] = this.frame;
|
||||
this.modules[this.type.name] = this.type;
|
||||
this.modules[this.path.name] = this.path;
|
||||
|
||||
this.modules[this.brush.name] = this.brush;
|
||||
|
||||
this.modules[this.source.name] = this.source;
|
||||
this.modules[this.render.name] = this.render;
|
||||
this.modules[this.eye.name] = this.eye;
|
||||
this.modules[this.magnet.name] = this.magnet;
|
||||
|
||||
this.modules[this.cursor.name] = this.cursor;
|
||||
this.modules[this.terminal.name] = this.terminal;
|
||||
|
||||
// document.addEventListener('contextmenu', function(ev){ ev.preventDefault(); return false;}, false);
|
||||
window.addEventListener('resize', function(){ ronin.on_resize(); }, true);
|
||||
|
||||
this.install = function()
|
||||
{
|
||||
ronin.frame.element = document.getElementById('frame');
|
||||
ronin.cursor.element = document.getElementById('cursor');
|
||||
ronin.terminal.element = document.getElementById('terminal');
|
||||
|
||||
for(var key in this.modules){
|
||||
this.modules[key].install();
|
||||
}
|
||||
|
||||
this.widget.install();
|
||||
ronin.cursor.mode = ronin.brush;
|
||||
this.on_drag();
|
||||
}
|
||||
|
||||
this.start = function(hash = null)
|
||||
{
|
||||
var target_file = hash.length > 2 ? hash.substr(1,hash.length-1)+".rin" : "default.rin"
|
||||
|
||||
ronin.terminal.update();
|
||||
ronin.widget.update();
|
||||
ronin.terminal.input.focus();
|
||||
// ronin.load(target_file);
|
||||
}
|
||||
|
||||
this.hint = function(method)
|
||||
{
|
||||
var html = "";
|
||||
if(this.terminal.input.value){
|
||||
for(id in ronin.modules){
|
||||
if(this.terminal.input.value != ronin.modules[id].name.substr(0,this.terminal.input.value.length)){ continue; }
|
||||
html += "<span class='module'>"+ronin.modules[id].name+"</span> ";
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(id in ronin.modules){
|
||||
html += "<span class='module'>"+ronin.modules[id].name+"</span> ";
|
||||
}
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
this.cursors = [];
|
||||
|
||||
this.position_in_canvas = function(e)
|
||||
{
|
||||
// x -= parseInt(this.frame.element.style.left) - parseInt(this.frame.element.style.width/2);
|
||||
var x = e.clientX - parseInt(this.frame.element.style.left);
|
||||
var y = e.clientY - parseInt(this.frame.element.style.top);
|
||||
return new Position(x,y);
|
||||
}
|
||||
|
||||
this.timestamp = function()
|
||||
{
|
||||
var currentdate = new Date();
|
||||
var date = currentdate.getFullYear()+""+(currentdate.getMonth()+1)+""+currentdate.getDate();
|
||||
return date+" "+currentdate.getHours()+":"+currentdate.getMinutes()+":"+currentdate.getSeconds();
|
||||
}
|
||||
|
||||
this.on_resize = function()
|
||||
{
|
||||
ronin.frame.center();
|
||||
}
|
||||
|
||||
this.on_drag = function()
|
||||
{
|
||||
// Position Background
|
||||
var bg_offset_parts = ronin.element.style.backgroundPosition == "" ? [0,0] : ronin.element.style.backgroundPosition.split(" ");
|
||||
|
||||
var x = parseInt(ronin.frame.element.style.left)/4;
|
||||
var y = parseInt(ronin.frame.element.style.top)/4;
|
||||
|
||||
ronin.element.style.backgroundPosition = x+"px "+y+"px";
|
||||
}
|
||||
|
||||
this.filename = "default.rin";
|
||||
|
||||
this.load = function readTextFile(name)
|
||||
{
|
||||
return;
|
||||
this.filename = name;
|
||||
var file = "presets/"+name+'?'+new Date().getTime();
|
||||
var rawFile = new XMLHttpRequest();
|
||||
rawFile.open("GET", file, false);
|
||||
rawFile.onreadystatechange = function ()
|
||||
{
|
||||
if(rawFile.readyState === 4)
|
||||
{
|
||||
if(rawFile.status === 200 || rawFile.status == 0)
|
||||
{
|
||||
var allText = rawFile.responseText;
|
||||
ronin.terminal.log(new Log(null,"Loaded file "+name));
|
||||
ronin.terminal.run_multi(allText.split("\n").join(";"));
|
||||
}
|
||||
}
|
||||
}
|
||||
rawFile.send(null);
|
||||
ronin.widget.update();
|
||||
ronin.terminal.update();
|
||||
}
|
||||
|
||||
// Drag file on canvas
|
||||
|
||||
this.element.addEventListener('dragover',function(e)
|
||||
{
|
||||
e.stopPropagation(); e.preventDefault(); e.dataTransfer.dropEffect = 'copy';
|
||||
});
|
||||
|
||||
this.element.addEventListener('drop', function(e)
|
||||
{
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var files = e.dataTransfer.files;
|
||||
var file = files[0];
|
||||
|
||||
if (!file.type.match(/image.*/)) { console.log("Not image"); return false; }
|
||||
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = function(event)
|
||||
{
|
||||
base_image = new Image();
|
||||
base_image.src = event.target.result;
|
||||
|
||||
var width = base_image.naturalWidth;
|
||||
var height = base_image.naturalHeight;
|
||||
|
||||
// Display as large as the canvas
|
||||
var ratio = ronin.frame.size.width/width;
|
||||
ronin.frame.active_layer.context().drawImage(base_image, 0,0,width * ratio,height * ratio);
|
||||
}
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
function Filter_Balance()
|
||||
{
|
||||
Filter.call(this);
|
||||
|
||||
this.parameters = [Color];
|
||||
|
||||
this.render = function(params)
|
||||
{
|
||||
var color = params.color() ? params.color().floats() : new Color("#999999").floats();
|
||||
var originalData = ronin.frame.context().getImageData(0, 0, ronin.frame.size.width*2, ronin.frame.size.height*2);
|
||||
var data = originalData.data;
|
||||
|
||||
for(var i = 0; i < data.length; i += 4) {
|
||||
data[i] = data[i] * (color.r + 0.5);
|
||||
data[i + 1] = data[i + 1] * (color.g + 0.5);
|
||||
data[i + 2] = data[i + 2] * (color.b + 0.5);
|
||||
}
|
||||
|
||||
ronin.frame.context().putImageData(originalData, 0, 0);
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
function Filter_Chromatic()
|
||||
{
|
||||
Filter.call(this);
|
||||
|
||||
this.parameters = [Value, Position];
|
||||
//value is maximum distance pixels are shifted
|
||||
//position is where the pixels are shifted from, defaults to half the image
|
||||
|
||||
this.render = function(cmd)
|
||||
{
|
||||
var position = cmd.position() ? cmd.position() : new Position(ronin.frame.size.width,ronin.frame.size.height);
|
||||
var value = cmd.value() ? cmd.value().float : 5;
|
||||
|
||||
this.draw(this.context(),value,position);
|
||||
}
|
||||
|
||||
this.preview = function(cmd)
|
||||
{
|
||||
if(cmd.position()){
|
||||
ronin.overlay.draw(cmd.position());
|
||||
}
|
||||
}
|
||||
|
||||
this.draw = function(context = this.context(), value, position)
|
||||
{
|
||||
var w = ronin.frame.size.width;
|
||||
var h = ronin.frame.size.height;
|
||||
|
||||
//no longer letting you set how far each chanel is shifted, not sure how to receive extra data any more
|
||||
var s = {r:value,g:value*.5,b:0};
|
||||
|
||||
var context = ronin.frame.context();
|
||||
|
||||
//now need two imagedatas to sample off of, for some reason I cant just dump the new pixels into an empty array :/
|
||||
var originalData = context.getImageData(0, 0, w*2, h*2);
|
||||
var imageData = context.getImageData(0, 0, w*2, h*2);
|
||||
|
||||
var maxLength = Math.sqrt(w*w+h*h);
|
||||
for (var i=0; i<w*2; i++) {
|
||||
for(var j=0; j<h*2; j++){
|
||||
var x = i-position.x;
|
||||
var y = j-position.y;
|
||||
var a = Math.atan2(y,x);
|
||||
var d = Math.sqrt(x*x+y*y);
|
||||
var f = (d-s.r*d/maxLength);
|
||||
x = Math.cos(a)*f+position.x;
|
||||
y = Math.sin(a)*f+position.y;
|
||||
var r = this.get_color_bilinear(originalData, x, y);
|
||||
f = (d-s.g*d/maxLength);
|
||||
x = Math.cos(a)*f+position.x;
|
||||
y = Math.sin(a)*f+position.y;
|
||||
var g = this.get_color_bilinear(originalData, x, y);
|
||||
f = (d-s.b*d/maxLength);
|
||||
x = Math.cos(a)*f+position.x;
|
||||
y = Math.sin(a)*f+position.y;
|
||||
var b = this.get_color_bilinear(originalData, x, y);
|
||||
var c = {r:r.r, g:g.g, b:b.b,a:Math.max(r.a, Math.max(g.a,b.a))};
|
||||
this.set_color(imageData, c, i,j);
|
||||
}
|
||||
}
|
||||
ronin.frame.active_layer.clear();
|
||||
context.putImageData(imageData, 0, 0);
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
function Filter_Contrast()
|
||||
{
|
||||
Filter.call(this);
|
||||
|
||||
this.parameters = [Value];
|
||||
|
||||
this.render = function(params)
|
||||
{
|
||||
var color = params.color() ? params.color().floats() : new Color("#999999").floats();
|
||||
var originalData = ronin.frame.context().getImageData(0, 0, ronin.frame.size.width*2, ronin.frame.size.height*2);
|
||||
var data = originalData.data;
|
||||
|
||||
for(var i = 0; i < data.length; i += 4) {
|
||||
var average = parseFloat(data[i] + data[i+1] + data[i+2])/3;
|
||||
var distance = 50;
|
||||
data[i] = data[i] + distance;
|
||||
data[i + 1] = data[i+1] + distance;
|
||||
data[i + 2] = data[i+2] + distance;
|
||||
}
|
||||
|
||||
ronin.frame.context().putImageData(originalData, 0, 0);
|
||||
}
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
function Filter()
|
||||
{
|
||||
this.name = "Unknown";
|
||||
this.parameters = [];
|
||||
|
||||
this.render = function(cmd)
|
||||
{
|
||||
console.log("render: Nothing here.");
|
||||
}
|
||||
|
||||
this.preview = function(cmd)
|
||||
{
|
||||
console.log("render: Nothing here.");
|
||||
}
|
||||
|
||||
this.get_neighbors = function(pixels,x,y)
|
||||
{
|
||||
return [
|
||||
this.get_color(pixels,x-1,y-1),this.get_color(pixels,x,y-1),this.get_color(pixels,x+1,y-1),
|
||||
this.get_color(pixels,x-1,y),this.get_color(pixels,x,y),this.get_color(pixels,x+1,y),
|
||||
this.get_color(pixels,x-1,y+1),this.get_color(pixels,x,y+1),this.get_color(pixels,x+1,y+1),
|
||||
];
|
||||
}
|
||||
|
||||
this.get_neighbors_average = function(pixels,x,y,weight_map = [1,1,1,1,1,1,1,1,1])
|
||||
{
|
||||
var n = this.get_neighbors(pixels,x,y);
|
||||
var r = 0;
|
||||
var g = 0;
|
||||
var b = 0;
|
||||
for (var i = 0; i < n.length; i++){
|
||||
r += n[i].r * weight_map[i];
|
||||
g += n[i].g * weight_map[i];
|
||||
b += n[i].b * weight_map[i];
|
||||
}
|
||||
return {r:r/n.length,g:g/n.length,b:b/n.length}
|
||||
}
|
||||
|
||||
this.set_color = function(pixels, color, x, y)
|
||||
{
|
||||
x = Math.max(0,Math.min(x,pixels.width-1));
|
||||
y = Math.max(0,Math.min(y,pixels.height-1));
|
||||
var index = (x+y*pixels.width)*4;
|
||||
pixels.data[index] = color.r;
|
||||
pixels.data[index+1] = color.g;
|
||||
pixels.data[index+2] = color.b;
|
||||
pixels.data[index+3] = color.a;
|
||||
}
|
||||
|
||||
this.get_color = function(pixels,x,y)
|
||||
{
|
||||
x = Math.max(0,Math.min(x,pixels.width-1));
|
||||
y = Math.max(0,Math.min(y,pixels.height-1));
|
||||
var index = (x+y*pixels.width)*4;
|
||||
return {r:pixels.data[index], g:pixels.data[index+1], b:pixels.data[index+2], a:pixels.data[index+3]};
|
||||
}
|
||||
|
||||
this.get_color_bilinear = function(pixels, x, y)
|
||||
{
|
||||
var c1 = this.get_color(pixels, Math.floor(x),Math.floor(y));
|
||||
var c2 = this.get_color(pixels, Math.ceil(x),Math.floor(y));
|
||||
var c3 = this.get_color(pixels, Math.floor(x),Math.ceil(y));
|
||||
var c4 = this.get_color(pixels, Math.ceil(x),Math.ceil(y));
|
||||
return this.lerp_color(this.lerp_color(c1,c2, x%1),this.lerp_color(c3,c4, x%1), y%1);
|
||||
}
|
||||
|
||||
this.lerp_color = function(c1, c2, t)
|
||||
{
|
||||
return {r:c1.r+t*(c2.r-c1.r), g:c1.g+t*(c2.g-c1.g), b:c1.b+t*(c2.b-c1.b), a:c1.a+t*(c2.a-c1.a)};
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
this.context = function()
|
||||
{
|
||||
return ronin.frame.context();
|
||||
}
|
||||
|
||||
this.pixels = function()
|
||||
{
|
||||
return ronin.frame.context().getImageData(0,0,ronin.frame.size.width * 2,ronin.frame.size.height * 2);
|
||||
}
|
||||
|
||||
this.hint = function()
|
||||
{
|
||||
var html = "";
|
||||
|
||||
for(id in this.parameters){
|
||||
html += this.parameters[id]+" ";
|
||||
}
|
||||
return html;
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
function Filter_Grey()
|
||||
{
|
||||
Filter.call(this);
|
||||
|
||||
this.parameters = [Color];
|
||||
|
||||
this.render = function(params)
|
||||
{
|
||||
var color = params.color() ? params.color().floats() : new Color("#36ba0e").floats();
|
||||
var originalData = ronin.frame.context().getImageData(0, 0, ronin.frame.size.width*2, ronin.frame.size.height*2);
|
||||
var data = originalData.data;
|
||||
|
||||
for(var i = 0; i < data.length; i += 4) {
|
||||
var r = data[i];
|
||||
var g = data[i+1];
|
||||
var b = data[i+2];
|
||||
var v = color.r*r + color.g*g + color.b*b;
|
||||
data[i] = data[i+1] = data[i+2] = v
|
||||
}
|
||||
ronin.frame.context().putImageData(originalData, 0, 0);
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
function Filter_Invert()
|
||||
{
|
||||
Filter.call(this);
|
||||
this.parameters = [];
|
||||
|
||||
this.render = function(cmd)
|
||||
{
|
||||
var imageObj = new Image();
|
||||
imageObj.src = ronin.frame.active_layer.element.toDataURL('image/png');
|
||||
|
||||
var w = ronin.frame.size.width;
|
||||
var h = ronin.frame.size.height;
|
||||
var context = ronin.frame.context();
|
||||
|
||||
var originalData = context.getImageData(0, 0, w*2, h*2);
|
||||
var data = originalData.data;
|
||||
|
||||
for(var i = 0; i < data.length; i += 4) {
|
||||
data[i] = 255 - data[i];
|
||||
data[i + 1] = 255 - data[i + 1];
|
||||
data[i + 2] = 255 - data[i + 2];
|
||||
}
|
||||
|
||||
ronin.frame.active_layer.clear();
|
||||
context.putImageData(originalData, 0, 0);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
function Filter_Saturate()
|
||||
{
|
||||
Filter.call(this);
|
||||
|
||||
this.parameters = [Color];
|
||||
|
||||
this.render = function(params)
|
||||
{
|
||||
var color = params.color() ? params.color().floats() : new Color("#999999").floats();
|
||||
var originalData = ronin.frame.context().getImageData(0, 0, ronin.frame.size.width*2, ronin.frame.size.height*2);
|
||||
var data = originalData.data;
|
||||
|
||||
for(var i = 0; i < data.length; i += 4) {
|
||||
var average = parseFloat(data[i] + data[i+1] + data[i+2])/3;
|
||||
data[i] = (average+(data[i]*color.r))/2;
|
||||
data[i + 1] = (average+(data[i+1]*color.g))/2;
|
||||
data[i + 2] = (average+(data[i+2]*color.b))/2;
|
||||
}
|
||||
|
||||
ronin.frame.context().putImageData(originalData, 0, 0);
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
function Filter_Sharpen()
|
||||
{
|
||||
Filter.call(this);
|
||||
|
||||
this.parameters = [Value];
|
||||
|
||||
this.render = function(cmd)
|
||||
{
|
||||
var imageObj = new Image();
|
||||
imageObj.src = ronin.frame.active_layer.element.toDataURL('image/png');
|
||||
|
||||
var w = ronin.frame.size.width;
|
||||
var h = ronin.frame.size.height;
|
||||
var context = ronin.frame.context();
|
||||
|
||||
var originalData = context.getImageData(0, 0, w*2, h*2);
|
||||
var data = originalData.data;
|
||||
var newImage = context.getImageData(0, 0, w*2, h*2);
|
||||
|
||||
var strenght = cmd.value() ? cmd.value().float : 1;
|
||||
|
||||
var ver = -1;
|
||||
var dia = 1;
|
||||
var cen = 8;
|
||||
|
||||
var weight_map = [
|
||||
dia * strenght, ver * strenght, dia * strenght,
|
||||
ver * strenght, cen * strenght, ver * strenght,
|
||||
dia * strenght, ver * strenght, dia * strenght
|
||||
];
|
||||
|
||||
for(var i = 0; i < data.length; i += 4) {
|
||||
var p = i / 4;
|
||||
var x = (p % originalData.width);
|
||||
var y = parseInt(p/originalData.width);
|
||||
|
||||
var average = this.get_neighbors_average(originalData,x,y,weight_map);
|
||||
newImage.data[i] = parseInt(average.r);
|
||||
newImage.data[i+1] = parseInt(average.g);
|
||||
newImage.data[i+2] = parseInt(average.b);
|
||||
}
|
||||
|
||||
ronin.frame.active_layer.clear();
|
||||
context.putImageData(newImage, 0, 0);
|
||||
}
|
||||
|
||||
this.preview = function(cmd)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
this.draw = function(context = this.context(), value, position)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
function Filter_Stencil()
|
||||
{
|
||||
Filter.call(this);
|
||||
this.parameters = [Angle,Color];
|
||||
|
||||
this.render = function(cmd)
|
||||
{
|
||||
var angle = cmd.angle() ? cmd.angle().degrees : 20;
|
||||
var color = cmd.color() ? cmd.color().hex : "#000000";
|
||||
|
||||
this.draw(ronin.frame.context(),angle,color);
|
||||
if(ronin.render.layer){ ronin.render.layer.remove(this); }
|
||||
|
||||
return 1, "ok";
|
||||
}
|
||||
|
||||
this.preview = function(cmd)
|
||||
{
|
||||
var angle = cmd.angle() ? cmd.angle().degrees : 20;
|
||||
var color = cmd.color() ? cmd.color().hex : "#000000";
|
||||
|
||||
ronin.render.get_layer().clear();
|
||||
this.draw(ronin.render.layer.context(),angle,color);
|
||||
}
|
||||
|
||||
this.draw = function(context = this.context(), angle, color)
|
||||
{
|
||||
var w = ronin.frame.size.width;
|
||||
var h = ronin.frame.size.height;
|
||||
|
||||
context.translate(w/2,h/2);
|
||||
|
||||
context.rotate(angle*Math.PI/180);
|
||||
|
||||
this.line(context,-w,0,w,0,color);
|
||||
|
||||
this.line(context,w*0.4,-h,w*0.4,h,color);
|
||||
this.line(context,-w*0.4,-h,-w*0.4,h,color);
|
||||
|
||||
this.line(context,-w,h*0.25,w,h*0.25,color);
|
||||
this.line(context,-w,-h*0.25,w,-h*0.25,color);
|
||||
|
||||
this.line(context,w*0.1,0,w*0.1,h,color);
|
||||
this.line(context,-w*0.1,0,-w*0.1,-h,color);
|
||||
|
||||
this.circle(context,w*0.4,-h*0.25,w*0.05,1,1.5,color);
|
||||
this.circle(context,-w*0.4,h*0.25,w*0.05,0,0.5,color);
|
||||
|
||||
context.font = "5px Arial";
|
||||
context.fillStyle = color;
|
||||
context.fillText(angle+"'",(w*0.4)+10,10);
|
||||
|
||||
context.font = "5px Arial";
|
||||
context.fillStyle = color;
|
||||
context.fillText(angle+"'",(-w*0.4)-20,-10);
|
||||
|
||||
context.rotate(-angle*Math.PI/180);
|
||||
context.translate(-w/2,-h/2);
|
||||
}
|
||||
|
||||
this.line = function(context,x1,x2,y1,y2,color)
|
||||
{
|
||||
context.beginPath();
|
||||
context.moveTo(x1,x2);
|
||||
context.lineTo(y1,y2);
|
||||
context.lineCap="round";
|
||||
context.lineWidth = 0.5;
|
||||
context.strokeStyle = color;
|
||||
context.stroke();
|
||||
context.closePath();
|
||||
}
|
||||
|
||||
this.circle = function(context,x,y,r,c1,c2,color)
|
||||
{
|
||||
context.beginPath();
|
||||
context.arc(x,y,r,c1*Math.PI,c2*Math.PI);
|
||||
context.lineCap="round";
|
||||
context.lineWidth = 0.5;
|
||||
context.strokeStyle = color;
|
||||
context.stroke();
|
||||
context.closePath();
|
||||
}
|
||||
}
|
@ -1,138 +0,0 @@
|
||||
function Brush(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.pointers = [new Pointer(new Position("0,0"))];
|
||||
|
||||
this.add_mode(new Mode("paint"));
|
||||
this.add_mode(new Mode("erase","shift"));
|
||||
this.add_setting(new Setting("color","#000000"));
|
||||
this.add_setting(new Setting("size","2"));
|
||||
this.add_method(new Method("add",["Position","Color","Scale","Angle"],["mirror_x","mirror_y"]));
|
||||
this.add_method(new Method("clear"));
|
||||
|
||||
this.add = function(cmd, preview = false)
|
||||
{
|
||||
if(cmd.option("mirror_x")){
|
||||
var mirror_x = parseFloat(cmd.option("mirror_x").value);
|
||||
ronin.overlay.draw(new Position(mirror_x+",0"))
|
||||
}
|
||||
if(cmd.option("mirror_y")){
|
||||
var mirror_y = parseFloat(cmd.option("mirror_y").value);
|
||||
ronin.overlay.draw(new Position("0,"+mirror_y))
|
||||
}
|
||||
|
||||
if(preview){
|
||||
return;
|
||||
}
|
||||
|
||||
var pointer = new Pointer();
|
||||
pointer.offset = cmd.position() ? cmd.position() : new Position("0,0");
|
||||
pointer.color = cmd.color() ? cmd.color().hex : this.settings["color"].value;
|
||||
pointer.scale = cmd.value() ? cmd.value().float : 1;
|
||||
pointer.angle = cmd.angle() ? cmd.angle().degrees : 0;
|
||||
|
||||
if(mirror_x){ pointer.mirror_x = mirror_x; }
|
||||
if(mirror_y){ pointer.mirror_y = mirror_y; }
|
||||
|
||||
this.pointers.push(pointer);
|
||||
|
||||
ronin.terminal.log(new Log(this,"Added pointer at: "+pointer.offset.toString()));
|
||||
|
||||
return 1, "ok";
|
||||
}
|
||||
|
||||
this.remove = function()
|
||||
{
|
||||
this.pointers = [];
|
||||
return 1,"Removed all pointers.";
|
||||
}
|
||||
|
||||
this.size_up = function()
|
||||
{
|
||||
var new_size = this.settings["size"].to_f() + 1;
|
||||
this.settings["size"].update(new_size);
|
||||
}
|
||||
|
||||
this.size_down = function()
|
||||
{
|
||||
var new_size = this.settings["size"].to_f() - 1;
|
||||
this.settings["size"].update(new_size < 1 ? 1 : new_size);
|
||||
}
|
||||
|
||||
// Eraser
|
||||
|
||||
this.erase = function()
|
||||
{
|
||||
if(!this.position_prev){this.position_prev = ronin.cursor.position; }
|
||||
|
||||
var position = ronin.cursor.position;
|
||||
|
||||
ronin.frame.context().beginPath();
|
||||
ronin.frame.context().globalCompositeOperation="destination-out";
|
||||
ronin.frame.context().moveTo(this.position_prev.x,this.position_prev.y);
|
||||
ronin.frame.context().lineTo(position.x,position.y);
|
||||
ronin.frame.context().lineCap="round";
|
||||
ronin.frame.context().lineWidth = this.settings.size.to_f() * 3;
|
||||
ronin.frame.context().strokeStyle = new Color("#ff0000").rgba();
|
||||
ronin.frame.context().stroke();
|
||||
ronin.frame.context().closePath();
|
||||
|
||||
this.position_prev = position;
|
||||
}
|
||||
|
||||
// Mouse
|
||||
|
||||
this.mouse_pointer = function(position)
|
||||
{
|
||||
if(this.pointers.length < 1){ ronin.cursor.draw_pointer_no_pointer(position); return; }
|
||||
return keyboard.shift_held == true ? ronin.cursor.draw_pointer_circle_eraser(position,this.settings["size"].to_f() * 3) : ronin.cursor.draw_pointer_brush(position,this.settings["size"].to_f());
|
||||
}
|
||||
|
||||
this.mouse_mode = function()
|
||||
{
|
||||
if(keyboard.shift_held == true){
|
||||
return "Erase "+this.settings["size"].to_f();
|
||||
}
|
||||
else{
|
||||
return "Paint <i style='color:"+this.settings["color"].value+"'>●</i> "+this.settings["size"].to_f();
|
||||
}
|
||||
}
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
if(position.is_outside()){ return; }
|
||||
|
||||
if(keyboard.shift_held == true){
|
||||
this.erase();
|
||||
}
|
||||
else{
|
||||
if(ronin.brush.pointers.length < 1){ ronin.terminal.log(new Log(this,"Brush has no pointers!"))}
|
||||
for (i = 0; i < ronin.brush.pointers.length; i++) {
|
||||
ronin.brush.pointers[i].start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.mouse_move = function(position,rect)
|
||||
{
|
||||
if(!this.mouse_held){ return; }
|
||||
|
||||
if(keyboard.shift_held == true){
|
||||
this.erase();
|
||||
}
|
||||
else{
|
||||
for (i = 0; i < ronin.brush.pointers.length; i++) {
|
||||
ronin.brush.pointers[i].draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.mouse_up = function(position,rect)
|
||||
{
|
||||
for (i = 0; i < ronin.brush.pointers.length; i++) {
|
||||
ronin.brush.pointers[i].stop();
|
||||
}
|
||||
this.position_prev = null;
|
||||
}
|
||||
}
|
@ -1,146 +0,0 @@
|
||||
function Pointer(offset = new Position(), color = null, scale = 1, angle = 1)
|
||||
{
|
||||
this.offset = offset;
|
||||
this.color = color;
|
||||
this.scale = scale;
|
||||
this.angle = null;
|
||||
|
||||
this.mirror_x = null;
|
||||
this.mirror_y = null;
|
||||
|
||||
this.position_prev = null;
|
||||
this.distance = 0;
|
||||
|
||||
// Parameters
|
||||
|
||||
this.actual_thickness = 0;
|
||||
|
||||
this.thickness = function()
|
||||
{
|
||||
var radius = ronin.brush.settings["size"].to_f() * this.scale;
|
||||
var ratio = 1 - this.position().distance_to((this.position_prev ? this.position_prev[0] : 1)) / 10;
|
||||
var target = radius * ratio;
|
||||
var rate = ronin.brush.settings["size"].to_f()/8;
|
||||
|
||||
if(this.actual_thickness < target){ this.actual_thickness += rate; }
|
||||
if(this.actual_thickness > target){ this.actual_thickness -= rate; }
|
||||
|
||||
return this.actual_thickness;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
this.draw = function()
|
||||
{
|
||||
if(!this.position_prev){this.position_prev = [this.position()]; return; }
|
||||
|
||||
var position = this.position();
|
||||
var position_prev = this.position_prev[0];
|
||||
|
||||
//remove stale previous positions
|
||||
if (this.position_prev.length > 3) this.position_prev.pop();
|
||||
|
||||
this.distance += position.distance_to(position_prev);
|
||||
|
||||
ronin.frame.context().beginPath();
|
||||
|
||||
ronin.frame.context().globalCompositeOperation="source-over";
|
||||
ronin.frame.context().moveTo(position_prev.x,position_prev.y);
|
||||
|
||||
//Choose direct line or curve line based on how many samples available
|
||||
if(this.position_prev.length > 1 && position.distance_to(position_prev) > 5){
|
||||
|
||||
var d = position.distance_to(position_prev)/position_prev.distance_to(this.position_prev[1]);
|
||||
|
||||
//caluclate a control point for the quad curve
|
||||
var ppx = position_prev.x - (this.position_prev[1].x - position_prev.x);
|
||||
var ppy = position_prev.y - (this.position_prev[1].y - position_prev.y);
|
||||
var px = (position.x + position_prev.x)/2;
|
||||
var py = (position.y + position_prev.y)/2;
|
||||
var tx = px + (ppx - px) * 0.2 * d;
|
||||
var ty = py + (ppy - py) * 0.2 * d;
|
||||
|
||||
ronin.frame.context().quadraticCurveTo(tx,ty,position.x,position.y);
|
||||
}
|
||||
else {
|
||||
ronin.frame.context().lineTo(position.x,position.y);
|
||||
}
|
||||
|
||||
ronin.frame.context().lineCap="round";
|
||||
ronin.frame.context().lineWidth = this.thickness();
|
||||
ronin.frame.context().strokeStyle = this.color ? this.color : ronin.brush.settings["color"].value;
|
||||
ronin.frame.context().stroke();
|
||||
ronin.frame.context().closePath();
|
||||
|
||||
this.position_prev.unshift(position);
|
||||
}
|
||||
|
||||
this.position = function()
|
||||
{
|
||||
if(this.mirror_x && this.mirror_x > 0){
|
||||
return this.position_mirror_x();
|
||||
}
|
||||
if(this.mirror_y && this.mirror_y > 0){
|
||||
return this.position_mirror_y();
|
||||
}
|
||||
|
||||
if(this.angle && this.offset){
|
||||
return this.position_rotation();
|
||||
}
|
||||
else if(this.mirror && this.mirror.height > 0){
|
||||
return this.position_mirror_y();
|
||||
}
|
||||
return this.position_default();
|
||||
}
|
||||
|
||||
// Effects
|
||||
|
||||
this.position_default = function()
|
||||
{
|
||||
return ronin.cursor.position.add(this.offset);
|
||||
}
|
||||
|
||||
this.position_mirror_x = function()
|
||||
{
|
||||
return new Position((2 * this.mirror_x) - (ronin.cursor.position.x + this.offset.x), 0 + (ronin.cursor.position.y + this.offset.y));
|
||||
}
|
||||
|
||||
this.position_mirror_y = function()
|
||||
{
|
||||
return new Position((ronin.cursor.position.x + this.offset.x), (2 * this.mirror_y) - (ronin.cursor.position.y + this.offset.y));
|
||||
}
|
||||
|
||||
this.position_rotation = function()
|
||||
{
|
||||
var angle_radian = this.angle * Math.PI / 180;
|
||||
var deltaX = ronin.cursor.position.x - this.offset.x;
|
||||
var deltaY = ronin.cursor.position.y - this.offset.y;
|
||||
var t = Math.atan2(deltaY, deltaX) + angle_radian;
|
||||
var radius = ronin.cursor.position.distance_to(this.offset);
|
||||
var x = Math.cos(t) * radius;
|
||||
var y = Math.sin(t) * radius;
|
||||
return new Position(x + this.offset.x,y + this.offset.y);
|
||||
}
|
||||
|
||||
this.start = function()
|
||||
{
|
||||
var radius = ronin.brush.settings["size"].to_f() * this.scale;
|
||||
this.actual_thickness = radius/4;
|
||||
ronin.frame.context().beginPath();
|
||||
ronin.frame.context().arc(this.position().x, this.position().y, this.thickness(), 0, 2 * Math.PI, false);
|
||||
ronin.frame.context().lineWidth = 0;
|
||||
ronin.frame.context().fillStyle = this.color ? this.color : ronin.brush.settings["color"].value;
|
||||
ronin.frame.context().fill();
|
||||
ronin.frame.context().closePath();
|
||||
}
|
||||
|
||||
this.stop = function()
|
||||
{
|
||||
this.position_prev = null;
|
||||
}
|
||||
|
||||
this.widget = function()
|
||||
{
|
||||
return this.offset.toString();
|
||||
}
|
||||
}
|
@ -1,301 +0,0 @@
|
||||
function Cursor(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.add_setting(new Setting("color","#000000"));
|
||||
this.add_setting(new Setting("color_alt","#fffffff"));
|
||||
|
||||
this.mode = null;
|
||||
this.position = new Position();
|
||||
this.position_in_window = new Position();
|
||||
|
||||
document.addEventListener('mousedown', function(e){ ronin.cursor.mouse_down(ronin.position_in_canvas(e),e);}, false);
|
||||
document.addEventListener('mousemove', function(e){ ronin.cursor.mouse_move(ronin.position_in_canvas(e),e);}, false);
|
||||
document.addEventListener('mouseup', function(e){ ronin.cursor.mouse_up(ronin.position_in_canvas(e),e);}, false);
|
||||
|
||||
this.update = function(event = null)
|
||||
{
|
||||
if(ronin.terminal.cmd().module()){
|
||||
this.set_mode(ronin.terminal.cmd().module());
|
||||
}
|
||||
else if(keyboard.shift_held,keyboard.alt_held){
|
||||
this.set_mode(ronin.frame.active_layer);
|
||||
}
|
||||
else if(this.is_inside){
|
||||
this.set_mode(ronin.default)
|
||||
}
|
||||
else{
|
||||
this.set_mode(ronin.brush);
|
||||
}
|
||||
}
|
||||
|
||||
this.set_mode = function(mode = ronin.brush)
|
||||
{
|
||||
if(!mode){ return; }
|
||||
|
||||
if(this.mode == mode){ return; }
|
||||
this.mode = mode;
|
||||
document.body.setAttribute("class",this.mode.name);
|
||||
ronin.widget.update();
|
||||
}
|
||||
|
||||
this.mouse_down = function(position,e)
|
||||
{
|
||||
var true_pos = e.clientX;
|
||||
var better_pos = (e.clientX/parseFloat(window.innerWidth)) * window.innerWidth;
|
||||
|
||||
if(this.layer){ this.layer.clear(); }
|
||||
|
||||
this.position = ronin.magnet.update_mouse(position);
|
||||
this.position_in_window = new Position(e.clientX,e.clientY);
|
||||
|
||||
if(this.mode.constructor.name != Cursor.name){
|
||||
this.mode.mouse_from = this.position;
|
||||
this.mode.mouse_held = true;
|
||||
if(!position.is_outside()){
|
||||
this.mode.mouse_down(this.position);
|
||||
}
|
||||
else{
|
||||
ronin.cursor.set_mode(ronin.default);
|
||||
ronin.default.mouse_down(this.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.mouse_move = function(position,e)
|
||||
{
|
||||
if(!this.layer){ this.create_layer(); }
|
||||
|
||||
// On/Out
|
||||
if(position.is_outside()){ this.mouse_outside(); }
|
||||
else{ this.mouse_inside(); }
|
||||
|
||||
this.layer.clear();
|
||||
|
||||
// Magnet
|
||||
this.position = ronin.magnet.update_mouse(position);
|
||||
this.position_in_window = new Position(e.clientX,e.clientY);
|
||||
|
||||
if(this.mode){this.mode.mouse_pointer(this.position);}
|
||||
else{ this.mouse_pointer(this.position);}
|
||||
|
||||
if(this.mode.mouse_from == null){ return; }
|
||||
|
||||
var rect = new Rect();
|
||||
rect.width = this.position.x - this.mode.mouse_from.x;
|
||||
rect.height = this.position.y - this.mode.mouse_from.y;
|
||||
|
||||
if(this.mode.constructor.name != Cursor.name){
|
||||
this.mode.mouse_move(this.position,rect);
|
||||
this.mode.mouse_prev = this.position;
|
||||
}
|
||||
}
|
||||
|
||||
this.mouse_up = function(position,e)
|
||||
{
|
||||
this.position = ronin.magnet.update_mouse(position);
|
||||
this.position_in_window = new Position(e.clientX,e.clientY);
|
||||
|
||||
if(this.mode.mouse_from){
|
||||
var rect = new Rect();
|
||||
rect.width = this.position.x - this.mode.mouse_from.x;
|
||||
rect.height = this.position.y - this.mode.mouse_from.y;
|
||||
}
|
||||
|
||||
if(!this.mode){ return; }
|
||||
|
||||
if(this.mode.constructor.name != Cursor.name){
|
||||
if(!position.is_outside()){
|
||||
this.mode.mouse_up(this.position,rect);
|
||||
}
|
||||
this.mode.mouse_held = false;
|
||||
}
|
||||
this.mode.mouse_from = null;
|
||||
}
|
||||
|
||||
// over/out
|
||||
|
||||
this.is_inside = false;
|
||||
|
||||
this.mouse_outside = function()
|
||||
{
|
||||
if(this.is_inside){ return; }
|
||||
|
||||
this.is_inside = true;
|
||||
this.update();
|
||||
}
|
||||
|
||||
this.mouse_inside = function()
|
||||
{
|
||||
if(!this.is_inside){ return; }
|
||||
|
||||
this.is_inside = false;
|
||||
this.update();
|
||||
}
|
||||
|
||||
this.draw_pointer_arrow = function(position,size = 1)
|
||||
{
|
||||
if(!this.layer){ this.create_layer(); }
|
||||
|
||||
this.pointer_last = this.pointer_last ? this.pointer_last : position;
|
||||
|
||||
this.layer.context().beginPath();
|
||||
|
||||
// Background
|
||||
this.layer.context().moveTo(position.x + 5,position.y);
|
||||
this.layer.context().lineTo(position.x,position.y);
|
||||
this.layer.context().lineTo(position.x,position.y + 5);
|
||||
|
||||
this.layer.context().lineCap="square";
|
||||
this.layer.context().lineWidth = 2;
|
||||
this.layer.context().strokeStyle = "#000000";
|
||||
this.layer.context().stroke();
|
||||
|
||||
this.layer.context().lineCap="round";
|
||||
this.layer.context().lineWidth = 1;
|
||||
this.layer.context().strokeStyle = "#ffffff";
|
||||
this.layer.context().stroke();
|
||||
|
||||
this.layer.context().closePath();
|
||||
|
||||
this.pointer_last = position;
|
||||
}
|
||||
|
||||
this.draw_pointer_no_pointer = function(position,size = 2)
|
||||
{
|
||||
if(!this.layer){ this.create_layer(); }
|
||||
|
||||
var radius = 4000;
|
||||
|
||||
this.pointer_last = this.pointer_last ? this.pointer_last : position;
|
||||
|
||||
this.layer.context().beginPath();
|
||||
|
||||
this.layer.context().moveTo(position.x - radius,position.y + radius);
|
||||
this.layer.context().lineTo(position.x - size,position.y + size);
|
||||
this.layer.context().moveTo(position.x + radius,position.y + radius);
|
||||
this.layer.context().lineTo(position.x + size,position.y + size);
|
||||
|
||||
this.layer.context().moveTo(position.x - radius,position.y - radius);
|
||||
this.layer.context().lineTo(position.x - size,position.y - size);
|
||||
this.layer.context().moveTo(position.x + radius,position.y - radius);
|
||||
this.layer.context().lineTo(position.x + size,position.y - size);
|
||||
|
||||
this.layer.context().lineCap="square";
|
||||
this.layer.context().lineWidth = 2;
|
||||
this.layer.context().strokeStyle = "#000000";
|
||||
this.layer.context().stroke();
|
||||
|
||||
this.layer.context().lineCap="round";
|
||||
this.layer.context().lineWidth = 1;
|
||||
this.layer.context().strokeStyle = "#ffffff";
|
||||
this.layer.context().stroke();
|
||||
|
||||
this.layer.context().closePath();
|
||||
|
||||
this.pointer_last = position;
|
||||
}
|
||||
|
||||
this.draw_pointer_brush = function(position,size = 1)
|
||||
{
|
||||
if(!this.layer){ this.create_layer(); }
|
||||
|
||||
this.pointer_last = this.pointer_last ? this.pointer_last : position;
|
||||
|
||||
this.layer.context().beginPath();
|
||||
|
||||
this.layer.context().arc(position.x, position.y, size/2, 0, 2 * Math.PI, false);
|
||||
|
||||
this.layer.context().lineWidth = 2;
|
||||
this.layer.context().strokeStyle = "#000000";
|
||||
this.layer.context().stroke();
|
||||
|
||||
this.layer.context().arc(position.x, position.y, size/2, 0, 2 * Math.PI, false);
|
||||
|
||||
this.layer.context().lineWidth = 1;
|
||||
this.layer.context().strokeStyle = ronin.brush.settings["color"].value != "#000000" ? ronin.brush.settings["color"].value : "#ffffff";
|
||||
this.layer.context().stroke();
|
||||
|
||||
this.layer.context().closePath();
|
||||
|
||||
this.pointer_last = position;
|
||||
}
|
||||
|
||||
this.draw_pointer_circle_eraser = function(position,size = 1)
|
||||
{
|
||||
if(!this.layer){ this.create_layer(); }
|
||||
|
||||
this.pointer_last = this.pointer_last ? this.pointer_last : position;
|
||||
|
||||
this.layer.context().beginPath();
|
||||
this.layer.context().arc(position.x, position.y, (size/2), 0, 2 * Math.PI, false);
|
||||
|
||||
this.layer.context().lineCap="square";
|
||||
this.layer.context().lineWidth = 2;
|
||||
this.layer.context().strokeStyle = "#000000";
|
||||
this.layer.context().stroke();
|
||||
|
||||
this.layer.context().lineCap="round";
|
||||
this.layer.context().lineWidth = 1;
|
||||
this.layer.context().strokeStyle = "#ffffff";
|
||||
this.layer.context().stroke();
|
||||
|
||||
this.layer.context().closePath();
|
||||
|
||||
this.pointer_last = position;
|
||||
}
|
||||
|
||||
this.draw_pointer_drag = function(position)
|
||||
{
|
||||
if(!this.layer){ this.create_layer(); }
|
||||
|
||||
this.pointer_last = this.pointer_last ? this.pointer_last : position;
|
||||
|
||||
this.layer.context().beginPath();
|
||||
|
||||
var radius = 5;
|
||||
|
||||
this.layer.context().moveTo(position.x,position.y - radius);
|
||||
this.layer.context().lineTo(position.x,position.y + radius);
|
||||
this.layer.context().moveTo(position.x - radius/2,position.y - radius);
|
||||
this.layer.context().lineTo(position.x - radius/2,position.y + radius);
|
||||
this.layer.context().moveTo(position.x + radius/2,position.y - radius);
|
||||
this.layer.context().lineTo(position.x + radius/2,position.y + radius);
|
||||
this.layer.context().moveTo(position.x + radius,position.y - radius);
|
||||
this.layer.context().lineTo(position.x + radius,position.y + radius);
|
||||
this.layer.context().moveTo(position.x - radius,position.y - radius);
|
||||
this.layer.context().lineTo(position.x - radius,position.y + radius);
|
||||
|
||||
this.layer.context().lineCap="square";
|
||||
this.layer.context().lineWidth = 2;
|
||||
this.layer.context().strokeStyle = "#000000";
|
||||
this.layer.context().stroke();
|
||||
|
||||
this.layer.context().lineCap="round";
|
||||
this.layer.context().lineWidth = 1;
|
||||
this.layer.context().strokeStyle = "#ffffff";
|
||||
this.layer.context().stroke();
|
||||
|
||||
this.layer.context().closePath();
|
||||
|
||||
this.pointer_last = position;
|
||||
}
|
||||
|
||||
this.release = function()
|
||||
{
|
||||
this.mode.mouse_held = false;
|
||||
this.mode.mouse_from = null;
|
||||
this.mode = ronin.brush;
|
||||
ronin.terminal.input.focus();
|
||||
}
|
||||
|
||||
this.widget = function()
|
||||
{
|
||||
return "<span class='mouse'>"+this.mode.name+"."+this.mode.mouse_mode()+"</span>";
|
||||
}
|
||||
|
||||
this.key_escape = function()
|
||||
{
|
||||
if(this.layer){ this.layer.remove(this); }
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
function Default(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
// Cursor
|
||||
|
||||
this.mouse_mode = function()
|
||||
{
|
||||
return "Drag";
|
||||
}
|
||||
|
||||
this.mouse_pointer = function(position)
|
||||
{
|
||||
return ronin.cursor.draw_pointer_drag(position);
|
||||
}
|
||||
|
||||
this.drag_from = null;
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
this.drag_from = ronin.cursor.position_in_window;
|
||||
}
|
||||
|
||||
this.mouse_move = function(position)
|
||||
{
|
||||
if(this.drag_from === null){ return; }
|
||||
|
||||
var offset = ronin.cursor.position_in_window.offset(this.drag_from);
|
||||
|
||||
ronin.frame.element.style.left = parseInt(ronin.frame.element.style.left) + offset.x;
|
||||
ronin.frame.element.style.top = parseInt(ronin.frame.element.style.top) + offset.y;
|
||||
|
||||
ronin.on_drag();
|
||||
|
||||
this.drag_from = ronin.cursor.position_in_window;
|
||||
}
|
||||
|
||||
this.mouse_up = function(event)
|
||||
{
|
||||
this.drag_from = null;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
function Eye(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.add_mode(new Mode("picker"));
|
||||
|
||||
// TODO: If a rect is given, return the average color
|
||||
this.color_picker = function(position,rect = null)
|
||||
{
|
||||
var pixel = ronin.frame.context().getImageData(position.x*2, position.y*2, 1, 1).data;
|
||||
var hex = new Color().rgb_to_hex({r:pixel[0],g:pixel[1],b:pixel[2]});
|
||||
ronin.terminal.log(new Log(this,"Pixel on "+ronin.frame.active_layer.name+" layer at "+position.toString()+" is "+hex));
|
||||
ronin.terminal.input.focus();
|
||||
}
|
||||
|
||||
// Mouse
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
this.color_picker(position);
|
||||
}
|
||||
|
||||
this.mouse_move = function(position,rect)
|
||||
{
|
||||
this.color_picker(position);
|
||||
}
|
||||
|
||||
this.mouse_up = function(position,rect)
|
||||
{
|
||||
this.color_picker(position);
|
||||
}
|
||||
}
|
@ -1,205 +0,0 @@
|
||||
function Frame(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.element = null;
|
||||
|
||||
this.size = new Rect("200x200");
|
||||
|
||||
this.layers = {};
|
||||
this.active_layer = null;
|
||||
this.render_layer = null;
|
||||
|
||||
this.add_method(new Method("resize",[new Position().name,new Rect().name]));
|
||||
this.add_method(new Method("select",["text"]));
|
||||
this.add_mode(new Mode("resize"));
|
||||
|
||||
this.install = function()
|
||||
{
|
||||
this.select(new Command("frame.select background"));
|
||||
|
||||
// Canvas
|
||||
var starting_canvas = new Rect();
|
||||
starting_canvas.width = window.innerWidth - 100;
|
||||
starting_canvas.height = window.innerHeight - 100;
|
||||
|
||||
// Clamp
|
||||
|
||||
starting_canvas.width = parseInt(starting_canvas.width/40) * 40 - 40;
|
||||
starting_canvas.height = parseInt(starting_canvas.height/40) * 40 - 40;
|
||||
|
||||
this.resize(new Command(starting_canvas.width+"x"+starting_canvas.height));
|
||||
}
|
||||
|
||||
// Methods
|
||||
|
||||
this.resize = function(cmd, preview = false)
|
||||
{
|
||||
var rect = cmd.rect();
|
||||
var position = cmd.position() ? cmd.position() : new Position(0,0);
|
||||
|
||||
if(preview){ ronin.overlay.draw(position,rect); return; }
|
||||
|
||||
for(layer_name in ronin.frame.layers){
|
||||
ronin.frame.layers[layer_name].resize(rect);
|
||||
}
|
||||
|
||||
ronin.frame.element.width = rect.width * 2;
|
||||
ronin.frame.element.height = rect.height * 2;
|
||||
ronin.frame.element.style.width = rect.width+"px";
|
||||
ronin.frame.element.style.height = rect.height+"px";
|
||||
|
||||
ronin.frame.element.style.left = (window.innerWidth - rect.width)/2;
|
||||
ronin.frame.element.style.top = (window.innerHeight - rect.height)/2;
|
||||
|
||||
ronin.on_resize();
|
||||
|
||||
this.size = rect;
|
||||
|
||||
return 1, "Resized to "+this.size.toString();
|
||||
}
|
||||
|
||||
this.select = function(cmd, preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
|
||||
var layer_name = cmd.values();
|
||||
|
||||
if(!ronin.frame.layers[layer_name]){
|
||||
this.add_layer(new Layer(layer_name));
|
||||
}
|
||||
this.select_layer(this.layers[layer_name]);
|
||||
ronin.modules["layer"] = this.layers[layer_name];
|
||||
ronin.layer = this.layers[layer_name];
|
||||
|
||||
return 1, "Selected "+this.active_layer.name;
|
||||
}
|
||||
|
||||
this.context = function()
|
||||
{
|
||||
return this.active_layer.context();
|
||||
}
|
||||
|
||||
// Misc
|
||||
|
||||
this.blink = function()
|
||||
{
|
||||
Object.keys(ronin.frame.layers).forEach(function (key) {
|
||||
ronin.frame.layers[key].blink();
|
||||
});
|
||||
setTimeout(function(){ ronin.frame.blink(); }, 30);
|
||||
}
|
||||
|
||||
this.center = function()
|
||||
{
|
||||
ronin.frame.element.style.left = (window.innerWidth/2) - (ronin.frame.element.width/4);
|
||||
ronin.frame.element.style.top = (window.innerHeight/2) - (ronin.frame.element.height/4) - 30;
|
||||
}
|
||||
|
||||
this.select_layer = function(layer)
|
||||
{
|
||||
if(!layer || layer.manager){ return; }
|
||||
this.active_layer = layer;
|
||||
}
|
||||
|
||||
this.add_layer = function(layer)
|
||||
{
|
||||
if(this.active_layer){layer.set_depth(this.active_layer.depth+1);}
|
||||
layer.resize(this.size);
|
||||
this.layers[layer.name] = layer;
|
||||
this.element.appendChild(layer.element);
|
||||
}
|
||||
|
||||
// Commands
|
||||
|
||||
this.layer_above = function()
|
||||
{
|
||||
var keys = Object.keys(ronin.frame.layers);
|
||||
var loc = keys.indexOf(this.active_layer.name);
|
||||
|
||||
if(loc >= keys.length-1){ console.log("Reached end"); return false; }
|
||||
|
||||
if(keys[loc+1] != null){ return ronin.frame.layers[keys[loc+1]]; }
|
||||
}
|
||||
|
||||
this.layer_below = function()
|
||||
{
|
||||
var keys = Object.keys(ronin.frame.layers);
|
||||
var loc = keys.indexOf(this.active_layer.name);
|
||||
|
||||
if(keys[loc-1] != null){ return ronin.frame.layers[keys[loc-1]]; }
|
||||
}
|
||||
|
||||
// Cursor
|
||||
|
||||
this.mouse_mode = function()
|
||||
{
|
||||
return "crop";
|
||||
}
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
ronin.overlay.draw(position);
|
||||
}
|
||||
this.mouse_move = function(position,rect)
|
||||
{
|
||||
ronin.overlay.draw(this.mouse_from,rect);
|
||||
}
|
||||
|
||||
this.mouse_up = function(position,rect)
|
||||
{
|
||||
ronin.overlay.draw(this.mouse_from,rect)+" "+rect.toString();
|
||||
|
||||
var line = "frame.resize "+this.mouse_from.toString()+" "+rect.toString();
|
||||
ronin.terminal.update(line);
|
||||
}
|
||||
|
||||
this.widget = function()
|
||||
{
|
||||
var html = ""
|
||||
|
||||
html += this.size.toString()+" ";
|
||||
html += this.active_layer.name+" ";
|
||||
|
||||
var user_layers = 0;
|
||||
var managed_layers = 0;
|
||||
|
||||
count = 0;
|
||||
for(id in this.layers){
|
||||
if(this.layers[id].manager){
|
||||
managed_layers += 1;
|
||||
}
|
||||
else{
|
||||
user_layers += 1;
|
||||
}
|
||||
count += 1;
|
||||
}
|
||||
|
||||
html += user_layers+"&"+managed_layers+" ";
|
||||
|
||||
html += this.widget_map()+" "
|
||||
|
||||
return html
|
||||
}
|
||||
|
||||
this.widget_map = function()
|
||||
{
|
||||
html = ""
|
||||
var keys = Object.keys(ronin.frame.layers);
|
||||
var loc = keys.indexOf(this.active_layer.name);
|
||||
i = 0;
|
||||
while(i < keys.length){
|
||||
if(i == loc){
|
||||
html += "<span style='color:white'>|</span>";
|
||||
}
|
||||
else if(this.layers[keys[i]].manager){
|
||||
html += "<span style='color:red'>|</span>";
|
||||
}
|
||||
else{
|
||||
html += "|";
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
return html;
|
||||
}
|
||||
}
|
@ -1,187 +0,0 @@
|
||||
function Layer(name,manager = null)
|
||||
{
|
||||
Module.call(this,"#");
|
||||
|
||||
this.add_method(new Method("translate",["position"]));
|
||||
this.add_method(new Method("rotate",["position","angle"]));
|
||||
this.add_method(new Method("scale",["float"]));
|
||||
this.add_method(new Method("clear",[]));
|
||||
this.add_method(new Method("rotate",["position","angle"]));
|
||||
this.add_method(new Method("mirror",["position"]));
|
||||
this.add_method(new Method("fill",["color","position","rect"]));
|
||||
|
||||
this.add_method(new Method("rename",["text"]));
|
||||
|
||||
this.name = name;
|
||||
this.rune = "#";
|
||||
this.manager = manager;
|
||||
this.element = document.createElement("canvas");
|
||||
this.element.setAttribute("id","_"+name);
|
||||
this.element.setAttribute("class","layer");
|
||||
this.depth = 0;
|
||||
|
||||
this.scale = function(cmd,preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
|
||||
var ratio = parseFloat(cmd.values());
|
||||
var data = ronin.frame.context().canvas;
|
||||
|
||||
ronin.render.get_layer().clear();
|
||||
ronin.render.context().drawImage(ronin.frame.context().canvas,0,0,w,h);
|
||||
|
||||
ronin.frame.context().drawImage(ronin.render.context().canvas, -position.x, -position.y,w,h)
|
||||
|
||||
ronin.frame.context().drawImage(data,0,0,ronin.frame.size.width * ratio,ronin.frame.size.height * ratio);
|
||||
}
|
||||
|
||||
this.rotate = function(params, preview = false)
|
||||
{
|
||||
if(preview){ ronin.overlay.draw_pointer(params.position()); return; }
|
||||
if(!params.position()){ return; }
|
||||
|
||||
var position = params.position();
|
||||
var angle = params.angle().degrees;
|
||||
|
||||
var w = ronin.frame.size.width;
|
||||
var h = ronin.frame.size.height;
|
||||
|
||||
ronin.render.get_layer().clear();
|
||||
ronin.render.context().drawImage(ronin.frame.context().canvas,0,0,w,h);
|
||||
ronin.frame.active_layer.clear();
|
||||
|
||||
ronin.frame.context().save();
|
||||
ronin.frame.context().translate(position.x,position.y);
|
||||
ronin.frame.context().rotate(angle*Math.PI/180);
|
||||
|
||||
ronin.frame.context().drawImage(ronin.render.context().canvas, -position.x, -position.y,w,h)
|
||||
|
||||
ronin.frame.context().rotate(-angle*Math.PI/180);
|
||||
ronin.frame.context().restore();
|
||||
ronin.render.get_layer().clear();
|
||||
|
||||
return 1, "ok";
|
||||
}
|
||||
|
||||
this.translate = function(params,preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
if(!params.position()){ return; }
|
||||
|
||||
var data = this.data();
|
||||
this.clear();
|
||||
this.context().putImageData(data, params.position().x * 2, params.position().y * 2);
|
||||
ronin.overlay.get_layer(true).clear();
|
||||
|
||||
return 1, "ok";
|
||||
}
|
||||
|
||||
this.fill = function(params,preview = false)
|
||||
{
|
||||
if(!params.color()){ return 0, "Color?"; }
|
||||
if(preview){ return 0, "No Preview"; }
|
||||
|
||||
var rect = params.rect() ? params.rect() : new Rect(this.element.width+"x"+this.element.height);
|
||||
var position = params.position() ? params.position() : new Position("0,0");
|
||||
|
||||
this.context().beginPath();
|
||||
this.context().rect(position.x, position.y, rect.width, rect.height);
|
||||
this.context().fillStyle = params.color().hex;
|
||||
this.context().fill();
|
||||
|
||||
return 1, "ok";
|
||||
}
|
||||
|
||||
this.clear = function(params, preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
|
||||
this.context().clearRect(0, 0, this.element.width, this.element.height);
|
||||
}
|
||||
|
||||
this.resize = function(rect)
|
||||
{
|
||||
var pixels_rect = new Rect(this.element.width+"x"+this.element.height);
|
||||
|
||||
this.element.width = rect.width * 2;
|
||||
this.element.height = rect.height * 2;
|
||||
this.element.style.width = rect.width+"px";
|
||||
this.element.style.height = rect.height+"px";
|
||||
|
||||
this.context().scale(2,2);
|
||||
}
|
||||
|
||||
this.remove = function(manager)
|
||||
{
|
||||
manager.layer = null;
|
||||
ronin.frame.layers[this.name].element.outerHTML = "";
|
||||
delete ronin.frame.layers[this.name];
|
||||
}
|
||||
|
||||
this.context = function()
|
||||
{
|
||||
return this.element.getContext('2d');
|
||||
}
|
||||
|
||||
this.set_depth = function(depth)
|
||||
{
|
||||
this.depth = depth;
|
||||
this.element.setAttribute("z-index",depth);
|
||||
}
|
||||
|
||||
this.image = function()
|
||||
{
|
||||
return this.element.toDataURL('image/png');
|
||||
}
|
||||
|
||||
this.data = function()
|
||||
{
|
||||
return this.context().getImageData(0, 0, ronin.frame.size.width * 2, ronin.frame.size.height * 2);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
this.mouse_pointer = function(position)
|
||||
{
|
||||
return ronin.cursor.draw_pointer_arrow(position);
|
||||
}
|
||||
|
||||
this.mouse_mode = function()
|
||||
{
|
||||
return "Move";
|
||||
}
|
||||
|
||||
this.drag_from = null;
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
this.drag_from = ronin.cursor.position_in_window;
|
||||
}
|
||||
|
||||
this.mouse_move = function(position)
|
||||
{
|
||||
if(this.drag_from === null){ return; }
|
||||
|
||||
var offset = ronin.cursor.position_in_window.offset(this.drag_from);
|
||||
|
||||
var data = this.data();
|
||||
this.clear();
|
||||
this.context().putImageData(data, offset.x * 2, offset.y * 2);
|
||||
|
||||
this.drag_from = ronin.cursor.position_in_window;
|
||||
}
|
||||
|
||||
this.mouse_up = function(position)
|
||||
{
|
||||
this.drag_from = null;
|
||||
}
|
||||
|
||||
// Blink
|
||||
|
||||
this.is_blinking = false;
|
||||
|
||||
this.blink = function()
|
||||
{
|
||||
this.element.setAttribute("class","layer blink")
|
||||
}
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
function Magnet(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.size = new Rect("1x1");
|
||||
this.rate = new Position("4,4");
|
||||
|
||||
this.add_setting(new Setting("color","#000000"));
|
||||
|
||||
this.add_method(new Method("grid",["rect","position"]));
|
||||
this.add_method(new Method("clear",[]));
|
||||
|
||||
this.grid = function(cmd,preview = false)
|
||||
{
|
||||
if(!cmd.rect()){ return 0, "Rect?"; }
|
||||
|
||||
if(!this.layer){ this.create_layer(); }
|
||||
|
||||
this.layer.clear();
|
||||
this.draw_grid(cmd.rect(),cmd.position());
|
||||
|
||||
if(preview == false){
|
||||
if(cmd.rect()){ this.size = cmd.rect(); }
|
||||
if(cmd.position()){ this.rate = cmd.position(); }
|
||||
}
|
||||
|
||||
return 1, preview ? "preview" : "ok";
|
||||
}
|
||||
|
||||
this.clear = function(cmd,preview = false)
|
||||
{
|
||||
this.layer.clear();
|
||||
|
||||
this.size = new Rect("1x1");
|
||||
this.rate = this.rate;
|
||||
}
|
||||
|
||||
this.draw_grid = function(rect,position)
|
||||
{
|
||||
if(!rect){ rect = new Rect("20x20"); }
|
||||
if(!position){ position = new Position("4,4"); }
|
||||
|
||||
this.size = rect;
|
||||
this.rate = position;
|
||||
|
||||
if(rect.width < 5 || rect.height < 5){ return; }
|
||||
|
||||
var horizontal = ronin.frame.size.width/rect.width;
|
||||
var vertical = ronin.frame.size.height/rect.height;
|
||||
|
||||
for (var x = 1; x < horizontal; x++) {
|
||||
for (var y = 1; y < vertical; y++) {
|
||||
var dot_position = new Position(x * rect.width, y * rect.height);
|
||||
var size = 0.5;
|
||||
if(this.rate && x % this.rate.x == 0 && y % this.rate.y == 0){ size = 1; }
|
||||
this.draw_marker(dot_position,size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.draw_marker = function(position,size = 0.5)
|
||||
{
|
||||
this.context().beginPath();
|
||||
this.context().arc(position.x, position.y, size, 0, 2 * Math.PI, false);
|
||||
this.context().fillStyle = this.settings["color"].value;
|
||||
this.context().fill();
|
||||
this.context().closePath();
|
||||
}
|
||||
|
||||
this.magnetic_position = function(position)
|
||||
{
|
||||
var x = parseInt(position.x / this.size.width) * this.size.width;
|
||||
var y = parseInt(position.y / this.size.width) * this.size.width;
|
||||
|
||||
return new Position(x,y);
|
||||
}
|
||||
|
||||
this.update_mouse = function(position)
|
||||
{
|
||||
if(this.size.width > 4 || this.size.height > 4){
|
||||
if(!this.layer){ this.create_layer(); }
|
||||
this.layer.clear();
|
||||
this.draw_grid(this.size,this.rate);
|
||||
}
|
||||
|
||||
return this.magnetic_position(position);
|
||||
}
|
||||
|
||||
this.widget = function()
|
||||
{
|
||||
if(this.size.width < 2 || this.size.height < 2){ return ""; }
|
||||
return this.size.value;
|
||||
}
|
||||
|
||||
this.key_escape = function()
|
||||
{
|
||||
if(this.layer){ this.layer.remove(this); }
|
||||
}
|
||||
}
|
@ -1,167 +0,0 @@
|
||||
function Module(rune)
|
||||
{
|
||||
this.name = this.constructor.name.toLowerCase();
|
||||
this.rune = rune;
|
||||
this.element = null;
|
||||
this.settings = {};
|
||||
this.methods = {};
|
||||
this.modes = {};
|
||||
this.layer = null;
|
||||
this.is_locked = false;
|
||||
|
||||
this.docs = "Missing documentation.";
|
||||
|
||||
this.add_method = function(method)
|
||||
{
|
||||
method.host = this;
|
||||
this.methods[method.name] = method;
|
||||
}
|
||||
|
||||
this.add_setting = function(setting)
|
||||
{
|
||||
setting.host = this;
|
||||
this.settings[setting.name] = setting;
|
||||
}
|
||||
|
||||
this.add_mode = function(mode)
|
||||
{
|
||||
mode.host = this;
|
||||
this.modes[mode.name] = mode;
|
||||
}
|
||||
|
||||
this.install = function()
|
||||
{
|
||||
}
|
||||
|
||||
this.context = function()
|
||||
{
|
||||
return this.get_layer().context();
|
||||
}
|
||||
|
||||
this.create_layer = function(blink = false)
|
||||
{
|
||||
this.layer = new Layer(this.constructor.name+".Preview",this);
|
||||
this.layer.element.setAttribute("style","z-index:7000");
|
||||
if(blink){ this.layer.blink(); }
|
||||
ronin.frame.add_layer(this.layer);
|
||||
}
|
||||
|
||||
this.get_layer = function(is_blinking = false)
|
||||
{
|
||||
if(!this.layer){ this.create_layer(); this.layer.is_blinking = is_blinking }
|
||||
return this.layer;
|
||||
}
|
||||
|
||||
this.hint = function(method)
|
||||
{
|
||||
var html = "";
|
||||
|
||||
if(method){
|
||||
html += method;
|
||||
}
|
||||
else{
|
||||
for(id in this.methods){
|
||||
html += this.methods[id]+" ";
|
||||
}
|
||||
for(id in this.settings){
|
||||
html += this.settings[id]+" ";
|
||||
}
|
||||
for(mode in this.modes){
|
||||
html += this.modes[mode]+" ";
|
||||
}
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
this.pad = function(input)
|
||||
{
|
||||
var s = "";
|
||||
for (i = 0; i < input.length+1; i++){
|
||||
s += "_";
|
||||
}
|
||||
return "<span style='color:#000'>"+s+"</span>";
|
||||
}
|
||||
|
||||
this.widget = function()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
this.lock = function()
|
||||
{
|
||||
ronin.terminal.is_locked = true;
|
||||
}
|
||||
|
||||
this.unlock = function()
|
||||
{
|
||||
ronin.terminal.is_locked = false;
|
||||
}
|
||||
|
||||
// Mouse
|
||||
|
||||
this.mouse_mode = function()
|
||||
{
|
||||
for(mode_id in this.modes){
|
||||
if(!keyboard.shift_held && !keyboard.alt_held && !this.modes[mode_id].key){
|
||||
return this.modes[mode_id].name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
this.mouse_pointer = function(position)
|
||||
{
|
||||
return ronin.cursor.draw_pointer_arrow(position);
|
||||
}
|
||||
|
||||
this.mouse_from = null;
|
||||
this.mouse_held = null;
|
||||
this.mouse_prev = null;
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
}
|
||||
|
||||
this.mouse_move = function(position,rect)
|
||||
{
|
||||
}
|
||||
|
||||
this.mouse_up = function(position,rect)
|
||||
{
|
||||
}
|
||||
|
||||
// Keyboard
|
||||
|
||||
this.key_escape = function()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
this.key_delete = function()
|
||||
{
|
||||
}
|
||||
|
||||
this.key_arrow_up = function()
|
||||
{
|
||||
ronin.frame.layer_up();
|
||||
}
|
||||
|
||||
this.key_arrow_down = function()
|
||||
{
|
||||
ronin.frame.layer_down();
|
||||
}
|
||||
|
||||
this.key_arrow_left = function()
|
||||
{
|
||||
}
|
||||
|
||||
this.key_arrow_right = function()
|
||||
{
|
||||
}
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
return "<span class='module'>"+this.name+"</span>";
|
||||
}
|
||||
}
|
@ -1,221 +0,0 @@
|
||||
function Overlay(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.color = new Color("#ffffff");
|
||||
|
||||
// draw
|
||||
|
||||
this.draw = function(position,rect)
|
||||
{
|
||||
if(!this.layer){ this.create_layer(true); this.layer.is_blinking = true; }
|
||||
|
||||
if(!position){ position = new Position("0,0"); }
|
||||
|
||||
this.layer.clear();
|
||||
|
||||
if(rect){
|
||||
this.draw_rect(position,rect);
|
||||
}
|
||||
else if(position.x !== 0 && position.y !== 0){
|
||||
this.draw_pointer(position);
|
||||
}
|
||||
else if(position.x !== 0 ){
|
||||
this.draw_vertical_line(position);
|
||||
}
|
||||
else if(position.y !== 0 ){
|
||||
this.draw_horizontal_line(position);
|
||||
}
|
||||
}
|
||||
|
||||
this.draw_rect = function(position = new Position(0,0),rect)
|
||||
{
|
||||
if(!position || !rect){ return; }
|
||||
|
||||
this.context().beginPath();
|
||||
|
||||
position.normalize(rect);
|
||||
|
||||
this.context().moveTo(position.x,position.y);
|
||||
this.context().lineTo(position.x + rect.width,position.y);
|
||||
this.context().lineTo(position.x + rect.width,position.y + rect.height);
|
||||
this.context().lineTo(position.x,position.y + rect.height);
|
||||
this.context().lineTo(position.x,position.y);
|
||||
|
||||
// Limits
|
||||
this.context().moveTo(position.x + (rect.width/2),position.y-2);
|
||||
this.context().lineTo(position.x + (rect.width/2),position.y+2);
|
||||
this.context().moveTo(position.x + (rect.width/2),position.y + rect.height-2);
|
||||
this.context().lineTo(position.x + (rect.width/2),position.y + rect.height+2);
|
||||
this.context().moveTo(position.x + rect.width-2,position.y + (rect.height/2));
|
||||
this.context().lineTo(position.x + rect.width+2,position.y + (rect.height/2));
|
||||
this.context().moveTo(position.x+2,position.y + (rect.height/2));
|
||||
this.context().lineTo(position.x-2,position.y + (rect.height/2));
|
||||
|
||||
// Center
|
||||
var radius = 3;
|
||||
var radius_2 = 4;
|
||||
this.context().moveTo(position.x + (rect.width/2) + radius,position.y + (rect.height/2));
|
||||
this.context().lineTo(position.x + (rect.width/2) + radius_2,position.y + (rect.height/2));
|
||||
this.context().moveTo(position.x + (rect.width/2) - radius,position.y + (rect.height/2));
|
||||
this.context().lineTo(position.x + (rect.width/2) - radius_2,position.y + (rect.height/2));
|
||||
|
||||
this.context().moveTo(position.x + (rect.width/2),position.y + (rect.height/2) + radius);
|
||||
this.context().lineTo(position.x + (rect.width/2),position.y + (rect.height/2) + radius_2);
|
||||
this.context().moveTo(position.x + (rect.width/2),position.y + (rect.height/2) - radius);
|
||||
this.context().lineTo(position.x + (rect.width/2),position.y + (rect.height/2) - radius_2);
|
||||
|
||||
this.context().lineCap="square";
|
||||
this.context().lineWidth = 2;
|
||||
this.context().strokeStyle = "#000000";
|
||||
this.context().stroke();
|
||||
|
||||
this.context().lineCap="round";
|
||||
this.context().lineWidth = 1;
|
||||
this.context().strokeStyle = "#ffffff";
|
||||
this.context().stroke();
|
||||
|
||||
this.context().closePath();
|
||||
}
|
||||
|
||||
this.draw_pointer = function(position)
|
||||
{
|
||||
this.context().beginPath();
|
||||
|
||||
this.context().moveTo(position.x + 2,position.y);
|
||||
this.context().lineTo(position.x + 5,position.y);
|
||||
this.context().moveTo(position.x,position.y + 2);
|
||||
this.context().lineTo(position.x,position.y + 5);
|
||||
this.context().moveTo(position.x - 2,position.y);
|
||||
this.context().lineTo(position.x - 5,position.y);
|
||||
this.context().moveTo(position.x,position.y - 2);
|
||||
this.context().lineTo(position.x,position.y - 5);
|
||||
|
||||
this.context().lineCap="square";
|
||||
this.context().lineWidth = 2;
|
||||
this.context().strokeStyle = "#000000";
|
||||
this.context().stroke();
|
||||
|
||||
this.context().lineCap="round";
|
||||
this.context().lineWidth = 1;
|
||||
this.context().strokeStyle = "#ffffff";
|
||||
this.context().stroke();
|
||||
|
||||
this.context().closePath();
|
||||
}
|
||||
|
||||
this.draw_line = function(position,to)
|
||||
{
|
||||
this.context().beginPath();
|
||||
|
||||
this.context().moveTo(position.x,position.y);
|
||||
this.context().lineTo(to.x,to.y);
|
||||
|
||||
this.context().lineCap="square";
|
||||
this.context().lineWidth = 2;
|
||||
this.context().strokeStyle = "#000000";
|
||||
this.context().stroke();
|
||||
|
||||
this.context().lineCap="round";
|
||||
this.context().lineWidth = 1;
|
||||
this.context().strokeStyle = "#ffffff";
|
||||
this.context().stroke();
|
||||
|
||||
this.context().closePath();
|
||||
}
|
||||
|
||||
this.draw_circle = function(position,radius = 5)
|
||||
{
|
||||
this.context().beginPath();
|
||||
this.context().arc(position.x, position.y, radius, 0, 2 * Math.PI, false);
|
||||
|
||||
this.context().lineCap="square";
|
||||
this.context().lineWidth = 2;
|
||||
this.context().strokeStyle = "#000000"
|
||||
this.context().stroke();
|
||||
|
||||
this.context().lineCap="round";
|
||||
this.context().lineWidth = 1;
|
||||
this.context().strokeStyle = "#ffffff"
|
||||
this.context().stroke();
|
||||
|
||||
this.context().closePath();
|
||||
}
|
||||
|
||||
this.draw_cross = function(position,radius = 5)
|
||||
{
|
||||
this.context().beginPath();
|
||||
|
||||
this.context().moveTo(position.x+(radius-2),position.y);
|
||||
this.context().lineTo(position.x+radius,position.y);
|
||||
this.context().moveTo(position.x-(radius-2),position.y);
|
||||
this.context().lineTo(position.x-radius,position.y);
|
||||
this.context().moveTo(position.x,position.y+(radius-2));
|
||||
this.context().lineTo(position.x,position.y+radius);
|
||||
this.context().moveTo(position.x,position.y-(radius-2));
|
||||
this.context().lineTo(position.x,position.y-radius);
|
||||
|
||||
this.context().lineCap="square";
|
||||
this.context().lineWidth = 2;
|
||||
this.context().strokeStyle = "#000000"
|
||||
this.context().stroke();
|
||||
|
||||
this.context().lineCap="round";
|
||||
this.context().lineWidth = 1;
|
||||
this.context().strokeStyle = "#ffffff"
|
||||
this.context().stroke();
|
||||
|
||||
this.context().closePath();
|
||||
}
|
||||
|
||||
this.draw_vertical_line = function(position)
|
||||
{
|
||||
this.context().beginPath();
|
||||
|
||||
this.context().moveTo(position.x,0);
|
||||
this.context().lineTo(position.x,ronin.frame.size.height);
|
||||
|
||||
this.context().lineCap="square";
|
||||
this.context().lineWidth = 2;
|
||||
this.context().strokeStyle = "#000000"
|
||||
this.context().stroke();
|
||||
|
||||
|
||||
this.context().lineCap="round";
|
||||
this.context().lineWidth = 1;
|
||||
this.context().strokeStyle = "#ffffff"
|
||||
this.context().stroke();
|
||||
|
||||
this.context().closePath();
|
||||
}
|
||||
|
||||
this.draw_horizontal_line = function(position)
|
||||
{
|
||||
this.context().beginPath();
|
||||
|
||||
this.context().moveTo(0,position.y);
|
||||
this.context().lineTo(ronin.frame.size.width,position.y);
|
||||
|
||||
this.context().lineCap="square";
|
||||
this.context().lineWidth = 2;
|
||||
this.context().strokeStyle = "#000000"
|
||||
this.context().stroke();
|
||||
|
||||
this.context().lineCap="round";
|
||||
this.context().lineWidth = 1;
|
||||
this.context().strokeStyle = "#ffffff"
|
||||
this.context().stroke();
|
||||
|
||||
this.context().closePath();
|
||||
}
|
||||
|
||||
this.clear = function()
|
||||
{
|
||||
this.layer.remove(this);
|
||||
}
|
||||
|
||||
this.key_escape = function()
|
||||
{
|
||||
if(this.layer){ this.layer.remove(this); }
|
||||
}
|
||||
}
|
@ -1,149 +0,0 @@
|
||||
function Path(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.add_mode(new Mode("stroke"));
|
||||
this.add_mode(new Mode("arc","shift"));
|
||||
this.add_mode(new Mode("arc_cc","alt"));
|
||||
this.add_mode(new Mode("stem","shift_alt"));
|
||||
|
||||
this.add_setting(new Setting("fill_color","#ff0000"));
|
||||
this.add_setting(new Setting("line_width","3"));
|
||||
this.add_setting(new Setting("line_color","#ffffff"));
|
||||
this.add_setting(new Setting("line_cap","square"));
|
||||
|
||||
this.add_method(new Method("stroke",["Positions"]));
|
||||
this.add_method(new Method("fill",["Positions"]));
|
||||
|
||||
this.coordinates = [];
|
||||
this.last_pos = null;
|
||||
this.paths = [];
|
||||
|
||||
this.stroke = function(cmd,preview = false)
|
||||
{
|
||||
if(!ronin.path.layer){ ronin.path.create_layer(); ronin.path.layer.is_blinking = true; }
|
||||
|
||||
this.layer.clear();
|
||||
|
||||
var context = preview ? this.context() : ronin.frame.context();
|
||||
|
||||
context.beginPath();
|
||||
context.lineCap = this.settings["line_cap"].value;
|
||||
context.lineWidth = this.settings["line_width"].value;
|
||||
context.strokeStyle = this.settings["line_color"].value;
|
||||
context.stroke(new Path2D(cmd.values()));
|
||||
context.closePath();
|
||||
|
||||
if(!preview){ this.coordinates = []; this.last_pos = null; if(!preview){ this.layer.remove(this); } }
|
||||
|
||||
return 1, preview ? "preview" : "ok";
|
||||
}
|
||||
|
||||
this.fill = function(cmd,preview = false)
|
||||
{
|
||||
if(!ronin.path.layer){ ronin.path.create_layer(); ronin.path.layer.is_blinking = true; }
|
||||
|
||||
this.layer.clear();
|
||||
|
||||
var context = preview ? this.context() : ronin.frame.context();
|
||||
|
||||
context.beginPath();
|
||||
context.fillStyle = this.settings["fill_color"].value;
|
||||
context.fill(new Path2D(cmd.values()));
|
||||
context.closePath();
|
||||
|
||||
if(!preview){ this.coordinates = []; this.last_pos = null; }
|
||||
|
||||
return 1, preview ? "preview" : "ok";
|
||||
}
|
||||
|
||||
// Tools
|
||||
|
||||
this.create_path = function()
|
||||
{
|
||||
var command = "";
|
||||
|
||||
for (var i = 0; i < this.coordinates.length; i++) {
|
||||
command += this.coordinates[i]+" ";
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
this.create_svg = function()
|
||||
{
|
||||
var s = "";
|
||||
for (var i = 0; i < this.paths.length; i++) {
|
||||
s += "<path d='"+this.paths[i]+"' />";
|
||||
}
|
||||
return "<svg width='"+ronin.frame.size.width+"' height='"+ronin.frame.size.height+"' xmlns='http://www.w3.org/2000/svg' baseProfile='full' version='1.1' style='fill:none;stroke:red;stroke-width:2px;stroke-linecap:square;'>"+s+"</svg>";
|
||||
}
|
||||
|
||||
// Mouse
|
||||
|
||||
this.mouse_mode = function()
|
||||
{
|
||||
if(keyboard.shift_held == true && keyboard.alt_held == true){
|
||||
return "Path(Origin)";
|
||||
}
|
||||
else if(keyboard.shift_held == true){
|
||||
return "Path(Counterclock Arc)";
|
||||
}
|
||||
else if(keyboard.alt_held == true){
|
||||
return "Path(Clockwise Arc)";
|
||||
}
|
||||
else{
|
||||
return "Path(Line)";
|
||||
}
|
||||
}
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
var method = ronin.terminal.cmd().method() ? ronin.terminal.cmd().method().name : "stroke";
|
||||
var line = "path."+method+" "+this.create_path();
|
||||
line += "M"+position.toString();
|
||||
ronin.terminal.update(line);
|
||||
}
|
||||
|
||||
this.mouse_move = function(position)
|
||||
{
|
||||
var method = ronin.terminal.cmd().method().name;
|
||||
var line = "path."+method+" "+this.create_path();
|
||||
line += "L"+position.toString();
|
||||
ronin.terminal.update(line);
|
||||
}
|
||||
|
||||
this.mouse_up = function(position)
|
||||
{
|
||||
var method = ronin.terminal.cmd().method().name;
|
||||
|
||||
if(this.coordinates.length == 0){
|
||||
this.coordinates.push("M"+position.toString());
|
||||
}
|
||||
else{
|
||||
var offset = this.last_pos ? position.offset(this.last_pos) : position;
|
||||
|
||||
if(keyboard.shift_held == true && keyboard.alt_held == true){
|
||||
this.coordinates.push("M"+position.toString());
|
||||
}
|
||||
else if(keyboard.shift_held == true){
|
||||
this.coordinates.push("a"+offset.toString()+" 0 0,1 "+offset.toString());
|
||||
}
|
||||
else if(keyboard.alt_held == true){
|
||||
this.coordinates.push("a"+offset.toString()+" 0 0,0 "+offset.toString());
|
||||
}
|
||||
else{
|
||||
this.coordinates.push("l"+offset.toString());
|
||||
}
|
||||
}
|
||||
|
||||
ronin.terminal.update("path."+method+" "+this.create_path());
|
||||
this.last_pos = position;
|
||||
}
|
||||
|
||||
this.key_escape = function()
|
||||
{
|
||||
if(this.layer){ this.layer.remove(this); }
|
||||
this.coordinates = [];
|
||||
this.last_pos = null;
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
function Render(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.filters = {};
|
||||
|
||||
this.add_method(new Method("balance",["color"]));
|
||||
this.add_method(new Method("stencil",["angle","color"]));
|
||||
this.add_method(new Method("chromatic",["position","float"]));
|
||||
|
||||
this.filters["balance"] = new Filter_Balance();
|
||||
this.filters["grey"] = new Filter_Grey();
|
||||
this.filters["stencil"] = new Filter_Stencil();
|
||||
this.filters["invert"] = new Filter_Invert();
|
||||
this.filters["chromatic"] = new Filter_Chromatic();
|
||||
this.filters["sharpen"] = new Filter_Sharpen();
|
||||
this.filters["saturate"] = new Filter_Saturate();
|
||||
this.filters["contrast"] = new Filter_Contrast();
|
||||
|
||||
this.stencil = function(cmd,preview = false)
|
||||
{
|
||||
var f = new Filter_Stencil();
|
||||
|
||||
if(preview){ f.preview(cmd); }
|
||||
else{ f.render(cmd); }
|
||||
}
|
||||
|
||||
this.chromatic = function(cmd,preview = false)
|
||||
{
|
||||
var f = new Filter_Chromatic();
|
||||
|
||||
if(preview){ f.preview(cmd); }
|
||||
else{ f.render(cmd); }
|
||||
|
||||
return "Done.";
|
||||
}
|
||||
}
|
@ -1,147 +0,0 @@
|
||||
function Source(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.modal_element = null;
|
||||
|
||||
this.add_setting(new Setting("format","png"));
|
||||
this.add_setting(new Setting("quality","1"));
|
||||
|
||||
this.add_method(new Method("save",["name","rect","format"]));
|
||||
this.add_method(new Method("load",["path","position","rect"]));
|
||||
this.add_method(new Method("help"));
|
||||
|
||||
this.install = function()
|
||||
{
|
||||
this.modal_element = document.createElement("modal");
|
||||
this.modal_element.id = "modal";
|
||||
this.modal_element.setAttribute("class","hidden");
|
||||
ronin.element.appendChild(this.modal_element);
|
||||
}
|
||||
|
||||
this.load = function(params,preview = false) // source.load /01.jpg 0,0 100x100
|
||||
{
|
||||
if(!params.filepath()){ return 0, "Path?"; }
|
||||
if(!params.rect()){ return 0,"Rect?"; }
|
||||
|
||||
var position = params.position() ? params.position() : new Position("0,0");
|
||||
var rect = params.rect() ? params.rect() : new Rect("50,50");
|
||||
|
||||
ronin.overlay.draw(position,rect);
|
||||
|
||||
if(preview){ return; }
|
||||
if(this.is_locked){ console.log("Locked!"); return 0,"The source module is locked."; }
|
||||
|
||||
this.lock();
|
||||
|
||||
base_image = new Image();
|
||||
base_image.src = "../assets/"+params.filepath().path;
|
||||
base_image.src += '?'+new Date().getTime();
|
||||
base_image.crossOrigin = "Anonymous";
|
||||
|
||||
base_image.onload = function(){
|
||||
var width = base_image.naturalWidth;
|
||||
var height = base_image.naturalHeight;
|
||||
if(params.rect()){
|
||||
width = params.rect().width;
|
||||
height = params.rect().height;
|
||||
position.normalize(params.rect());
|
||||
}
|
||||
// Scale with only 1 unit
|
||||
width = isNaN(width) && height > 0 ? (height*base_image.naturalWidth)/base_image.naturalHeight : width;
|
||||
height = isNaN(height) && width > 0 ? (width*base_image.naturalHeight)/base_image.naturalWidth : height;
|
||||
|
||||
ronin.frame.active_layer.context().drawImage(base_image, position.x, position.y, width, height);
|
||||
ronin.overlay.clear();
|
||||
ronin.source.unlock();
|
||||
}
|
||||
|
||||
return 1,"Loaded "+params.filepath().path+" at "+position.toString();
|
||||
}
|
||||
|
||||
this.save = function(params,preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
if(!this.layer){ this.create_layer(); }
|
||||
|
||||
var d = null;
|
||||
|
||||
this.modal();
|
||||
|
||||
if(this.settings["format"].value == "jpg"){
|
||||
this.modal("image","<img src='"+this.merge().element.toDataURL('image/jpeg',this.settings["quality"].to_f())+"' />");
|
||||
}
|
||||
else{
|
||||
this.modal("image","<img src='"+this.merge().element.toDataURL('image/png')+"'/>");
|
||||
}
|
||||
/*
|
||||
if(params.setting("format") && params.setting("format").value == "svg"){
|
||||
ronin.terminal.log(new Log(this,ronin.path.create_svg(),"image"));
|
||||
}
|
||||
else if(params.setting("format") && params.setting("format").value == "rin"){
|
||||
var w = window.open('about:blank','source');
|
||||
var html = "";
|
||||
for (i = 0; i < ronin.terminal.history.length; i++) { html += ronin.terminal.history[i]+";<br />"; }
|
||||
w.document.write("<title>Source</title><pre>"+html+"</pre>");
|
||||
}
|
||||
else
|
||||
*/
|
||||
|
||||
this.layer.remove(this);
|
||||
|
||||
return 1,"Rendered the "+this.settings.format+" image, "+this.settings.quality+"."
|
||||
}
|
||||
|
||||
this.help = function(params,preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
|
||||
html = "";
|
||||
|
||||
for(module_id in ronin.modules){
|
||||
html += ronin.modules[module_id]+"\n";
|
||||
|
||||
for(mode_id in ronin.modules[module_id].modes){
|
||||
html += " "+ronin.modules[module_id].modes[mode_id]+"\n";
|
||||
}
|
||||
for(setting_id in ronin.modules[module_id].settings){
|
||||
html += " "+ronin.modules[module_id].settings[setting_id]+"\n";
|
||||
}
|
||||
for(method_id in ronin.modules[module_id].methods){
|
||||
html += " "+ronin.modules[module_id].methods[method_id]+"\n";
|
||||
}
|
||||
}
|
||||
|
||||
this.modal("text",html);
|
||||
}
|
||||
|
||||
this.modal = function(type,content)
|
||||
{
|
||||
this.modal_element.setAttribute("class",type);
|
||||
this.modal_element.innerHTML = content;
|
||||
}
|
||||
|
||||
this.merge = function()
|
||||
{
|
||||
var a = [];
|
||||
for(layer_name in ronin.frame.layers){
|
||||
if(ronin.frame.layers[layer_name].manager){ continue; }
|
||||
a.push(ronin.frame.layers[layer_name]);
|
||||
}
|
||||
for (i = 0; i < a.length; i++) {
|
||||
this.layer.context().drawImage(a[i].context().canvas,0,0,ronin.frame.size.width,ronin.frame.size.height);
|
||||
}
|
||||
return this.layer;
|
||||
}
|
||||
|
||||
this.key_escape = function()
|
||||
{
|
||||
if(this.layer){ this.layer.remove(this); }
|
||||
this.coordinates = [];
|
||||
this.last_pos = null;
|
||||
ronin.terminal.input.value = "";
|
||||
|
||||
this.modal_element.innerHTML = "";
|
||||
this.modal_element.setAttribute("class","hidden");
|
||||
}
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
function Terminal(rune)
|
||||
{
|
||||
Module.call(this);
|
||||
|
||||
this.element = document.createElement("div");
|
||||
this.input = document.createElement("input");
|
||||
this.hint_element = document.createElement("div");
|
||||
this.logs_element = document.createElement("div");
|
||||
this.hint_element.id = "hint";
|
||||
this.logs_element.id = "logs";
|
||||
this.logs_element.innerHTML = "<log>Hello there</log>";
|
||||
|
||||
this.history = [];
|
||||
this.locks = [];
|
||||
|
||||
this.add_method(new Method("load",["file_name.rin"]));
|
||||
|
||||
// Module
|
||||
this.install = function(cmd)
|
||||
{
|
||||
this.element.appendChild(this.input);
|
||||
this.element.appendChild(this.hint_element);
|
||||
this.element.appendChild(this.logs_element);
|
||||
|
||||
this.input.value = ""
|
||||
this.hint_element.innerHTML = "";
|
||||
}
|
||||
|
||||
this.run = function(target_cmd)
|
||||
{
|
||||
var command = target_cmd ? target_cmd : this.cmd();
|
||||
var module = command.module();
|
||||
var method = command.method();
|
||||
var setting = command.setting();
|
||||
|
||||
console.info(command.content); // Don't remove
|
||||
|
||||
if(method){
|
||||
method.run(command);
|
||||
}
|
||||
if(setting){
|
||||
module.settings[setting].update(command.values());
|
||||
this.log(new Log(module,module.settings[setting]));
|
||||
}
|
||||
this.hint_element.innerHTML = "";
|
||||
this.input.value = "";
|
||||
this.update();
|
||||
}
|
||||
|
||||
this.update = function(value = null, preview = true)
|
||||
{
|
||||
if(value){ this.input.value = value; this.input.focus(); }
|
||||
|
||||
var command = this.cmd();
|
||||
var module = command.module();
|
||||
var method = command.method();
|
||||
var autocomplete = this.find_autocomplete(command,module,method);
|
||||
|
||||
if(method && preview){
|
||||
method.preview(command);
|
||||
}
|
||||
|
||||
this.hint_element.innerHTML = "<span class='input'>"+this.input.value+"</span>"+(autocomplete ? '<span class="autocomplete">'+autocomplete+'</span>' : '')+(this.input.value ? " > " : "")+(module ? module.hint(method) : ronin.hint(method));
|
||||
ronin.cursor.update();
|
||||
}
|
||||
|
||||
this.run_multi = function(lines)
|
||||
{
|
||||
lines = lines.split(";");
|
||||
if(!ronin.terminal.is_locked){
|
||||
target_line = lines.shift();
|
||||
this.run(new Command(target_line));
|
||||
}
|
||||
|
||||
if(lines.length > 0){ setTimeout(function(){ ronin.terminal.run_multi(lines.join(";")) }, 50); }
|
||||
}
|
||||
|
||||
this.log = function(log)
|
||||
{
|
||||
this.logs_element.innerHTML = "";
|
||||
this.logs_element.appendChild(log.element);
|
||||
}
|
||||
|
||||
this.cmd = function()
|
||||
{
|
||||
return new Command(this.input.value);
|
||||
}
|
||||
|
||||
this.load = function(cmd,preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
|
||||
ronin.load(cmd.values());
|
||||
|
||||
return "Loading "+cmd.values();
|
||||
}
|
||||
|
||||
this.find_autocomplete = function()
|
||||
{
|
||||
html = ""
|
||||
|
||||
var entry = this.input.value;
|
||||
var module = this.cmd().module();
|
||||
var method = entry.indexOf(".") > -1 ? entry.split(".")[1] : null;
|
||||
|
||||
if(entry.length == 0){ return null; }
|
||||
|
||||
if(module && method){
|
||||
for(id in module.methods){
|
||||
if(method == module.methods[id].name){ break; }
|
||||
if(method == module.methods[id].name.substr(0,method.length)){ return module.methods[id].name.replace(method,""); }
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(id in ronin.modules){
|
||||
if(entry == ronin.modules[id].name){ break; }
|
||||
if(entry == ronin.modules[id].name.substr(0,entry.length)){ return ronin.modules[id].name.replace(entry,""); }
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Log
|
||||
|
||||
function Log(host = null,message,error = false)
|
||||
{
|
||||
this.host = host;
|
||||
this.message = message;
|
||||
this.error = error;
|
||||
this.element = document.createElement("log");
|
||||
this.element.setAttribute("class",error ? "error" : "okay");
|
||||
this.element.innerHTML = "<span class='module'>"+(this.host ? this.host.name : "Ronin")+"</span> "+message;
|
||||
console.log(this.host ? this.host.name : "Ronin",this.message);
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
function Widget(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.element = document.createElement("div");
|
||||
this.element.setAttribute("id","widget");
|
||||
|
||||
this.install = function()
|
||||
{
|
||||
ronin.terminal.element.appendChild(this.element);
|
||||
}
|
||||
|
||||
this.update = function()
|
||||
{
|
||||
var html = "";
|
||||
for (var key in ronin.modules){
|
||||
html += ronin.modules[key].widget() ? ronin.modules[key].widget()+" " : "";
|
||||
}
|
||||
this.element.innerHTML = html;
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
function Type(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.add_method(new Method("write",["Position","Text"]));
|
||||
this.add_mode(new Mode("write"));
|
||||
this.add_setting(new Setting("color","#000000"));
|
||||
this.add_setting(new Setting("size","40"));
|
||||
this.add_setting(new Setting("font","DIN Medium"));
|
||||
|
||||
this.write = function(cmd,preview = false)
|
||||
{
|
||||
if(!this.layer){ this.create_layer(true); this.layer.is_blinking = true; }
|
||||
|
||||
this.layer.clear();
|
||||
|
||||
var text = cmd.text() ? cmd.text() : "Text";
|
||||
var position = cmd.position() ? cmd.position() : new Position(40,80);
|
||||
var color = this.settings["color"].value;
|
||||
var size = parseFloat(this.settings["size"].value);
|
||||
var font = this.settings["font"].value;
|
||||
|
||||
var target_layer = preview ? this.layer : ronin.frame.active_layer;
|
||||
target_layer.context().font = size+"px "+font;
|
||||
target_layer.context().fillStyle = color;
|
||||
target_layer.context().fillText(text,position.x,position.y);
|
||||
|
||||
if(!preview){ this.layer.remove(this); }
|
||||
|
||||
return 1, "Wrote "+text+" at "+position.toString();
|
||||
}
|
||||
|
||||
// Mouse
|
||||
|
||||
this.mouse_mode = function()
|
||||
{
|
||||
return "Write";
|
||||
}
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
var str = ronin.terminal.cmd().text() ? ronin.terminal.cmd().text() : "Text";
|
||||
var line = "type.write "+position.toString()+" \""+str+"\"";
|
||||
ronin.terminal.update(line);
|
||||
}
|
||||
|
||||
this.mouse_move = function(position,rect)
|
||||
{
|
||||
}
|
||||
|
||||
this.mouse_up = function(position)
|
||||
{
|
||||
var str = ronin.terminal.cmd().text() ? ronin.terminal.cmd().text() : "Text";
|
||||
var line = "type.write "+position.toString()+" \""+str+"\"";
|
||||
ronin.terminal.update(line);
|
||||
}
|
||||
|
||||
this.key_escape = function()
|
||||
{
|
||||
if(this.layer){ this.layer.remove(this); }
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
function Angle(angle_str = "0'")
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "45'";
|
||||
|
||||
this.degrees = parseFloat(angle_str.replace('\'',''));
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
return this.degrees+"'";
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
function Any(str)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "";
|
||||
this.string = str;
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
return this.string;
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
function Bang()
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "";
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
return "BANG";
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
function Color(hex = '#000000')
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "#ff0000";
|
||||
this.hex = hex;
|
||||
|
||||
this.rgb = function()
|
||||
{
|
||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(this.hex);
|
||||
return result ? {
|
||||
r: parseInt(result[1], 16),
|
||||
g: parseInt(result[2], 16),
|
||||
b: parseInt(result[3], 16)
|
||||
} : null;
|
||||
}
|
||||
|
||||
this.rgba = function()
|
||||
{
|
||||
return "rgba("+this.rgb().r+","+this.rgb().g+","+this.rgb().b+",1)";
|
||||
}
|
||||
|
||||
this.floats = function()
|
||||
{
|
||||
var rgb = this.rgb();
|
||||
return { r:rgb.r/255, g:rgb.g/255, b:rgb.b/255 }
|
||||
}
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
return this.hex;
|
||||
}
|
||||
|
||||
this.rgb_to_hex = function(rgb)
|
||||
{
|
||||
return "#"+parseInt(rgb.r,10).toString(16)+parseInt(rgb.g,10).toString(16)+parseInt(rgb.b,10).toString(16);
|
||||
}
|
||||
|
||||
this.brightness = function()
|
||||
{
|
||||
return this.rgb() ? (this.rgb().r + this.rgb().g + this.rgb().b)/3 : 0;
|
||||
}
|
||||
|
||||
this.style = function()
|
||||
{
|
||||
return this.brightness() > 150 ? "bright" : "dark";
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
function Filepath(path_str)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "assets/demo.png";
|
||||
this.path = path_str;
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
return this.path;
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
function Method(name,params,options = null)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.host = null;
|
||||
this.name = name;
|
||||
this.params = params;
|
||||
this.options = options;
|
||||
this.example = "";
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
var params_str = "";
|
||||
for(param in this.params){
|
||||
params_str += this.params[param]+","
|
||||
}
|
||||
params_str = params_str.substr(0,params_str.length-1);
|
||||
|
||||
var options_str = "";
|
||||
for(option in this.options){
|
||||
options_str += this.options[option]+","
|
||||
}
|
||||
options_str = options_str.substr(0,options_str.length-1);
|
||||
|
||||
return "<span class='method'>.<span class='name'>"+this.name+"</span> "+params_str+(this.options ? ' <span class=\'options\'>['+options_str+']</span>' : '')+"</span>";
|
||||
}
|
||||
|
||||
this.preview = function(cmd)
|
||||
{
|
||||
return this.host[this.name] ? this.host[this.name](cmd,true) : "";
|
||||
}
|
||||
|
||||
this.run = function(cmd)
|
||||
{
|
||||
return this.host[this.name] ? ronin.terminal.log(new Log(this.host,this.host[this.name](cmd,false))) : null;
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
function Mode(name,key = null)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.host = null;
|
||||
this.name = name;
|
||||
this.key = key;
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
return "<span class='mode'><span class='name'>~"+this.name+"</span>"+(this.key ? ' <span class="key">'+this.key+'</span>' : '')+"</span>"
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
function Option(name)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.name = name.split("=")[0];
|
||||
this.value = name.split("=")[1];
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
function Position(position_str = "0,0",y = null)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "100,150";
|
||||
this.position_str = position_str;
|
||||
|
||||
this.x = y != null ? position_str : parseFloat(position_str.split(",")[0]);
|
||||
this.y = y != null ? y : parseFloat(position_str.split(",")[1]);
|
||||
|
||||
this.add = function(position)
|
||||
{
|
||||
return new Position(this.x + position.x, this.y + position.y);
|
||||
}
|
||||
|
||||
this.is_equal = function(target)
|
||||
{
|
||||
if(target.x == this.x && target.y == this.y){ return true; }
|
||||
return null;
|
||||
}
|
||||
|
||||
this.distance_to = function(target)
|
||||
{
|
||||
if(!target){ return 0; }
|
||||
return Math.sqrt( (this.x-target.x)*(this.x-target.x) + (this.y-target.y)*(this.y-target.y) );
|
||||
}
|
||||
|
||||
this.offset = function(position = new Position(0,0))
|
||||
{
|
||||
return new Position(this.x - position.x,this.y - position.y);
|
||||
}
|
||||
|
||||
this.normalize = function(rect)
|
||||
{
|
||||
if(this.x == null){
|
||||
this.x = ronin.canvas.element.width - rect.width - Math.abs(this.x);
|
||||
}
|
||||
if(this.y == null){
|
||||
this.y = ronin.canvas.element.height - rect.height - Math.abs(this.y);
|
||||
}
|
||||
}
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
return (isNaN(this.x) ? 0 : this.x)+","+(isNaN(this.y) ? 0 : this.y);
|
||||
}
|
||||
|
||||
this.is_outside = function()
|
||||
{
|
||||
if(this.x < 0){ return true; }
|
||||
if(this.y < 0){ return true; }
|
||||
if(this.x > ronin.frame.element.width/2){ return true; }
|
||||
if(this.y > ronin.frame.element.height/2){ return true; }
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
function Range(range_str)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "10..50";
|
||||
this.range_str = range_str;
|
||||
|
||||
this.from = parseFloat(this.range_str.split("..")[0]);
|
||||
this.to = parseFloat(this.range_str.split("..")[1]);
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
return this.from+".."+this.to;
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
function Rect(rect_str)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.rect_str = rect_str;
|
||||
|
||||
this.width = rect_str ? parseFloat(this.rect_str.split("x")[0]) : 0;
|
||||
this.height = rect_str ? parseFloat(this.rect_str.split("x")[1]) : 0;
|
||||
|
||||
this.example = "200x300";
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
return (isNaN(this.width) ? 0 : this.width)+"x"+(isNaN(this.height) ? 0 : this.height);
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
function Setting(name,value)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.host = null;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
return "?";
|
||||
}
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
return "<span class='setting'>:"+this.name+(this.value ? ' <span class="value">'+this.value+'</span>' : '')+"</span>"
|
||||
}
|
||||
|
||||
this.update = function(value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
this.to_f = function()
|
||||
{
|
||||
return parseFloat(this.value);
|
||||
}
|
||||
|
||||
this.to_rect = function()
|
||||
{
|
||||
return new Rect(this.value);
|
||||
}
|
||||
|
||||
this.to_pos = function()
|
||||
{
|
||||
return new Position(this.value);
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
function Unit()
|
||||
{
|
||||
this.example = "unknown";
|
||||
this.name = this.constructor.name;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
function Value(value_str)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "20";
|
||||
this.value = value_str;
|
||||
this.float = parseFloat(this.value);
|
||||
this.int = parseInt(this.value);
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@
|
||||
<script type="text/javascript" src="scripts/layers/render.js"></script>
|
||||
|
||||
<script type="text/javascript" src="scripts/docs.js"></script>
|
||||
<script type="text/javascript" src="scripts/port.js"></script>
|
||||
<script type="text/javascript" src="scripts/io.js"></script>
|
||||
<script type="text/javascript" src="scripts/query.js"></script>
|
||||
<script type="text/javascript" src="scripts/keyboard.js"></script>
|
||||
@ -27,7 +28,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
const {dialog,app} = require('electron').remote;
|
||||
const fs = require('fs');
|
||||
const app_path = app.getAppPath();
|
||||
|
@ -25,7 +25,7 @@ function Docs()
|
||||
this.print_intro = function()
|
||||
{
|
||||
html = "# Ronin\n";
|
||||
html += "Ronin is a simple open-source graphic design tool.\n";
|
||||
html += "Ronin is a simple open-source graphic design tool.\n\n";
|
||||
html += "<img src='https://raw.githubusercontent.com/hundredrabbits/Ronin/master/PREVIEW.jpg' width='600'/>\n";
|
||||
return html;
|
||||
}
|
||||
@ -61,7 +61,7 @@ function Docs()
|
||||
|
||||
for(method_name in methods){
|
||||
var method_val = methods[method_name];
|
||||
html += "- `"+method_name+"`, no details.\n";
|
||||
html += "- `"+method_name+":`, no details.\n";
|
||||
}
|
||||
return html;
|
||||
}
|
||||
@ -71,8 +71,9 @@ function Docs()
|
||||
var html = "### Ports\n";
|
||||
|
||||
for(port_name in ports){
|
||||
var port_val = ports[setting_name];
|
||||
html += "- `"+port_name+"`, no details.\n";
|
||||
var port = ports[port_name];
|
||||
console.log(ports);
|
||||
html += "- `->"+port.name+"`{"+port.input+","+port.output+"}, **"+port.value+"/"+port.max+"** "+port.docs+".\n";
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
@ -6,20 +6,17 @@ function Brush()
|
||||
|
||||
this.pointers = [
|
||||
new Pointer({offset:{x:0,y:0}}),
|
||||
// new Pointer({offset:{x:1,y:0}}),
|
||||
// new Pointer({offset:{x:-1,y:0}}),
|
||||
// new Pointer({offset:{x:0,y:1}}),
|
||||
// new Pointer({offset:{x:0,y:-1}}),
|
||||
new Pointer({offset:{x:2,y:2}}),
|
||||
new Pointer({offset:{x:4,y:4}}),
|
||||
];
|
||||
|
||||
this.ports.speed = 0;
|
||||
this.ports.distance = 0;
|
||||
this.ports.red = 0;
|
||||
this.ports.green = 0;
|
||||
this.ports.blue = 0;
|
||||
this.ports.alpha = 1;
|
||||
this.ports.x = 1;
|
||||
this.ports.noise = 0;
|
||||
this.ports = {};
|
||||
|
||||
this.ports.speed = new Port("speed",false,true,0,50,"The cursor speed");
|
||||
this.ports.distance = new Port("distance",false,true,0,null,"The cursor distance");
|
||||
this.ports.red = new Port("red",true,true,0,255,"The brush color value(red)");
|
||||
this.ports.green = new Port("green",true,true,0,255,"The brush color value(green)");
|
||||
this.ports.blue = new Port("blue",true,true,0,255,"The brush color value(blue)");
|
||||
|
||||
this.thickness = function(line)
|
||||
{
|
||||
@ -39,6 +36,7 @@ function Brush()
|
||||
|
||||
this.red = function(line)
|
||||
{
|
||||
return 255;
|
||||
if(this.ports[this.routes.red]){
|
||||
return this.ports[this.routes.red] * 255;
|
||||
}
|
||||
@ -47,6 +45,7 @@ function Brush()
|
||||
|
||||
this.green = function(line)
|
||||
{
|
||||
return 0;
|
||||
if(this.ports[this.routes.green]){
|
||||
return this.ports[this.routes.green] * 255;
|
||||
}
|
||||
@ -55,6 +54,7 @@ function Brush()
|
||||
|
||||
this.blue = function(line)
|
||||
{
|
||||
return 0;
|
||||
if(this.ports[this.routes.blue]){
|
||||
return this.ports[this.routes.blue] * 255;
|
||||
}
|
||||
@ -73,10 +73,10 @@ function Brush()
|
||||
{
|
||||
ronin.commander.blur();
|
||||
|
||||
this.ports.speed = distance_between(line.from,line.to)/15.0;
|
||||
this.ports.distance += this.ports.speed;
|
||||
this.ports.noise = Math.random(255/255.0);
|
||||
this.ports.x = line.from.x/2;
|
||||
// this.ports.speed = distance_between(line.from,line.to)/15.0;
|
||||
// this.ports.distance += this.ports.speed;
|
||||
// this.ports.noise = Math.random(255/255.0);
|
||||
// this.ports.x = line.from.x/2;
|
||||
|
||||
for(pointer_id in this.pointers){
|
||||
this.pointers[pointer_id].stroke(line);
|
||||
|
@ -7,7 +7,6 @@ function Line()
|
||||
this.methods = {};
|
||||
|
||||
this.ports = {};
|
||||
this.ports.index = 0;
|
||||
|
||||
this.methods.tween = function(q)
|
||||
{
|
||||
|
9
sources/scripts/port.js
Normal file
9
sources/scripts/port.js
Normal file
@ -0,0 +1,9 @@
|
||||
function Port(name,input,output,value,max,docs)
|
||||
{
|
||||
this.name = name;
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.value = value;
|
||||
this.max = max;
|
||||
this.docs = docs;
|
||||
}
|
@ -63,7 +63,5 @@ function Ronin()
|
||||
this.render.update();
|
||||
this.grid.update();
|
||||
this.guide.update();
|
||||
|
||||
this.commander.input_el.value = "frame crop:$";
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user