(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
/* | |
* Copyright 2014 Chris Banes | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
package org.lucasr.layoutsamples.canvas; | |
import android.os.Build; | |
import android.text.Layout.Alignment; | |
import android.text.StaticLayout; | |
import android.text.TextDirectionHeuristic; | |
import android.text.TextDirectionHeuristics; | |
import android.text.TextPaint; | |
import android.text.TextUtils.TruncateAt; | |
import android.util.Log; |
/* | |
* Copyright 2014 Chris Banes | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
There was a [great article][1] about how react implements it's virtual DOM. There are some really interesting ideas in there but they are deeply buried in the implementation of the React framework.
However, it's possible to implement just the virtual DOM and diff algorithm on it's own as a set of independent modules.
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:0.4' | |
} | |
} | |
apply plugin: 'android' |
#! /usr/bin/env python | |
# coding=utf-8 | |
__author__ = 'jszhou' | |
from bottle import * | |
import hashlib | |
import xml.etree.ElementTree as ET | |
import urllib2 | |
# import requests | |
import json |
import android.content.res.Resources; | |
import android.graphics.Bitmap; | |
import android.graphics.NinePatch; | |
import android.graphics.Rect; | |
import android.graphics.drawable.NinePatchDrawable; | |
import java.nio.ByteBuffer; | |
import java.nio.ByteOrder; | |
/** |
// adapted from http://www.youtube.com/watch?v=qNM0k522R7o | |
extern vec2 size; | |
extern int samples = 5; // pixels per axis; higher = bigger glow, worse performance | |
extern float quality = 2.5; // lower = smaller glow, better quality | |
vec4 effect(vec4 colour, Image tex, vec2 tc, vec2 sc) | |
{ | |
vec4 source = Texel(tex, tc); | |
vec4 sum = vec4(0); |