Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
karimnaaji committed May 29, 2020
1 parent 9d73d1a commit 2a8b560
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/render/draw_line.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type LineStyleLayer from '../style/style_layer/line_style_layer';
import type LineBucket from '../data/bucket/line_bucket';
import type {OverscaledTileID} from '../source/tile_id';
import {clamp, nextPowerOfTwo} from '../util/util';
import {renderColorRamp, type ColorRampParams} from '../util/color_ramp';
import {renderColorRamp} from '../util/color_ramp';
import EXTENT from '../data/extent';

export default function drawLine(painter: Painter, sourceCache: SourceCache, layer: LineStyleLayer, coords: Array<OverscaledTileID>) {
Expand Down Expand Up @@ -82,7 +82,6 @@ export default function drawLine(painter: Painter, sourceCache: SourceCache, lay
} else if (gradient) {
let gradientTexture = bucket.gradientTexture;
if (!gradientTexture || layer.gradientTextureInvalidated) {
const sourceMaxZoom = sourceCache.getSource().maxzoom;
const lineLength = bucket.maxLineLength / EXTENT;
// Logical pixel tile size is 512px, and 1024px right before current zoom + 1
const maxTilePixelSize = 1024;
Expand Down
6 changes: 3 additions & 3 deletions src/util/color_ramp.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function renderColorRamp(params: ColorRampParams): RGBAImage {
const evaluationGlobals = {};
const width = params.resolution || 256;
const height = params.clips ? params.clips.length : 1;
const image = params.image || new RGBAImage({width: width, height: height});
const image = params.image || new RGBAImage({width, height});

assert(isPowerOfTwo(width));

Expand All @@ -37,7 +37,7 @@ export function renderColorRamp(params: ColorRampParams): RGBAImage {
image.data[stride + index + 1] = Math.floor(pxColor.g * 255 / pxColor.a);
image.data[stride + index + 2] = Math.floor(pxColor.b * 255 / pxColor.a);
image.data[stride + index + 3] = Math.floor(pxColor.a * 255);
}
};

if (!params.clips) {
for (let i = 0, j = 0; i < width; i++, j += 4) {
Expand All @@ -60,4 +60,4 @@ export function renderColorRamp(params: ColorRampParams): RGBAImage {
}

return image;
}
}
8 changes: 4 additions & 4 deletions test/unit/util/color_ramp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test('renderColorRamp linear', (t) => {
1, 'red'
], spec, {handleErrors: false}).value;

const ramp = renderColorRamp({ expression, evaluationKey: 'lineProgress' });
const ramp = renderColorRamp({expression, evaluationKey: 'lineProgress'});

t.equal(ramp.width, 256);
t.equal(ramp.height, 1);
Expand All @@ -61,7 +61,7 @@ test('renderColorRamp step', (t) => {
1, 'black'
], spec, {handleErrors: false}).value;

const ramp = renderColorRamp({ expression, evaluationKey: 'lineProgress', resolution: 512 });
const ramp = renderColorRamp({expression, evaluationKey: 'lineProgress', resolution: 512});

t.equal(ramp.width, 512);
t.equal(ramp.height, 1);
Expand Down Expand Up @@ -89,12 +89,12 @@ test('renderColorRamp usePlacement', (t) => {
1, 'white'
], spec, {handleErrors: false}).value;

let ramp = renderColorRamp({ expression, evaluationKey: 'lineProgress', resolution: 512 });
const ramp = renderColorRamp({expression, evaluationKey: 'lineProgress', resolution: 512});

t.equal(ramp.width, 512);
t.equal(ramp.height, 1);

renderColorRamp({ expression, evaluationKey: 'lineProgress', resolution: 512, image: ramp });
renderColorRamp({expression, evaluationKey: 'lineProgress', resolution: 512, image: ramp});

t.equal(pixelAt(ramp, 0)[3], 127, 'pixel at 0.0 matches input alpha');
t.ok(nearlyEquals(pixelAt(ramp, 50), [255, 0, 0, 127]), 'pixel < 0.1 matches input');
Expand Down

0 comments on commit 2a8b560

Please sign in to comment.