Category Archives : Web Design


HTML5 Canvas: Smooth, variable width lines with transparency. 2

When making a drawing app with HTML5 canvas, you might come up against the problem of making a smooth, variable width line. Eventually you might find that you can make several calls to ctx.quadraticCurveTo(x,y,xc,yc) and get some kind of effect. If you stroke every 2 or 3 points, then as long as the line width is very small, you won’t notice the jaggedness. Unfortunately, if you try to do this with semi-transparent lines, the effect is truly horrible. To solve this problem, instead of drawing lines, I simply draw very thin shapes, and fill them with a color. This allows for 1) variable thickness and 2) nice transparency. Variable transparency is a problem I haven’t quite figured out yet. It may require composing the shape from individual pixels, which is simply too slow, especially in IE. What I am writing is a drawing App that works with the Wacom Web Plugin, and therefore varies line thickness based on pressure. I would like to vary opacity too, but this seems problematic right now. A solution that may be possible is to fill the shape with a complex gradient, if it is possible to create semi-transparent stops. Here is an image of what the program does so far:   Each line is actually a full shape, with varying degrees of opacity. Thickness and thinness is accomplished with pen pressure from the Wacom Intuous5 tablet. As the line is drawn, a temporary line is shown to the user, when they lift the pen, that line disappears, and a […]

jadczyk_line_eq1

HTML5 Canvas, Pixel Compositing, Transparency, and why all the trivia!

One thing I really hate about new technology are all the early adopters who incessantly post the same trivial examples. They cross link them too. So you can go from one page to the next, and see essentially the same example, just with the bits renamed or moved around. At a certain point, I got it into my head that I wanted to make a quickie HTML5 App that works with my Intuous5 Wacom Pad. Wacom has a web plugin that let’s you get data about pen pressure and so on from the tablet. So I started to work on it, and found the said trivial examples and started mashing something up. Pretty soon it became apparent that if I wanted my lines to look good, I might have to anti-alias them, or so I am trying, I don’t know if it will work, because I just spent the better part of 2 hours looking for a solution to a simple problem. If you look for examples of pixel level manipulation for HTML5 Canvas, you will find the same trivial examples over and over again, which basically say: var id = context.createImageData(1,1); var d = id.data; d[0] = r; // where r is 0…255 … context.putImageData(id,x,y); If you actually want a full trivial example, use google, they abound. The problem with the above is: it replaces the entire pixel, all the way to the background, erasing any colors beneath it. The alpha channel of the pixel doesn’t make it transparent to what was under the […]


Backbone.js + Rails 2

You all know that my opinion of Ruby On Rails couldn’t be any lower if it was under the basement carpet of a Pompeii1 house, so this post won’t be very suprising. So, awhile back I was having a discussion with a ¬†friend about how, as a general rule, about 90% of a web app should really be taking place on the browser, and this was vindicated in my opinion with several other developers coming to much the same conclusion and releasing some very interesting application frameworks for javascript Single Page Applications. Of course this conversation took place when jQuery was just really starting to take off. The problem at that time was that no one was really talking about a client side application in javascript methodology, how such a thing could or would work. In hindsight it all seems obvious, but actually, Backbone and other such frameworks represent some really great out of the box creativity. Anyway, after my last Rails project, I more or less swore I would never work with that ass backwards platform ever again. I decided to revisit this idea of Single Page Applications and low and behold I stumble onto Backbone.js, and I decide I am going to learn to use this tool. While looking around for some books on the topics of jQuery and Backbone (I’ve more or less decided to give up the ghost and use jQuery ui elements in all future applications cause rolling your own is just too much work.) low an behold I find […]

backbonevsrails

Rails will_paginate links to wrong page 4

Well, While setting up a website today I found a bit of retardation in will_paginate. Aside from poor and complicated documentation and an incredible amount of bloat for what amounts to a very simple kind of website component, I found that will_paginate was linking to /?page= on a page that showed in the url bar as /products, so the link should have been /products?page=. So I looked around for a quick fix, and this is the best I got: Revisited: roll your own pagination links with will_paginate and Rails 3 OH MY GAWD. You have to be shitting me. That is hands down the most retarded thing I have ever seen. So, like the little hack monster that I am, I did it faster and easier with less code. If you want to change the pagination links, you can do it with jQuery. $(‘div.pagination a’).each(function () { var url = $(this).attr(‘href’); url = url.replace(‘/’,”); $(this).attr(‘href’,url); }); Why? Because ideally, will_paginate shouldn’t give a shit about the url, that’s not its job, that’s my job, its job is to ADD get parameters, and manage what those parameters should be, anything else is retarded.


Love Ruby, Hate Rails, but still use it — or Ruby vs PHP 11

