Question: Is there a javascript library to draw images directly in the browser and save them to png or jpeg?

I want to use an alternative to services like aviary.com, pixlr.com and sumopaint.com and dont want to rely on third-party services and apis like these ones.

Is processingjs the right solution? I want a solution that works everywhere so please no nodejs and so on.

I need tools like a brush, paintbrush, pencil, layers, filters and so on - just like the real photoshop.

Answer: 
Ruby classes are objects like everything else to. Your Person class is really an object of class Class, which in turn inherits from class Module. When you add a method to class Class as an instance method, you are providing a new method for all classes.
If you had declared it with a `def` in Person, it would not be callable without an object. To add class methods for one class, but not all, you must prepend the method name with self or the name of the class:

```
class Person
    def instance_method
    end
    def self.class_method
    end
    def Person.other_class_method
    end
end

```

When you declare the method as `self.class_method` you are declaring your method to be a singleton method on the class object. `self` in a class or module declaration refers to the class object, which is why `self.` and `Person.` are the same.
When dealing with Ruby, just remember *everything* is an object, everything has methods. There are no functions in Ruby either, despite appearances to the contrary. Methods and objects, always.
You're extending the `Class` class, and all of your classes, like `Person`, are instances of `Class` (Yes, classes are instances of the `Class` class. They're ordinary objects).

So when you call `Person.add_accessor`, you're calling the instance method `Class#add_accessor`.