/// <summary> /// Initializes the local contrast inversion filter. /// </summary> /// <param name="size">Filter size</param> /// <param name="space">Color space</param> /// <param name="a">Contrast (0, 1]</param> /// <param name="b">Offset (0, 1]</param> public LocalContrastInversion(SizeInt size, Space space, float a = 0.75f, float b = 0.05f) { this.gb = new BoxBlur(size); Space = space; A = a; B = b; }
/// <summary> /// Initializes the local histogram stretch filter. /// </summary> /// <param name="width">Filter width</param> /// <param name="height">Filter height</param> /// <param name="space">Color space</param> /// <param name="contrast">Contrast [0, 1]</param> /// <param name="smoothing">Smoothing</param> public LocalHistogramStretch(int width, int height, Space space, float contrast = 0.5f, bool smoothing = true) { Size = new SizeInt(width, height); Space = space; Smoothing = smoothing; Contrast = contrast; }
/// <summary> /// Konstruktor /// </summary> /// <param name="p">Position des Rechteckes</param> /// <param name="s">Größe des Rechteckes</param> public RectInt(PointInt p, SizeInt s) { x = p.x; y = p.y; w = s.w; h = s.h; }
/// <summary> /// /// </summary> /// <param name="size">Radius</param> private void Data(SizeInt size) { this.l0 = size.Width; this.l1 = size.Height; this.rw = l0 >> 1; this.rh = l1 >> 1; }
/// <summary> /// Initializes the local histogram stretch filter. /// </summary> /// <param name="size">Radius</param> /// <param name="space">Color space</param> /// <param name="contrast">Contrast [0, 1]</param> /// <param name="smoothing">Smoothing</param> public LocalHistogramStretch(SizeInt size, Space space, float contrast = 0.5f, bool smoothing = true) { Size = size; Space = space; Smoothing = smoothing; Contrast = contrast; }
public static MapBehaviour CreateMainMap(Type mapType, SizeInt mapSize, Size cellSize) { MapBehaviour currentMainMapBehaviour = MainMapBehaviour; if (currentMainMapBehaviour != null) { UnityEngine.Object.DestroyImmediate(currentMainMapBehaviour.gameObject); currentMainMapBehaviour = null; } GameObject mapGO = new GameObject("Map"); mapGO.layer = LayerMask.NameToLayer(EditorStringReferences.ShadowWitchLayerName); MapBehaviour mapBehaviour = mapGO.AddComponent <MapBehaviour>(); MapBase map = mapType.Assembly.CreateInstance(mapType.ToString()) as MapBase; map.Init(mapSize, cellSize); mapBehaviour.Init(map, CreateLayerGameObjects()); mainMapBehaviour = mapBehaviour; BoxCollider boxCollider = mapGO.AddComponent <BoxCollider>(); boxCollider.isTrigger = true; boxCollider.center = new Vector3(mapSize.Width / 2f * cellSize.Width, 0f, -mapSize.Height / 2f * cellSize.Height); boxCollider.size = new Vector3(mapSize.Width * cellSize.Width, 0f, mapSize.Height * cellSize.Height); return(mainMapBehaviour); }
/// <summary> /// Initializes the local histogram stretch filter. /// </summary> /// <param name="radius">Radius</param> /// <param name="space">Color space</param> /// <param name="contrast">Contrast [0, 1]</param> /// <param name="smoothing">Smoothing</param> public LocalHistogramStretch(int radius, Space space, float contrast = 0.5f, bool smoothing = true) { Size = new SizeInt(radius, radius); Space = space; Smoothing = smoothing; Contrast = contrast; }
private FJobRequest CreateFJobRequest(int jobId, SMapWorkRequest smwr) { Coords coords = smwr.SCoords.GetCoords(); RectangleInt area = smwr.Area.GetRectangleInt(); SizeInt samplePoints = smwr.CanvasSize.GetSizeInt(); FJobRequest fJobRequest = new FJobRequest(jobId, smwr.Name, FJobRequestType.Generate, coords, area, samplePoints, (uint)smwr.MaxIterations); return(fJobRequest); }
private bool CalculateBestFitSquare(SizeInt area, float atlasRes, ref Vector2 Scale, UMAData.GeneratedMaterial generatedMaterial) { while (true) { PackSize lastRect = CalculateRects(generatedMaterial, area); if (lastRect.success) { if (area.Width != umaGenerator.atlasResolution || area.Height != umaGenerator.atlasResolution) { float neww = lastRect.xMax; // was area.Width; float newh = lastRect.yMax; // was area.Height; Scale.x = atlasRes / neww; Scale.y = atlasRes / newh; return(true); } return(false); // Everything fit, let's leave. } int projectedWidth = lastRect.xMax + lastRect.Width; int projectedHeight = lastRect.yMax + lastRect.Height; if (area.Width < area.Height) { // increase width. if (projectedWidth <= area.Width) { // If projectedWidth < the area width, then it's not // increasing each loop, and it MUST. area.Width += lastRect.Width; } else { area.Width = projectedWidth; } } else { // increase height if (projectedHeight <= area.Height) { area.Height += lastRect.Height; } else { area.Height = projectedHeight; } } } // no exit here! :) }
/// <summary> /// Vrátí ortogonální projekci modelu v podobě bitmapy (<see cref="Texture2D"/>). /// </summary> /// <param name="graphicsDevice">Grafické zařízení, které má být použito k vykreslení modelu.</param> /// <param name="model">Trojrozměný model k vykreslení.</param> /// <param name="bitmapScale">Poměr modelu vůči jeho bitmapové reprezentaci. Výchozí hodnota 100 znamená, /// že 1 jednotka modelu odpovídá 100 pixelům bitmapy.</param> /// <returns>Vrací ortogonální projekci trojrozměného modelu v podobě bitmapy.</returns> /// <param name="orthographicModelSize">Velikost modelu pro renderování. Pokud tento parametr není zadán, /// vypočítá se.</param> public static Texture2D RenderOrthographic( GraphicsDevice graphicsDevice, Model model, int bitmapScale = DEFAULT_BITMAP_SCALE, Vector2 orthographicModelSize = new Vector2()) { SizeFloat modelSize; BoundingBox box = Geometry.GetBoundingBox(model); if (orthographicModelSize.X == 0f || orthographicModelSize.Y == 0f) { modelSize = CalculateModelSize(box); } else { modelSize.X = orthographicModelSize.X; modelSize.Y = orthographicModelSize.Y; } SizeInt renderSize = CalculateBitmapSize(modelSize, bitmapScale); RenderTarget2D renderTarget = new RenderTarget2D( graphicsDevice, renderSize.X, renderSize.Y, false, graphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth16); Matrix world = Matrix.Identity; //Pozice kamery na ose Z odpovídá nejbližšímu bodu modelu Vector3 cameraPosition = new Vector3(0f, 0f, Math.Abs(box.Min.Z)); Matrix view = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up); //Přední ořezová plocha není vzdálena od kamery, zadní ořezová plocha odpovídá nejvzdálenějšímu bodu modelu float nearPlane = 0f; float farPlane = box.Max.Z * 2; Matrix projection = Matrix.CreateOrthographic(modelSize.X, modelSize.Y, nearPlane, farPlane); graphicsDevice.SetRenderTarget(renderTarget); graphicsDevice.DepthStencilState = new DepthStencilState() { DepthBufferEnable = true }; graphicsDevice.Clear(Color.Transparent); model.Draw(world, view, projection); graphicsDevice.SetRenderTarget(null); return(renderTarget); }
public void ZoomInShouldWork() { FCoordsMath fCoordsMath = new FCoordsMath(); PointDd start = new PointDd(new Dd(2), new Dd(-1)); PointDd end = new PointDd(new Dd(4), new Dd(1)); MCoordsDd coords = new MCoordsDd(start, end); SizeInt samplePoints = new SizeInt(100, 100); RectangleInt area = new RectangleInt(new PointInt(40, 40), new SizeInt(20, 20)); MCoordsDd result = fCoordsMath.ZoomIn(coords, samplePoints, area); }
private FGenJob CreateJob() { PointDd start = new PointDd(new Dd(-2), new Dd(-1)); PointDd end = new PointDd(new Dd(1), new Dd(1)); SizeInt samplePoints = new SizeInt(FGenerator.BLOCK_WIDTH, FGenerator.BLOCK_HEIGHT); uint maxIterations = 300; RectangleInt area = new RectangleInt(new PointInt(0, 0), samplePoints); FGenJob fGenJob = new FGenJob(42, start, end, samplePoints, maxIterations, area); return(fGenJob); }
/// <summary> /// JRRM - this is where we calculate the atlas rectangles. /// </summary> private void GenerateAtlasData() { SizeInt area = new SizeInt(); float atlasRes = umaGenerator.atlasResolution; Vector2 StartScale = Vector2.one / (float)scaleFactor; Vector2 Scale = Vector2.one; bool scaled = false; for (int i = 0; i < atlassedMaterials.Count; i++) { var generatedMaterial = atlassedMaterials[i]; if (generatedMaterial.umaMaterial.channels == null || generatedMaterial.umaMaterial.channels.Length == 0) { continue; } area.Width = umaGenerator.atlasResolution; area.Height = umaGenerator.atlasResolution; generatedMaterial.materialFragments.Sort(comparer); generatedMaterial.resolutionScale = StartScale; generatedMaterial.cropResolution = new Vector2(atlasRes, atlasRes); // We need a better method than this. // if "BestFitSquare" switch (umaGenerator.AtlasOverflowFitMethod) { case UMAGeneratorBase.FitMethod.BestFitSquare: scaled = CalculateBestFitSquare(area, atlasRes, ref Scale, generatedMaterial); break; default: // Shrink Textures while (!CalculateRects(generatedMaterial, area).success) { generatedMaterial.resolutionScale = generatedMaterial.resolutionScale * umaGenerator.FitPercentageDecrease; } break; } UpdateSharedRect(generatedMaterial); if (scaled) { generatedMaterial.resolutionScale = Scale * StartScale; UpdateAtlasRects(generatedMaterial, Scale); } } }
private FJobRequest CreateFJobRequest(SCoordsWorkRequest sCoordsWorkRequest, int jobId) { SCoords sCoords = sCoordsWorkRequest.SCoords; MqMessages.Coords coords = new MqMessages.Coords(sCoords.LeftBot.X, sCoords.RightTop.X, sCoords.LeftBot.Y, sCoords.RightTop.Y); CanvasSize cs = sCoordsWorkRequest.CanvasSize; SizeInt samplePoints = new SizeInt(cs.Width, cs.Height); MapSection ms = sCoordsWorkRequest.MapSection; RectangleInt area = new RectangleInt(new PointInt(ms.SectionAnchor.X, ms.SectionAnchor.Y), new SizeInt(ms.CanvasSize.Width, ms.CanvasSize.Height)); string name = "CoordsRequest"; FJobRequest fJobRequest = new FJobRequest(jobId, name, FJobRequestType.TransformCoords, coords, area, samplePoints, 0, sCoordsWorkRequest.TransformType); return(fJobRequest); }
public async void CmdLoginLogout(MouseEventArgs e, string ElementID) { if (LocalData.LoginLogout.Equals("Login")) { LocalFunctions.DisplayModal(ModalForm.Login); } else { SizeInt s = new SizeInt(); PointInt p = new PointInt(); p.Y = (int)(await BTodosJsInterop.GetElementActualTop(ElementID)); p.X = (int)(await BTodosJsInterop.GetElementActualLeft(ElementID)); s.W = (int)(await BTodosJsInterop.GetElementActualWidth(ElementID)); s.H = (int)(await BTodosJsInterop.GetElementActualHeight(ElementID)); p.Y += s.H; LocalFunctions.ContextMenu_DisplayLogout(p); } }
public override void OnGUI() { EditorGUILayout.BeginVertical(); currentSelectedMapTypeIndex = EditorGUILayout.Popup("Select Map Type", currentSelectedMapTypeIndex, mapTypeNames); EditorGUILayout.BeginHorizontal(); int mapSizeWidth = EditorGUILayout.IntField("Map Width", mapSize.Width); int mapSizeHeight = EditorGUILayout.IntField("Map Height", mapSize.Height); mapSize = new SizeInt(mapSizeWidth, mapSizeHeight); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); float cellSizeWidth = EditorGUILayout.FloatField("Cell Width", cellSize.Width); float cellSizeHeight = EditorGUILayout.FloatField("Cell Height", cellSize.Height); cellSize = new Size(cellSizeWidth, cellSizeHeight); EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Create Map")) { CreateNewWindow(); } EditorGUILayout.EndVertical(); }
/// <summary> /// Initializes the bottom-hat filter. /// </summary> /// <param name="size">Filter size</param> public BottomHat(SizeInt size) { closing = new Closing(size); }
/// <summary> /// Initializes the filter for homomorphic processing. /// </summary> /// <param name="size">Radius</param> /// <param name="space">Color space</param> /// <param name="a">Contrast [-1, 1]</param> /// <param name="b">Offset (0, 1]</param> public HomomorphicEnhancement(SizeInt size, Space space, float a = 0.5f, float b = 0.05f) { gb = new BoxBlur(size); Space = space; A = a; B = b; }
/// <summary> /// Initializes the contrast enhancement filter. /// </summary> /// <param name="size">Radius</param> /// <param name="space">Color space</param> /// <param name="a">Contrast [-1, 1]</param> /// <param name="b">Offset [-1, 1]</param> public KsiContrastEnhancement(SizeInt size, Space space, float a = 0.75f, float b = 0.05f) { gb = new BoxBlur(size); Space = space; A = a; B = b; }
/// <summary> /// Initializes the resize filter. /// </summary> /// <param name="size">Size</param> public Resize(SizeInt size) { Size = size; }
/// <summary> /// Initializes the resize filter. /// </summary> /// <param name="width">Width</param> /// <param name="height">Height</param> public Resize(int width = 512, int height = 512) { Size = new SizeInt(width, height); }
public PixelRangeWallSizer(SizeInt minSize, SizeInt maxSize) { MinSize = minSize; MaxSize = maxSize; }
public static Size ToSize(this SizeInt s) { return(new Size(s.Width, s.Height)); }
/// <summary> /// Initializes the Single Scale Retinex filter. /// </summary> /// <param name="size">Radius</param> /// <param name="space">Color space</param> /// <param name="a">Contrast [-1, 1]</param> /// <param name="b">Offset (0, 1]</param> /// <param name="nbase">Logarithm base</param> public SingleScaleRetinex(SizeInt size, Space space, float a = 1, float b = 0, float nbase = Maths.Pi) { gb = new BoxBlur(size); Space = space; A = a; B = b; Base = nbase; }
/// <summary> /// Initializes the erosion filter. /// </summary> /// <param name="size">Filter size</param> public Erosion(SizeInt size) { Size = size; }
/// <summary> /// Initializes the box blur filter. /// </summary> /// <param name="size">Filter size</param> public BoxBlur(SizeInt size) { Size = size; }
/// <summary> /// Initializes the box blur filter. /// </summary> /// <param name="radius">Radius</param> public BoxBlur(int radius = 3) { Size = new SizeInt(radius, radius); }
/// <summary> /// Initializes the box blur filter. /// </summary> /// <param name="width">Filter width</param> /// <param name="height">Filter height</param> public BoxBlur(int width, int height) { Size = new SizeInt(width, height); }
/// <summary> /// Initializes the erosion filter. /// </summary> /// <param name="radius">Radius</param> public Erosion(int radius = 3) { Size = new SizeInt(radius, radius); }
/// <summary> /// Initializes the Bradley local threshold filter. /// </summary> /// <param name="size">Radius</param> /// <param name="space">Color space</param> /// <param name="difference">Difference [0, 1]</param> public LocalThreshold(SizeInt size, Space space, float difference = 0.15f) { gb = new BoxBlur(size); Difference = difference; Space = space; }
/// <summary> /// Initializes the erosion filter. /// </summary> /// <param name="width">Filter width</param> /// <param name="height">Filter height</param> public Erosion(int width, int height) { Size = new SizeInt(width, height); }