These are chat archives for opal/opal

7th
Jul 2015
Rick Carlino
@RickCarlino
Jul 07 2015 04:51 UTC
So when is usage of to_n warranted?
Is it used mostly when interpolating code?
Forrest Chang
@fkchang
Jul 07 2015 07:55 UTC
@adambeynon @elia @meh when wrapping JS, why would one choose toll free bridging over include Native? In both cases you have to expose the methods via alias_native, though in toll free you have to define Klass.new and w/include Native, you can set @native in Klass#initialize
Forrest Chang
@fkchang
Jul 07 2015 08:03 UTC
The difference seems larger on the Javascript side, where they seem equivalent on the opal side
AstonJ
@AstonJ
Jul 07 2015 14:13 UTC
@pencilcheck www.metaruby.com - just let me know your username when you get there :)
Forrest Chang
@fkchang
Jul 07 2015 15:43 UTC
@jaredcwhite opalist deadline 8pm PT ish again tonight? Gonna be a tight squeeze for me
Rick Carlino
@RickCarlino
Jul 07 2015 16:07 UTC
Thanks for the reminder, @fkchang almost forgot!
Torsten Rüger
@rubydesign
Jul 07 2015 16:41 UTC
Hi, i'm trying to build some graphical application using html canvas.
Does anyone know of ruby wrappers for other libraries than three and phaser
Maybe Famous ? Anything not have to code on the canvas.
Forrest Chang
@fkchang
Jul 07 2015 16:45 UTC
@dancinglightning I think there's a opal-raphael, though simply wrapping in Native works pretty well for raphael
Torsten Rüger
@rubydesign
Jul 07 2015 16:52 UTC
@fkchang Thanks. I was looking for something not so tied to svg. more 2d context, possibly with 3d later. But simple is good.
Do you know the maintainer, it seems quite dead
Forrest Chang
@fkchang
Jul 07 2015 16:54 UTC
@dancinglightning I don't know the maintainer, it hit my radar a while's back, so I remembered that it's there. Looking back at the example on his readme, doesn't seem like he put much over what just wrapping w/Native gives you
hmm, maybe I should take that repo over at some point
Torsten Rüger
@rubydesign
Jul 07 2015 16:58 UTC
@fkchang it does seem very thin. 100 lines of code
Forrest Chang
@fkchang
Jul 07 2015 16:59 UTC
Yeah, his wrapper doesn't do much in the way or Ruby-fying, so it's nearly equivalent to wrapping in Native, but w/more work involved
Torsten Rüger
@rubydesign
Jul 07 2015 17:00 UTC
@fkchang sorry, newbie: what is wrapping Native? some link i can read.
Just asking because if it's easy, i might consider doing pixi.js myself. seems the better library
George Plymale II
@ylluminarious
Jul 07 2015 17:05 UTC
@dancinglightning there's an opal-pixi you're welcome to contribute to: https://github.com/orbitalimpact/opal-pixi
it's in its very early stages right now, and we've been busy with opal-phaser lately
Torsten Rüger
@rubydesign
Jul 07 2015 17:06 UTC
@ylluminarious i see you're everywhere. Thanks for the offer. i may just do that
Pixi seems just what i need, small enough and big enough. And well documented
Now i just need that link to the Native wrapping
George Plymale II
@ylluminarious
Jul 07 2015 17:08 UTC
@dancinglightning lol, thanks. you know what they say about great minds ;)
Torsten Rüger
@rubydesign
Jul 07 2015 17:12 UTC
@ylluminarious I hope that we're talking v3? Performance seems incredible, i had to crank it up to 40000 bunnies before it went down from 60fps. 50k was still at 40fps.
So do you have your own chat for that?
George Plymale II
@ylluminarious
Jul 07 2015 17:16 UTC
@dancinglightning sorry, i was away there for a sec. yes, we do have our own chat for it: https://gitter.im/orbitalimpact/opal-pixi
glad to hear it performs well under extreme conditions :)
yeah, should work well, it's just wrapping the library with some minimal ruby
Forrest Chang
@fkchang
Jul 07 2015 17:33 UTC
@dancinglightning check out me mucking w/raphael by wrapping it in native http://fkchang.github.io/opal-playground/?code:require_js%20'https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fraphael%2F2.1.4%2Fraphael-min.js'%0ADocument.ready%3F%20do%20%0A%20%20Timeout.new(1000)%20%7B%20%23%20to%20give%20require_js%20enough%20time%20to%20load%0A%20%20%20%20%24paper%20%3D%20Native(%60Raphael(200%2C%200%2C%20200%2C%20200)%60)%0A%20%20%20%20rect%20%3D%20%24paper.rect(0%2C%200%2C%20640%2C%20480%2C%2010)%0A%20%20%20%20rect.attr(%20fill%3A%20'%23fff'%2C%20stroke%3A%20'none')%0A%20%20%20%20rect.attr(%20fill%3A%20'%23bbb'%2C%20stroke%3A%20'none')%0A%20%20%20%20%24circle%20%3D%20%24paper.circle(100%2C%20100%2C%2060)%0A%20%20%20%20%24fill%20%3D%20'%23223fa3'%0A%20%20%20%20%24stroke%20%3D%20'%23000'%0A%20%20%20%20%24stroke_width%20%3D%2080%0A%20%20%20%20%24stroke_opacity%20%3D%200.5%0A%20%20%20%20%24duration%20%3D%202200%0A%20%20%20%20animate%0A%20%20%20%20COLORS%20%3D%20%25w(red%20green%20blue%20orange%20yellow%20pink%20white%20gold)%0A%20%20%20%20i%20%3D%200%0A%20%20%20%20Element.id('main').on(%3Aclick)%20%7B%20%0A%20%20%20%20%20%20%24fill%20%3D%20COLORS%5Bi%25COLORS.size%5D%0A%20%20%20%20%20%20i%20%2B%3D%201%0A%20%20%20%20%20%20reset%0A%20%20%20%20%20%20animate%0A%20%20%20%20%7D%0A%20%20%7D%0Aend%0Adef%20animate%0A%20%20%24circle.animate(%20%7Bfill%3A%20%24fill%2C%0A%20%20%20%20%20%20stroke%3A%20%24stroke%2C%0A%20%20%20%20%20%20'stroke-width'%20%3D%3E%20%24stroke_width%2C%0A%20%20%20%20%20%20'stroke-opacity'%20%3D%3E%20%24stroke_opacity%7D%2C%20%0A%20%20%20%20%24duration)%0Aend%0Adef%20reset%0A%20%20%24paper.clear%0A%20%20%24circle%20%3D%20%24paper.circle(100%2C%20100%2C%2060)%0Aend&html_code=%3Cbutton%20id%3D%22main%22%3E%0A%20%20Reanimate%0A%3C%2Fbutton%3E%0A&css_code=body%20%7B%0A%20%20background%3A%20%23eeeeee%3B%0A%7D%0A
All I had to do was wrap the initial paper in Native, and the rest was free
@all this examples uses the non publicized require_js functionality from opal-irb and pulls in raphael from cdn
I would like to be able to dynamically require in opal libs into the browser this way if there are compiled cdn versions around
Torsten Rüger
@rubydesign
Jul 07 2015 17:35 UTC
@fkchang ool. But what about those dollars. are they necessary ?
c
Forrest Chang
@fkchang
Jul 07 2015 17:36 UTC
the globals are there so I can manipulate them from opal-irb in real time w/o changing the data state

