コード:
#include "DxLib.h"
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
ChangeWindowMode(TRUE);
if (DxLib_Init() != 0) return 0;
int grahBrsh = MakeScreen(48,48,TRUE);
int grahOver = MakeScreen(640,480,TRUE);
int graphA = LoadGraph("Penguins.jpg");
int graphB = LoadGraph("Koala.jpg");
/*
* αチャンネルを操作するためのブラシ
* とりあえず円
*/
SetDrawScreen(grahBrsh);
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 0);
DrawBox(0,0,48,48,GetColor(0,0,0),TRUE);
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 128);
DrawCircle(24,24,20,GetColor(0,0,0),TRUE);
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 192);
DrawCircle(24,24,16,GetColor(0,0,0),TRUE);
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 255);
DrawCircle(24,24,12,GetColor(0,0,0),TRUE);
SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 255);
/*
* かぶせる方の画面
*/
SetDrawScreen(grahOver);
//DrawBox(0,0,640,480,GetColor(255,0,0),TRUE);
DrawGraph(0,0,graphA,FALSE);
// αチャンネルを削って透明にする
SetDrawBlendMode(DX_BLENDMODE_SUB, 255);
DrawBox(0,0,640,480,GetColor(0,0,0),TRUE);
SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 255);
while (ProcessMessage() == 0 && ScreenFlip() == 0) {
int mouseX, mouseY;
GetMousePoint(&mouseX, &mouseY);
if (GetMouseInput() & MOUSE_INPUT_LEFT) {
SetDrawScreen(grahOver);
SetDrawBlendMode(DX_BLENDMODE_ADD, 255);
DrawGraph(mouseX-24,mouseY-24,grahBrsh,TRUE);
SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 255);
}
if (GetMouseInput() & MOUSE_INPUT_RIGHT) {
SetDrawScreen(grahOver);
SetDrawBlendMode(DX_BLENDMODE_SUB, 255);
DrawGraph(mouseX-24,mouseY-24,grahBrsh,TRUE);
SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 255);
}
SetDrawScreen(DX_SCREEN_BACK);
//DrawBox(0,0,640,480,GetColor(0,0,255),TRUE);
DrawGraph(0,0,graphB,FALSE);
DrawGraph(0,0,grahOver,TRUE);
}
DxLib_End();
return 0;
}