How to use the @bentley/imodeljs-common.ColorDef.white function in @bentley/imodeljs-common

To help you get started, we’ve selected a few @bentley/imodeljs-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / test-apps / display-test-app / src / frontend / IncidentMarkerDemo.ts View on Github external
public addMarker(context: DecorateContext) {
    super.addMarker(context);
    const builder = context.createGraphicBuilder(GraphicType.WorldDecoration);
    const ellipse = Arc3d.createScaledXYColumns(this.worldLocation, context.viewport.rotation.transpose(), .2, .2, IncidentMarker._sweep360);
    // draw the circle the color of the marker, but with some transparency.
    const color = this._color.clone();
    builder.setSymbology(ColorDef.white, color, 1);
    color.setTransparency(200);
    builder.addArc(ellipse, false, false);
    builder.setBlankingFill(color);
    builder.addArc(ellipse, true, true);
    context.addDecorationFromBuilder(builder);
  }
}
github imodeljs / imodeljs / core / frontend / src / tile / CesiumWorldTerrainTileTree.ts View on Github external
// High water mark decoding based on decompressIndices_ in webgl-loader's loader.js.
    // https://code.google.com/p/webgl-loader/source/browse/trunk/samples/loader.js?r=99#55
    // Copyright 2012 Google Inc., Apache 2.0 license.
    let highest = 0;
    const length = indices.length;
    for (let i = 0; i < length; ++i) {
      const code = indices[i];
      indices[i] = highest - code;
      if (code === 0) {
        ++highest;
      }
    }
    const corners = (tile as any).corners;
    const patch = new BilinearPatch(corners[0], corners[1], corners[2], corners[3]);
    const materialParams = new RenderMaterial.Params();
    const color = ColorDef.white.clone();
    materialParams.diffuseColor = materialParams.specularColor = color;
    materialParams.diffuse = 0.8;
    materialParams.specular = 0.0;

    const material = system.createMaterial(materialParams, this._iModel);
    const displayParams = new DisplayParams(DisplayParams.Type.Mesh, color, color, 0.0, LinePixels.Solid, FillFlags.None, material);
    CesiumWorldTerrainTileLoader._scratchRange.setNull();
    CesiumWorldTerrainTileLoader._scratchRange.extendArray(corners);
    CesiumWorldTerrainTileLoader._scratchRange.low.z = minHeight - skirtHeight;
    CesiumWorldTerrainTileLoader._scratchRange.high.z = maxHeight;
    CesiumWorldTerrainTileLoader._scratchQParams.setFromRange(CesiumWorldTerrainTileLoader._scratchRange);
    const rangeCenter = CesiumWorldTerrainTileLoader._scratchRange.fractionToPoint(.5, .5, .5);
    CesiumWorldTerrainTileLoader._scratchRange.low.minus(rangeCenter, CesiumWorldTerrainTileLoader._scratchLocalRange.low);
    CesiumWorldTerrainTileLoader._scratchRange.high.minus(rangeCenter, CesiumWorldTerrainTileLoader._scratchLocalRange.high);

    const mesh = Mesh.create({ displayParams, type: Mesh.PrimitiveType.Mesh, range: CesiumWorldTerrainTileLoader._scratchLocalRange, isPlanar: false, is2d: false });
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / plugins / MeasurePoints.ts View on Github external
public onDynamicFrame(ev: BeButtonEvent, context: DynamicsContext): void {
    if (this.points.length < 1)
      return;

    const tmpPoints = this.points.slice();
    tmpPoints.push(ev.point.clone());

    const builder = context.createSceneGraphicBuilder();

    builder.setSymbology(ColorDef.white, ColorDef.white, 1);
    builder.addLineString(tmpPoints);

    context.addGraphic(builder.finish());
    this.updateDynamicDistanceMarker(tmpPoints);
  }