u can hit the 'show irb' window, and do something like

$fill = 'red'
reset
animate

and it will happen, and your old data state will still be there, vs reloading and starting from scratch

I was going to make a screencast about playing around w/js libs in real time in opal-playground, this is me experimenting w/what I might present. I would show off the require_js, as well as how it's game changer to be able to change code, data live in the app w/o having to reload everything
Torsten Rüger
@rubydesign
Jul 07 2015 17:39 UTC
@fkchang that is definitely cool. DO the screencast
Forrest Chang
@fkchang
Jul 07 2015 17:39 UTC
targeting @jaredcwhite 's opalist newsletter, but I don't think I'll get it in time. I need to take 'speed screencasting' lessons from @RickCarlino
The global thing is a quickie trick that I do in my normal apps -- make easily accessible certain variables to opal-irb (else they are hidden via closure). You could scope them in a class, but it's less typing to selectively use globals
Rick Carlino
@RickCarlino
Jul 07 2015 18:11 UTC
@fkchang I use a combo of Kazaam + KDENlive! on linux
Record each as seperate screens and then use shift + r to trim silence off the ends of scene transitions
Speaking of which, EPISODE 8 came out today. I cover Native and to_n breifly
Jamie Gaskins
@jgaskins
Jul 07 2015 20:04 UTC
@JikkuJose Haven't used Handlebars, but there's opal-haml (https://github.com/opal/opal-haml) and opal-slim(https://github.com/jgaskins/opal-slim) for Haml and Slim.
Jared White
@jaredcwhite
Jul 07 2015 20:07 UTC
@fkchang Yep, tonight's the night. @RickCarlino is a screencasting MACHINE!
Rick Carlino
@RickCarlino
Jul 07 2015 20:08 UTC
I'm actually 14 different people.
Jared White
@jaredcwhite
Jul 07 2015 20:08 UTC
BTW, I'm running behind too - I was planning to writing up a front end design pattern article with some code examples, but I've just been super busy opening up a new office IRL and that's taken up lots of time.
Jamie Gaskins
@jgaskins
Jul 07 2015 20:08 UTC
@RickCarlino All inside a single trench coat, right? :-)
Rick Carlino
@RickCarlino
Jul 07 2015 20:08 UTC
(that was a joke, btw)
Ofcourse
The other 9 of her are doing screencasting post production
Rick Carlino
@RickCarlino
Jul 07 2015 21:22 UTC
I have no idea what that is a reference to, but will agree that it is a factual statement.
Forrest Chang
@fkchang
Jul 07 2015 21:22 UTC
Reference: "I'm actually 14 different people."
Rick Carlino
@RickCarlino
Jul 07 2015 21:23 UTC
I got that part, though I have never seen the show / film from the picture ^
Gabriel Rios
@gabrielrios
Jul 07 2015 21:23 UTC
its from Agents of SHIELD
Forrest Chang
@fkchang
Jul 07 2015 21:23 UTC
Marvel's Agents of Shield. She's an inhuman who can duplicate herself
Rick Carlino
@RickCarlino
Jul 07 2015 21:23 UTC
...to promote Ruby
lol
Forrest Chang
@fkchang
Jul 07 2015 21:24 UTC
So I saw in my head, how you split like her and then crank out screencasts at breakneck speeds
Torsten Rüger
@rubydesign
Jul 07 2015 22:57 UTC
Newbie question: is there a pure ruby api for the dom?
Or do i have to finally learn jquery?
Rick Carlino
@RickCarlino
Jul 07 2015 22:57 UTC
@dancinglightning Yes!
Use ``Native(document`)````
Or
yeah, you can use opal-jquery
Elia Schito
@elia
Jul 07 2015 22:58 UTC
and also don't forget opal-browser
Rick Carlino
@RickCarlino
Jul 07 2015 22:58 UTC
Take a look at this and this if you're the screencast type.
Torsten Rüger
@rubydesign
Jul 07 2015 22:58 UTC
@RickCarlino yes, i just came off the html dom docs. seems hmm, how to say this
Elia Schito
@elia
Jul 07 2015 22:59 UTC
which is pure ruby and features an api similar to nokogiri
Torsten Rüger
@rubydesign
Jul 07 2015 23:04 UTC
@elia thanks, opal-browser may be what i was looking for. does it have docs more than the readme?
dancinglightning, or ask me if you have questions, I'm the one who wrote most of it
Torsten Rüger
@rubydesign
Jul 07 2015 23:07 UTC
thanks @meh , should bookmark that , that's got like everything
Elia Schito
@elia
Jul 07 2015 23:08 UTC
yeah it's kinda like MDN in ruby
Torsten Rüger
@rubydesign
Jul 07 2015 23:08 UTC
but there is a question, the dollar document? any way around the dollar
dancinglightning, how do you mean?
Torsten Rüger
@rubydesign
Jul 07 2015 23:11 UTC
@meh doesn't read like ruby code, is all i meant. probably works well enough. can't think of an alternative either
dancinglightning, what are you trying to do exactly?
Torsten Rüger
@rubydesign
Jul 07 2015 23:13 UTC
@meh just get my pixi element into the dom at the right place.
Elia Schito
@elia
Jul 07 2015 23:13 UTC
the document should be a global, you can either use the dollar or a constant (e.g. Document)
Torsten Rüger
@rubydesign
Jul 07 2015 23:14 UTC
ok, that was what i was looking for, thanks @elia , so i'm good
George Plymale II
@ylluminarious
Jul 07 2015 23:14 UTC
that is, anywhere in the defined scope of the program
@dancinglightning the dollar sign just indicates it's a global variable (accessible anywhere)
@dancinglightning also, i sometimes use $$[:document] to access the document. $$ is the wrapped window object, so you can access properties like the document from there.
huh, weird, gitter just switched some of my messages around
re: $$, you don't have to use opal-browser to use $$
as you can see here), i'm not using opal-browser to access the window object
but opal-browser is nice when you need more fine-grained control
George Plymale II
@ylluminarious
Jul 07 2015 23:21 UTC
shoot, i think gitter broke my link because of the markdown
Forrest Chang
@fkchang
Jul 07 2015 23:48 UTC
@meh @elia thoughts on :point_up: July 7, 2015 12:55 AM
fkchang, bridged classes imply having the methods directly added on the native class prototype
that may be unwanted
Forrest Chang
@fkchang
Jul 07 2015 23:56 UTC
@meh right, but why would I chose bridging over just including Native, the implications are different on the JS side only
that's the only reason, they're implementation dependant