Permalink
Browse files

Fix: brush antialiasing and minor stuff

  • Loading branch information...
trethaller committed Aug 6, 2013
1 parent ee3dfef commit 38ebb85e8695eb745843e7ee7f3ed4594ea45330
Showing with 37 additions and 37 deletions.
  1. +1 −1 js/app.coffee
  2. +1 −1 js/app.js
  3. +9 −8 js/core.coffee
  4. +1 −1 js/core.js
  5. +13 −14 js/tools.coffee
  6. +12 −12 js/tools.js
View
@@ -75,7 +75,7 @@ class DocumentView
local = {}
- $container.mousedown (e)->
+ $backCanvas.mousedown (e)->
e.preventDefault()
if e.which is 1
self.drawing = true
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -320,27 +320,28 @@ genBrushFunc = (args, brushExp, blendExp)->
str = "
(function (rect, dstFb, #{args}) {
- var minx = rect.x;
- var miny = rect.y;
- var sw = rect.width;
- var sh = rect.height;
+ var sw = Math.round(rect.width);
+ var sh = Math.round(rect.height);
var invw = 2.0 / (rect.width - 1);
var invh = 2.0 / (rect.height - 1);
+ var offx = -(rect.x % 1.0) * invw - 1.0;
+ var offy = -(rect.y % 1.0) * invh - 1.0;
var fbw = dstFb.width;
var fbh = dstFb.height;
+ var minx = Math.floor(rect.x) + fbw;
+ var miny = Math.floor(rect.y) + fbh;
var dstData = dstFb.getBuffer();
for(var sy=0; sy<sh; ++sy) {
- var y = sy * invh - 1.0;
+ var y = sy * invh + offy;
for(var sx=0; sx<sw; ++sx) {
- var x = sx * invw - 1.0;
- var dsti = (((sy + miny) + fbh) % fbh) * fbw + (((sx + minx) + fbw) % fbw);
+ var x = sx * invw + offx;
+ var dsti = ((sy + miny) % fbh) * fbw + ((sx + minx) % fbw);
var _tmp = 0.0;
#{brushExp};
#{blendExp};
}
}
})"
- #console.log("Generating brush function", str)
return eval(str)
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -14,7 +14,7 @@ class StepBrush
move: (pos, pressure) ->;
draw: (layer, pos, pressure) ->
rect = new Rect(pos.x, pos.y, 1, 1)
- intensity = pressure * @stepSize / 10.0
+ intensity = pressure
if @lastpos?
delt = pos.sub(@lastpos)
length = delt.length()
@@ -86,15 +86,15 @@ RoundBrush = (()->
{
id: 'stepSize'
name: "Step size"
- defaultValue: 3
- range: [1, 20]
+ defaultValue: 2
+ range: [1, 10]
type: 'int'
},
{
id: 'hardness'
name: "Hardness"
- defaultValue: 0.5
- range: [0.0, 10.0]
+ defaultValue: 0.2
+ range: [0.0, 1.0]
},
{
id: 'size'
@@ -112,8 +112,8 @@ RoundBrush = (()->
{
id:'intensity'
name: "Intensity"
- defaultValue: 0.5
- range: [0.0, 3.0]
+ defaultValue: 1.0
+ range: [0.0, 1.0]
}
]
@@ -122,9 +122,9 @@ RoundBrush = (()->
createTool = (env)->
sb = new StepBrush()
sb.stepSize = self.get('stepSize')
- rad = self.get('size')
+ size = self.get('size')
- hardness = self.get('hardness')
+ hardness = Math.pow(self.get('hardness'), 2.0) * 8.0;
hardnessPlus1 = hardness + 1.0
func = genBrushFunc("intensity, target, h, hp1",
"var d = Math.min(1.0, Math.max(0.0, (Math.sqrt(x*x + y*y) * hp1 - h)));
@@ -133,13 +133,12 @@ RoundBrush = (()->
sb.drawStep = (layer, pos, intensity, rect)->
r = new Rect(
- pos.x - rad * 0.5,
- pos.y - rad * 0.5,
- rad,
- rad).round()
+ pos.x - size * 0.5,
+ pos.y - size * 0.5,
+ size, size)
func(r, layer, intensity * self.get('intensity'), env.get('targetValue'), hardness, hardnessPlus1)
- rect.extend(r)
+ rect.extend(r.round())
return sb
self.properties = properties
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 38ebb85

Please sign in to comment.