Okay, that title was a bit extreme, I don’t really hate Rails. I don’t get why people feel the need to be so completely polarized about a framework, or a language. It’s either the best thing since sliced bread, or the worst, and nowhere in between. Still, most developers who aren’t Ruby purists, can tend to have a love hate relationship with Rails. Rails is easy to develop with, full stop. It’s practically impossible for you not to push out an app in AT LEAST 1/4 of the time it would take in straight up PHP. The problem is, PHP and Rails are apples and oranges, they aren’t the same thing, Rails is a framework built with the Ruby language, PHP is just a language. If you want a comparison, try CakePHP and Rails. Saying that Rails isn’t as fast as PHP is kind of mind boggling. Rails is slow, and so is ruby, and it will never be as fast as PHP or faster, period. Unless PHP becomes abandoned, which doesn’t seem likely. PHP is 100% geared towards a Server Side Scripting language, from the ground up, it’s written directly into the PHP parser to handle HTML with embedded PHP tags. Ruby is a general purpose scripting language with addon modules for parsing ruby code in HTML, like ERB. Regardless of this, you’d barely notice how much slower it is in reality because at this point, it’s very much a matter of hundredths of a second difference (probably). That barely even matters in large […]


Spree Commerce, eBay Trading API, and the eBay Accelerator Toolkit from Intradesys EbatNs

In this bit, I talk about using the EbatNs SDK for the eBay Trading API, to list items from your Spree Commerce store, or really any rails application. Filled with production code examples from an honest to god real live and working spree site that interfaces with the eBay trading API to Add, Revise, and End items, on ebay when they sell in your store, or on your store when they sell on eBay.


SOAP APIs R Klunky or How to waste bandwidth for no good reason

The fact that SOAP is still around is, to be honest, absolutely beyond my comprehension. No serious effort seems to have been put into something like JSONRPC. Still, when it comes to some API calls, SOAP is pretty darn good, but this here is one example of it being used as just a waste. I recently setup a client, who has a Spree Commerce Ruby on Rails store, with the Ebay Trading API. Basically, he lists items on his store, sends them to ebay, and his store is notified when they have sold on ebay, and are thus removed from his store, or when they sell on his store, they are ended on ebay. Pretty standard setup, nothing special. The app subscribes to ebay trading api platform notifications which are sent to the server in a SOAP format. The SOAP notification that an item has sold is 11kb. Yeah, I know what you are thinking, that’s small. No, it’s not. When you are talking millions of users, it’s not small, it’s huge. The information that I actually need from that is 1.1k. To be quite honest, I need even less. Apparently the client notifications api sends out notifications in as REST kind of way, i.e. as a url with key=>value pairs. Really, all I need is: EventName=TheEvent&ItemID=2312398081 That’s all I use. I understand that other people might need more information, and may be handling all kinds of specific situations, but that’s part of the point. Different people need different info, so just dumping all available […]


Rails Application Config 1

I saw this railscast on application wide configs and I liked it alot, however, I am not big on typing APP_CONFIG[:value][:subvalue] so I have made a small tweak to that, and placed it as a model, which is where I like it to be, as it is a model of the applications configuration, where the datasource is a fixed file, in this case, config/config.yml. I suppose, you could put it anywhere you like. class ValueProxy def initialize(attrs) @attrs = attrs end def method_missing(sym,*args,&block) sym = sym.to_s if @attrs[sym] then if @attrs[sym].class == Hash then return ValueProxy.new(@attrs[sym]) else return @attrs[sym] end end end end class AppConfig @@config = YAML::load_file(“#{RAILS_ROOT}/config/config.yml”) def self.method_missing(sym, *args, &block) if @@config[sym.to_s] then if @@config[sym.to_s].class == Hash then return ValueProxy.new(@@config[sym.to_s]) else return @@config[sym.to_s] end end end def self.respond_to?(sym,include_private=false) true end end Here is the yml file: auth: http_basic: true And then the usage: AppConfig.auth.http_basic == true Well that’s more or less it.


HowTo ActionScript 3 (as3 flash or flex or AIR) Class and Object Inheritance, extends

It seems I have been getting alot of hits due to my post on AS3 inheritance, and I notice that most of the documentation and examples out there don’t really cover the whys and the hows in a thorough manner. There are a couple of parts to this little tutorial, the first being a kind of very basic demonstration of extending, and then some concrete realworld samples. You can jump ahead to the realworld samples if you are just looking to see how/why you might use extend to solve some real problems. Basic/intro to oop and extending in as3 extending event dispatcher to manage your own event queue extending event to create a custom event and finally extending Panel to make a drag/drop Panel Having classes and objects does not equal OOP. To understand a class, you need to understand that an object without state or behavior is meaningless, so to be an object, it must have those things. The object itself is an environment, it is like a scope, it’s a container which imparts a kind of semantic meaning to the function and variables attached to it. Having objects is very nice, but there needs to be something more, and that something more is inheritance. Without inheritance, objects are simply wrappers, and it would be just as well to create functions and simply pass in some kind of key to ameliorate what to do. With inheritance, you share state and behavior between objects. The common example is with a person, people have names, and […]