github imodeljs / imodeljs / test-apps / imodel-from-geojson / src / GeoJsonImporter.ts View on Github external
private addCategoryToExistingDb(categoryName: string) {
    const categoryId = SpatialCategory.insert(this.iModelDb, IModel.dictionaryId, categoryName, { color: ColorDef.white });
    this.iModelDb.views.iterateViews({ from: "BisCore.SpatialViewDefinition" }, ((view: ViewDefinition) => {
      const categorySelector = this.iModelDb.elements.getElement(view.categorySelectorId);
      categorySelector.categories.push(categoryId);
      this.iModelDb.elements.updateElement(categorySelector);

      return true;
    }));

    return categoryId;
  }
  /** Iterate through and accumulate the GeoJSON FeatureCollection range. */
github imodeljs / imodeljs / core / frontend / src / tools / MeasureTool.ts View on Github external
context.addDecorationFromBuilder(builderDynVis);

      const builderDynHid = context.createGraphicBuilder(GraphicType.WorldOverlay);
      const colorDynHid = colorDynVis.clone(); colorDynHid.setAlpha(100);

      builderDynHid.setSymbology(colorDynHid, ColorDef.black, 1);
      builderDynHid.addLineString(tmpPoints);

      context.addDecorationFromBuilder(builderDynHid);
      this.displayDynamicDistance(context, tmpPoints);
    }

    if (this._acceptedSegments.length > 0) {
      const builderAccVis = context.createGraphicBuilder(GraphicType.WorldDecoration);
      const builderAccHid = context.createGraphicBuilder(GraphicType.WorldOverlay);
      const colorAccVis = ColorDef.white.adjustForContrast(context.viewport.view.backgroundColor);
      const colorAccHid = colorAccVis.clone(); colorAccHid.setAlpha(100);

      builderAccVis.setSymbology(colorAccVis, ColorDef.black, 3);
      builderAccHid.setSymbology(colorAccHid, ColorDef.black, 1);

      for (const seg of this._acceptedSegments) {
        builderAccVis.addLineString([seg.start, seg.end]);
        builderAccHid.addLineString([seg.start, seg.end]);
        seg.marker.addDecoration(context);
        if (seg.marker.isSelected)
          this.displayDelta(context, seg);
      }

      context.addDecorationFromBuilder(builderAccVis);
      context.addDecorationFromBuilder(builderAccHid);
    }
github imodeljs / imodeljs / example-code / snippets / src / frontend / ViewDecorations.ts View on Github external
public addMarker(context: DecorateContext) {
    super.addMarker(context);
    const builder = context.createGraphicBuilder(GraphicType.WorldDecoration);
    const ellipse = Arc3d.createScaledXYColumns(this.worldLocation, context.viewport.rotation.transpose(), .2, .2, IncidentMarker._sweep360);
    builder.setSymbology(ColorDef.white, this._color, 1);
    builder.addArc(ellipse, false, false);
    builder.setBlankingFill(this._color);
    builder.addArc(ellipse, true, true);
    context.addDecorationFromBuilder(builder);
  }
}
github imodeljs / imodeljs / core / frontend / src / render / webgl / Material.ts View on Github external
const rgb = FloatRgb.fromColorDef(params.diffuseColor);
      this.rgba[0] = rgb.red;
      this.rgba[1] = rgb.green;
      this.rgba[2] = rgb.blue;
    } else {
      this.rgba[0] = this.rgba[1] = this.rgba[2] = -1;
    }

    const alpha = undefined !== params.alpha ? params.alpha : -1;
    this.rgba[3] = alpha;

    const scale = (value: number) => Math.floor(value * 255 + 0.5);
    this.setInteger(scale(params.diffuse), scale(params.specular), 0);

    const textureWeight = undefined !== this.textureMapping ? this.textureMapping.params.weight : 1.0;
    const specularRgb = undefined !== params.specularColor ? params.specularColor : ColorDef.white;
    const specularColors = specularRgb.colors;
    this.setInteger(scale(textureWeight), specularColors.r, 1);
    this.setInteger(specularColors.g, specularColors.b, 2);

    this.fragUniforms[3] = params.specularExponent;
  }