private void selectEraserTool() { this.reset(); EraserTool eraser = new EraserTool(mapCreator); this.selecedTool = eraser; }
// Use this for initialization void Start() { Debug.Log(QualitySettings.GetQualityLevel().ToString()); if (QualitySettings.GetQualityLevel() >= 4) { Debug.Log("CaptureRes: 2048"); captureResolution = 1024; } if (QualitySettings.GetQualityLevel() == 5) { Debug.Log("CaptureAA: 2"); captureAASetting = 2; } else if (QualitySettings.GetQualityLevel() > 5) { Debug.Log("CaptureAA: 4"); captureAASetting = 1; } _toolMenu = GetComponent <ToolMenu>(); captureCamera = transform.Find("CaptureCamera").GetComponent <Camera>(); captureTexture = new Texture2D(captureResolution, captureResolution, TextureFormat.ARGB32, true); captureRenderer = captureTarget.GetComponent <MeshRenderer>(); renderTexturePool = new RenderTexture[2]; for (int i = 0; i < 2; ++i) { renderTexturePool[i] = new RenderTexture(captureResolution, captureResolution, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default); renderTexturePool[i].antiAliasing = captureAASetting; renderTexturePool[i].Create(); } splineTool = new SplineTool(this, _splineRenderTarget, _line, circleCursor); splineTool.SetSplineJaggedness(false); stampTool = new StampTool(this, _stampPrefab); meterTool = new MeterTool(this, _line, meterCursor); eraserTool = new EraserTool(this, eraserSprite, eraserCursor); activeTool = splineTool; activeTool.Activate(); float mapWHratio = 16.0f / 9.0f; int screenWidth = Screen.width; screenWidth -= screenWidth / 20; screenWidth = (int)Mathf.Min(captureResolution * 1.25f, screenWidth); int height = (int)(screenWidth / mapWHratio); UIImageTransform.sizeDelta = new Vector2(screenWidth, height); backups = new Color32[backupCount][]; for (int i = 0; i < backupCount; ++i) { backups[i] = new Color32[captureResolution * captureResolution]; } }
public FormMain() { InitializeComponent(); //WindowState = FormWindowState.Maximized; openImageDialog.Title = "Открыть изображение"; saveImageDialog.Title = "Сохранить изображение"; templateShown = false; isTemplateOn = false; BackgroundImage = null; //is it correct way to clear BackgroundImage of the form? templatePanel.Enabled = false; templatePanel.Visible = false; templatePanelMinimized.Enabled = false; templatePanelMinimized.Visible = false; isImageSaved = false; snapshot = new Bitmap(mainPictureBox.Width, mainPictureBox.Height); backPic = new Bitmap(mainImagePanel.Width, mainImagePanel.Height); loadPic = null; mouseDown = false; clearFlag = false; loadPicFlag = false; activeToolControlName = null; activeColorControlName = null; width = lineThicknessTrackBar.Value; eraser = new EraserTool(width); pencil = new PencilTool(width); rect = new RectangleTool(width); line = new LineTool(width); ellipse = new EllipseTool(width); fill = new FillTool(); toolsList = new Dictionary <string, ITool>(); toolsList.Add("labelPencil", pencil); toolsList.Add("labelEraser", eraser); toolsList.Add("labelRect", rect); toolsList.Add("labelLine", line); toolsList.Add("labelEllipse", ellipse); toolsList.Add("labelFill", fill); loadTemplate = new FormLoadTemplate(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Bundle extras = Intent.Extras; spriteName = extras.GetString(GetString(Resource.String.bundle_sprite_name)); int[] dimensions = extras.GetIntArray( GetString(Resource.String.bundle_sprite_dimensions)); w = dimensions[0]; h = dimensions[1]; //SetContentView(Resource.Layout.make_sprite); SetContentView(Resource.Layout.activity_make_sprite); // Drawer layout drawButton = FindViewById <Button>(Resource.Id.drawButton); drawButton.GetLocationOnScreen(buttonLocs); drawButton.Touch += OnbuttonPush; //// Setup Drawer drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_make_sprite); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, null, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close); drawerLayout.AddDrawerListener(toggle); NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view_create_sprite); navigationView.SetNavigationItemSelectedListener(this); canvasView = FindViewById <ImageView>(Resource.Id.imageView); cursorView = FindViewById <ImageView>(Resource.Id.cursorView); SetUpImage(ref this.canvas, ref this.mainSpriteDisplay, ref this.sourceBitmap, canvasView, w, h); commandHistory = new CommandHistory(); //Seems redundant for now tools = new Tool[4]; tools[0] = new PencilTool(commandHistory, sourceBitmap); tools[1] = new EraserTool(commandHistory, sourceBitmap); tools[2] = new FillTool(commandHistory, sourceBitmap); tools[3] = new ColorPickerTool(commandHistory, sourceBitmap); currentTool = tools[0]; FrameLayout spriteMainLayout = FindViewById <FrameLayout>(Resource.Id.make_sprite_main_layout); spriteMainLayout.Touch += OnSpriteCanvasTouched; SetupSideImageViews(Resource.Id.imageViewLeft, sourceBitmap); SetupSideImageViews(Resource.Id.imageViewTop, sourceBitmap); SetupSideImageViews(Resource.Id.imageViewRight, sourceBitmap); SetupSideImageViews(Resource.Id.imageViewBottom, sourceBitmap); canvas.DrawARGB(255, 255, 0, 255); curX = cursorView.GetX(); curY = cursorView.GetY(); SetupButtons(); }
public void SwitchTool(ToolType toolType) { if (toolType != ToolType.Move && ToolWhileMoveTool != null && ToolWhileMoveTool.GetToolType() == toolType) { ToolCurrent = ToolWhileMoveTool; ToolWhileMoveTool = null; return; } ToolWhileMoveTool = null; if (ToolCurrent != null) { ToolCurrent.ResetUsedElements(); } switch (toolType) { case ToolType.Brush: ToolCurrent = new BrushTool(); break; case ToolType.Crop: ToolCurrent = new CropTool(); break; case ToolType.Cursor: ToolCurrent = new CursorTool(); break; case ToolType.Fill: ToolCurrent = new FillTool(); break; case ToolType.Ellipse: ToolCurrent = new EllipseTool(); break; case ToolType.Eraser: ToolCurrent = new EraserTool(); break; case ToolType.ImportPng: ToolCurrent = new ImportTool(); break; case ToolType.Flip: ToolCurrent = new FlipTool(); break; case ToolType.Line: ToolCurrent = new LineTool(); break; case ToolType.Zoom: ToolCurrent = new MoveZoomTool(); break; case ToolType.Move: ToolWhileMoveTool = ToolCurrent; ToolCurrent = new MoveZoomTool(false); break; case ToolType.Pipette: ToolCurrent = new PipetteTool(); break; case ToolType.Rotate: ToolCurrent = new RotateTool(); break; case ToolType.Rect: ToolCurrent = new RectangleTool(); break; case ToolType.Stamp: ToolCurrent = new StampTool(); break; default: break; } }
void Awake() { instance = this; Global.eraserTool = this; }
// ======================================== // property // ======================================== // ======================================== // method // ======================================== public void Prepare() { if (_isPrepared) { return; } SuspendLayout(); var operation = new SelectorCategory("操作"); { operation.LabelSize = new Size(36, 36); operation.BackColor = Color.White; operation.MaxCols = 5; var select = new SelectTool(); _defaultTool = select; operation.AddLabel( Resources.cursor24, "選択", () => { _form.EditorCanvas.Tool = select; Hide(); _form.Activate(); _form.EditorCanvas.Select(); } ); var remove = new EraserTool( editor => editor.Model is MemoFreehand ); operation.AddLabel( Resources.eraser24, "消しゴム", () => { _form.EditorCanvas.Tool = remove; Hide(); _form.Activate(); _form.EditorCanvas.Select(); } ); var dragSelect = new DragSelectTool( editor => editor.Model is MemoFreehand ); operation.AddLabel( Resources.drag_select24, "ドラッグ選択", () => { _form.EditorCanvas.SelectionManager.DeselectAll(); _form.EditorCanvas.Tool = dragSelect; Hide(); _form.Activate(); _form.EditorCanvas.Select(); } ); dragSelect.Finished += HandleDragSelectToolFinished; AddCategory(operation); } var thin = new SelectorCategory("ペン (細)"); { thin.LabelSize = new Size(36, 36); thin.BackColor = Color.White; thin.MaxCols = 5; AddFreehand(thin, Resources.black_thin, "黒 太さ1pt", 1, Color.Black); AddFreehand(thin, Resources.red_thin, "赤 太さ1pt", 1, Color.Red); AddFreehand(thin, Resources.blue_thin, "青 太さ1pt", 1, Color.Blue); AddFreehand(thin, Resources.green_thin, "緑 太さ1pt", 1, Color.Green); AddFreehand(thin, Resources.gray_thin, "灰色 太さ1pt", 1, Color.Gray); AddCategory(thin); } var middle = new SelectorCategory("ペン (中)"); { middle.LabelSize = new Size(36, 36); middle.BackColor = Color.White; middle.MaxCols = 5; AddFreehand(middle, Resources.black_middle, "黒 太さ2pt", 2, Color.Black); AddFreehand(middle, Resources.red_middle, "赤 太さ2pt", 2, Color.Red); AddFreehand(middle, Resources.blue_middle, "青 太さ2pt", 2, Color.Blue); AddFreehand(middle, Resources.green_middle, "緑 太さ2pt", 2, Color.Green); AddFreehand(middle, Resources.gray_middle, "灰色 太さ2pt", 2, Color.Gray); AddCategory(middle); } var thick = new SelectorCategory("ペン (太)"); { thick.LabelSize = new Size(36, 36); thick.BackColor = Color.White; thick.MaxCols = 5; AddFreehand(thick, Resources.black_thick, "黒 太さ4pt", 4, Color.Black); AddFreehand(thick, Resources.red_thick, "赤 太さ4pt", 4, Color.Red); AddFreehand(thick, Resources.blue_thick, "青 太さ4pt", 4, Color.Blue); AddFreehand(thick, Resources.green_thick, "緑 太さ4pt", 4, Color.Green); AddFreehand(thick, Resources.gray_thick, "灰色 太さ4pt", 4, Color.Gray); AddCategory(thick); } ResumeLayout(); _isPrepared = true; }