Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add radius to flatten brush

  • Loading branch information...
commit daebdfd31cead0b5a8d149e406bdb857b8c20cff 1 parent a8784ec
@trethaller authored
View
14 out/js/teztura-core.js
@@ -33,18 +33,18 @@ Layer = (function() {
return this.data.fbuffer[ipos.y * this.width + ipos.x];
};
- Layer.prototype.getNormalAt = function(pos) {
+ Layer.prototype.getNormalAt = function(pos, rad) {
var fb, norm, p, px, py, sx1, sx2, sy1, sy2, xvec, yvec;
p = pos.round();
fb = this.data.fbuffer;
px = Math.round(pos.x);
py = Math.round(pos.y);
- sx1 = fb[py * this.width + ((px - 1) % this.width)];
- sx2 = fb[py * this.width + ((px + 1) % this.width)];
- sy1 = fb[((py + 1) % this.height) * this.width + px];
- sy2 = fb[((py - 1) % this.height) * this.width + px];
- xvec = new Vec3(2, 0, sx2 - sx1);
- yvec = new Vec3(0, 2, sy1 - sy2);
+ sx1 = fb[py * this.width + ((px - rad) % this.width)];
+ sx2 = fb[py * this.width + ((px + rad) % this.width)];
+ sy1 = fb[((py - rad) % this.height) * this.width + px];
+ sy2 = fb[((py + rad) % this.height) * this.width + px];
+ xvec = new Vec3(rad * 2, 0, sx2 - sx1);
+ yvec = new Vec3(0, rad * 2, sy2 - sy1);
norm = xvec.cross(yvec).normalized();
return norm;
};
View
16 out/js/teztura.js
@@ -787,24 +787,24 @@ FlattenBrush = (function() {
{
id: 'stepSize',
name: "Step size",
- defaultValue: 2,
+ defaultValue: 3,
range: [1, 10],
type: 'int'
}, {
id: 'hardness',
name: "Hardness",
- defaultValue: 0.2,
+ defaultValue: 0.8,
range: [0.0, 1.0]
}, {
id: 'size',
name: "Size",
- defaultValue: 20.0,
+ defaultValue: 40.0,
range: [1.0, 256.0],
type: 'int'
}, {
id: 'intensity',
name: "Intensity",
- defaultValue: 0.6,
+ defaultValue: 0.2,
range: [0.0, 1.0],
power: 2.0
}
@@ -827,6 +827,8 @@ FlattenBrush = (function() {
sb.drawStep = function(layer, pos, intensity, rect) {
var det, r;
r = new Rect(pos.x - size * 0.5, pos.y - size * 0.5, size, size);
+ self.normal = layer.getNormalAt(pos, 4);
+ self.origin = new Vec3(pos.x, pos.y, layer.getAt(pos));
det = -self.normal.x * self.origin.x - self.normal.y * self.origin.y - self.normal.z * self.origin.z;
func(r, layer, intensity * self.get('intensity'), hardness, self.normal, det);
return rect.extend(r.round());
@@ -842,12 +844,6 @@ FlattenBrush = (function() {
self.normal = layer.getNormalAt(pos);
self.origin = new Vec3(pos.x, pos.y, layer.getAt(pos));
return StepBrush.prototype.beginDraw.apply(sb, arguments);
- /*
- n = self.normal
- o = self.origin
- console.log n.toString(), o.toString()
- */
-
},
endDraw: function() {
return StepBrush.prototype.endDraw.apply(sb, arguments);
View
14 src/core/core.coffee
@@ -19,17 +19,17 @@ class Layer
ipos = pos.wrap(@width, @height).round()
return @data.fbuffer[ ipos.y * @width + ipos.x ]
- getNormalAt: (pos)->
+ getNormalAt: (pos, rad)->
p = pos.round()
fb = @data.fbuffer
px = Math.round(pos.x)
py = Math.round(pos.y)
- sx1 = fb[ py * @width + ((px-1)%@width) ]
- sx2 = fb[ py * @width + ((px+1)%@width) ]
- sy1 = fb[ ((py+1) % @height) * @width + px ]
- sy2 = fb[ ((py-1) % @height) * @width + px ]
- xvec = new Vec3(2, 0, sx2 - sx1)
- yvec = new Vec3(0, 2, sy1 - sy2)
+ sx1 = fb[ py * @width + ((px-rad)%@width) ]
+ sx2 = fb[ py * @width + ((px+rad)%@width) ]
+ sy1 = fb[ ((py-rad) % @height) * @width + px ]
+ sy2 = fb[ ((py+rad) % @height) * @width + px ]
+ xvec = new Vec3(rad*2, 0, sx2 - sx1)
+ yvec = new Vec3(0, rad*2, sy2 - sy1)
norm = xvec.cross(yvec).normalized()
return norm
View
15 src/tools.coffee
@@ -152,27 +152,27 @@ FlattenBrush = (()->
{
id: 'stepSize'
name: "Step size"
- defaultValue: 2
+ defaultValue: 3
range: [1, 10]
type: 'int'
},
{
id: 'hardness'
name: "Hardness"
- defaultValue: 0.2
+ defaultValue: 0.8
range: [0.0, 1.0]
},
{
id: 'size'
name: "Size"
- defaultValue: 20.0
+ defaultValue: 40.0
range: [1.0, 256.0]
type: 'int'
},
{
id:'intensity'
name: "Intensity"
- defaultValue: 0.6
+ defaultValue: 0.2
range: [0.0, 1.0]
power: 2.0
}
@@ -203,6 +203,8 @@ FlattenBrush = (()->
pos.y - size * 0.5,
size, size)
+ self.normal = layer.getNormalAt(pos, 4)
+ self.origin = new Vec3(pos.x, pos.y, layer.getAt(pos))
det = -self.normal.x * self.origin.x - self.normal.y * self.origin.y - self.normal.z * self.origin.z;
func(r, layer, intensity * self.get('intensity'), hardness, self.normal, det)
rect.extend(r.round())
@@ -214,11 +216,6 @@ FlattenBrush = (()->
self.normal = layer.getNormalAt(pos)
self.origin = new Vec3(pos.x, pos.y, layer.getAt(pos))
StepBrush.prototype.beginDraw.apply(sb, arguments)
- ###
- n = self.normal
- o = self.origin
- console.log n.toString(), o.toString()
- ###
endDraw: ()-> StepBrush.prototype.endDraw.apply(sb, arguments)
}
Please sign in to comment.
Something went wrong with that request. Please try again.