::: در حال بارگیری لطفا صبر کنید :::Loading , please wait ...

انجمن کدستانMoisrex

MoisrexMoisrex.rozblog.com
زمان جاریtime : چهارشنبه 11 آذر 1405 - 4:38 قبل از ظهر
نام کاربریusername : پسوردpassword : یاor عضویتregister | رمز عبور را فراموش کردمForgot your password?
شما در سایت ما ثبت نام نکرده اید و یا وارد اکانت کاربری خود نشده اید. از شما خواهشمند هستیم You are not log in to site. Please وارد شویدlogin یاor ثبت نام کنیدregister .
نقاشی با canvas
تعداد بازدیدvisits : 379
oisrex آفلاین



ارسال هاAnswers : 747
عضویتRegistration date : 4 /8 /1393
حمایت کردهThanks : 231
حمایت شدهThanked : 886
نقاشی با canvas

سلام

شما با این کد میتونید یه نقاشی شانسی بکشید

این با کلیک کار میکنه:

کد:
<script type="text/javascript" >

onclick=function(){

var canvas=document.getElementById('C');

r=Math.floor(Math.random() *250);

g=Math.floor(Math.random() *250);

b=Math.floor(Math.random() *250);

m=Math.floor(30+ Math.random() *300);

n=Math.floor(30+ Math.random() *300);

if(canvas.getContext){

var ctx=canvas.getContext('2d');

ctx.save();

ctx.shadowOffsetX=5;

ctx.shadowOffsetY=5;

ctx.shadowBlur=10;

ctx.shadowColor='rgb('+r+','+b+','+g+')';

ctx.fillStyle='rgb('+r+','+b+','+g+')';

ctx.fillRect(n,200,200,100);

ctx.restore();

ctx.beginPath();

ctx.arc(m,150,m,m,Math.PI*2,false);

ctx.lineWidth=2;

ctx.strokeStyle='rgb('+r+','+b+','+g+')';

ctx.stroke();

ctx.beginPath();

ctx.moveTo(m,m);

ctx.lineTo(n,10);

ctx.lineTo(100,10);

ctx.lineTo(n,200);

ctx.closePath();

ctx.lineWidth=2;

ctx.strokeStyle='rgb('+r+','+b+','+g+')';

ctx.stroke();

ctx.font="Bold 17px Arial";

ctx.fillStyle="#008600";

ctx.fillText("منبع: moisrex.rozblog.com",10,315);

}

}

</script>

<canvas id="C" width="700" height="500" >

Your web browser does not support canvas!

</canvas>

این پس از هر بار لود صفحه...

کد:
<script type="text/javascript" >

onload=function(){

var canvas=document.getElementById('C');

r=Math.floor(Math.random() *250);

g=Math.floor(Math.random() *250);

b=Math.floor(Math.random() *250);

m=Math.floor(30+ Math.random() *300);

n=Math.floor(30+ Math.random() *300);

if(canvas.getContext){

var ctx=canvas.getContext('2d');

ctx.save();

ctx.shadowOffsetX=5;

ctx.shadowOffsetY=5;

ctx.shadowBlur=10;

ctx.shadowColor='rgb('+r+','+b+','+g+')';

ctx.fillStyle='rgb('+r+','+b+','+g+')';

ctx.fillRect(n,200,200,100);

ctx.restore();

ctx.beginPath();

ctx.arc(m,150,m,m,Math.PI*2,false);

ctx.lineWidth=2;

ctx.strokeStyle='rgb('+r+','+b+','+g+')';

ctx.stroke();

ctx.beginPath();

ctx.moveTo(m,m);

ctx.lineTo(n,10);

ctx.lineTo(100,10);

ctx.lineTo(n,200);

ctx.closePath();

ctx.lineWidth=2;

ctx.strokeStyle='rgb('+r+','+b+','+g+')';

ctx.stroke();

ctx.font="Bold 17px Arial";

ctx.fillStyle="#008600";

ctx.fillText("منبع: moisrex.rozblog.com",10,315);

}

}

</script>

<canvas id="C" width="700" height="500" >

Your web browser does not support canvas!

</canvas>

اینم با فشردن کلید های صفحه کار میکنه:

کد:
<script type="text/javascript" >

onkeypress=function(){

var canvas=document.getElementById('C');

r=Math.floor(Math.random() *250);

g=Math.floor(Math.random() *250);

b=Math.floor(Math.random() *250);

m=Math.floor(30+ Math.random() *300);

n=Math.floor(30+ Math.random() *300);

if(canvas.getContext){

var ctx=canvas.getContext('2d');

ctx.save();

ctx.shadowOffsetX=5;

ctx.shadowOffsetY=5;

ctx.shadowBlur=10;

ctx.shadowColor='rgb('+r+','+b+','+g+')';

ctx.fillStyle='rgb('+r+','+b+','+g+')';

ctx.fillRect(n,200,200,100);

ctx.restore();

ctx.beginPath();

ctx.arc(m,150,m,m,Math.PI*2,false);

ctx.lineWidth=2;

ctx.strokeStyle='rgb('+r+','+b+','+g+')';

ctx.stroke();

ctx.beginPath();

ctx.moveTo(m,m);

ctx.lineTo(n,10);

ctx.lineTo(100,10);

ctx.lineTo(n,200);

ctx.closePath();

ctx.lineWidth=2;

ctx.strokeStyle='rgb('+r+','+b+','+g+')';

ctx.stroke();

ctx.font="Bold 17px Arial";

ctx.fillStyle="#008600";

ctx.fillText("منبع: moisrex.rozblog.com",10,315);

}

}

</script>

<canvas id="C" width="700" height="500" >

Your web browser does not support canvas!

</canvas>

اینم با دابل کلیک کار میکنه:

کد:
<script type="text/javascript" >

ondblclick=function(){

var canvas=document.getElementById('C');

r=Math.floor(Math.random() *250);

g=Math.floor(Math.random() *250);

b=Math.floor(Math.random() *250);

m=Math.floor(30+ Math.random() *300);

n=Math.floor(30+ Math.random() *300);

if(canvas.getContext){

var ctx=canvas.getContext('2d');

ctx.save();

ctx.shadowOffsetX=5;

ctx.shadowOffsetY=5;

ctx.shadowBlur=10;

ctx.shadowColor='rgb('+r+','+b+','+g+')';

ctx.fillStyle='rgb('+r+','+b+','+g+')';

ctx.fillRect(n,200,200,100);

ctx.restore();

ctx.beginPath();

ctx.arc(m,150,m,m,Math.PI*2,false);

ctx.lineWidth=2;

ctx.strokeStyle='rgb('+r+','+b+','+g+')';

ctx.stroke();

ctx.beginPath();

ctx.moveTo(m,m);

ctx.lineTo(n,10);

ctx.lineTo(100,10);

ctx.lineTo(n,200);

ctx.closePath();

ctx.lineWidth=2;

ctx.strokeStyle='rgb('+r+','+b+','+g+')';

ctx.stroke();

ctx.font="Bold 17px Arial";

ctx.fillStyle="#008600";

ctx.fillText("منبع: moisrex.rozblog.com",10,315);

}

}

</script>

<canvas id="C" width="700" height="500" >

Your web browser does not support canvas!

</canvas>

اینم پس از هر بار کلیک و برداشتن دکمه کلیک کار میکنه:

کد:
<script type="text/javascript" >

onmouseup=function(){

var canvas=document.getElementById('C');

r=Math.floor(Math.random() *250);

g=Math.floor(Math.random() *250);

b=Math.floor(Math.random() *250);

m=Math.floor(30+ Math.random() *300);

n=Math.floor(30+ Math.random() *300);

if(canvas.getContext){

var ctx=canvas.getContext('2d');

ctx.save();

ctx.shadowOffsetX=5;

ctx.shadowOffsetY=5;

ctx.shadowBlur=10;

ctx.shadowColor='rgb('+r+','+b+','+g+')';

ctx.fillStyle='rgb('+r+','+b+','+g+')';

ctx.fillRect(n,200,200,100);

ctx.restore();

ctx.beginPath();

ctx.arc(m,150,m,m,Math.PI*2,false);

ctx.lineWidth=2;

ctx.strokeStyle='rgb('+r+','+b+','+g+')';

ctx.stroke();

ctx.beginPath();

ctx.moveTo(m,m);

ctx.lineTo(n,10);

ctx.lineTo(100,10);

ctx.lineTo(n,200);

ctx.closePath();

ctx.lineWidth=2;

ctx.strokeStyle='rgb('+r+','+b+','+g+')';

ctx.stroke();

ctx.font="Bold 17px Arial";

ctx.fillStyle="#008600";

ctx.fillText("منبع: moisrex.rozblog.com",10,315);

}

}

</script>

<canvas id="C" width="700" height="500" >

Your web browser does not support canvas!

</canvas>

اینم بعد از هر بار راست کلیک کار میکنه:

کد:
<script type="text/javascript" >

oncontextmenu=function(){

var canvas=document.getElementById('C');

r=Math.floor(Math.random() *250);

g=Math.floor(Math.random() *250);

b=Math.floor(Math.random() *250);

m=Math.floor(30+ Math.random() *300);

n=Math.floor(30+ Math.random() *300);

if(canvas.getContext){

var ctx=canvas.getContext('2d');

ctx.save();

ctx.shadowOffsetX=5;

ctx.shadowOffsetY=5;

ctx.shadowBlur=10;

ctx.shadowColor='rgb('+r+','+b+','+g+')';

ctx.fillStyle='rgb('+r+','+b+','+g+')';

ctx.fillRect(n,200,200,100);

ctx.restore();

ctx.beginPath();

ctx.arc(m,150,m,m,Math.PI*2,false);

ctx.lineWidth=2;

ctx.strokeStyle='rgb('+r+','+b+','+g+')';

ctx.stroke();

ctx.beginPath();

ctx.moveTo(m,m);

ctx.lineTo(n,10);

ctx.lineTo(100,10);

ctx.lineTo(n,200);

ctx.closePath();

ctx.lineWidth=2;

ctx.strokeStyle='rgb('+r+','+b+','+g+')';

ctx.stroke();

ctx.font="Bold 17px Arial";

ctx.fillStyle="#008600";

ctx.fillText("منبع: moisrex.rozblog.com",10,315);

}

}

</script>

<canvas id="C" width="700" height="500" >

Your web browser does not support canvas!

</canvas>

اینم با حرکت ماوس روی canvas نقاشی میکشه: (باحال ترینشون اینه)

کد:
<script type="text/javascript" >

onmousemove=function(){

var canvas=document.getElementById('C');

r=Math.floor(Math.random() *250);

g=Math.floor(Math.random() *250);

b=Math.floor(Math.random() *250);

m=Math.floor(30+ Math.random() *300);

n=Math.floor(30+ Math.random() *300);

if(canvas.getContext){

var ctx=canvas.getContext('2d');

ctx.save();

ctx.shadowOffsetX=5;

ctx.shadowOffsetY=5;

ctx.shadowBlur=10;

ctx.shadowColor='rgb('+r+','+b+','+g+')';

ctx.fillStyle='rgb('+r+','+b+','+g+')';

ctx.fillRect(n,200,200,100);

ctx.restore();

ctx.beginPath();

ctx.arc(m,150,m,m,Math.PI*2,false);

ctx.lineWidth=2;

ctx.strokeStyle='rgb('+r+','+b+','+g+')';

ctx.stroke();

ctx.beginPath();

ctx.moveTo(m,m);

ctx.lineTo(n,10);

ctx.lineTo(100,10);

ctx.lineTo(n,200);

ctx.closePath();

ctx.lineWidth=2;

ctx.strokeStyle='rgb('+r+','+b+','+g+')';

ctx.stroke();

ctx.font="Bold 17px Arial";

ctx.fillStyle="#008600";

ctx.fillText("منبع: moisrex.rozblog.com",10,315);

}

}

</script>

<canvas id="C" width="700" height="500" >

Your web browser does not support canvas!

</canvas>

با تشکر

مردم از بس کد گذاشتم :دی


سه شنبه 14 بهمن 1393 - 19:37
وب کاربرUser's blog ارسال پیامsend p.m. نقل قولReply سپاس گزارمThanks
حمایت شده حمایت شدهThanks : سپاس هاThanks (4) : smaeal - amalian - farnam - amir_reza -
smaeal آفلاین



ارسال‌هاAsnwers : 10648
عضویتRegistration date : 18 /11 /1392
حمایت کردهthanks : 18906
حمایت شدهThanked : 5424
پاسخAnswer 1 : نقاشی با canvas

نوید چرا اینطوری میزاری خو...

بگو میتونین به جای اون onload مثلاً onclick بزارین...


===================================================
☼برای تشکر از دکمه « سپاسگزارم » استفاده نمایید☼
سه شنبه 14 بهمن 1393 - 19:39
وب کاربرUser's blog ارسال پیامSend p.m. نقل قولReply سپاس گزارمThanks
oisrex آفلاین



ارسال‌هاAsnwers : 747
عضویتRegistration date : 4 /8 /1393
حمایت کردهthanks : 231
حمایت شدهThanked : 886
پاسخAnswer 2 : نقاشی با canvas

این جوری گذاشتم که برن چک کنن چه فرق هایی دارن و هر کدوم چه کار میکنن


سه شنبه 14 بهمن 1393 - 19:40
وب کاربرUser's blog ارسال پیامSend p.m. نقل قولReply سپاس گزارمThanks
smaeal آفلاین



ارسال‌هاAsnwers : 10648
عضویتRegistration date : 18 /11 /1392
حمایت کردهthanks : 18906
حمایت شدهThanked : 5424
پاسخAnswer 3 : نقاشی با canvas

خب اینطروری بخوای کد بزاری که سخت میشه...:دی


===================================================
☼برای تشکر از دکمه « سپاسگزارم » استفاده نمایید☼
سه شنبه 14 بهمن 1393 - 19:41
وب کاربرUser's blog ارسال پیامSend p.m. نقل قولReply سپاس گزارمThanks
amalian آفلاین


ارسال‌هاAsnwers : 288
عضویتRegistration date : 14 /10 /1391
حمایت کردهthanks : 234
حمایت شدهThanked : 241
پاسخAnswer 4 : نقاشی با canvas

خیلی خوبه نکته های کاربردی داره

سه شنبه 14 بهمن 1393 - 19:43
ارسال پیامSend p.m. نقل قولReply سپاس گزارمThanks
smaeal آفلاین



ارسال‌هاAsnwers : 10648
عضویتRegistration date : 18 /11 /1392
حمایت کردهthanks : 18906
حمایت شدهThanked : 5424
پاسخAnswer 5 : نقاشی با canvas

در هر حال ممنون...خوب شده...پس سعی کن زیاد خودتو خسته نکنی...


===================================================
☼برای تشکر از دکمه « سپاسگزارم » استفاده نمایید☼
سه شنبه 14 بهمن 1393 - 19:44
وب کاربرUser's blog ارسال پیامSend p.m. نقل قولReply سپاس گزارمThanks
farnam آفلاین


گرافیست

ارسال‌هاAsnwers : 1701
عضویتRegistration date : 14 /12 /1391
حمایت کردهthanks : 662
حمایت شدهThanked : 973
پاسخAnswer 6 : نقاشی با canvas

خيلي خوبه

موفق باشي

با تشكر

یادت باشه که بهترین دوستت همیشه میتونه بهترین ادم در همه شرایط باشه پس قدرشو بدون
------------------------------------------------------------------------------------------------------------------------
دوست های خوبم: محمد، اسماعیل، آقای قیاسی، اقبال، امیر محسن، محمد آر بوی، علیرضا، نوید، مویزبست
سه شنبه 14 بهمن 1393 - 20:03
وب کاربرUser's blog ارسال پیامSend p.m. نقل قولReply سپاس گزارمThanks
smaeal آفلاین



ارسال‌هاAsnwers : 10648
عضویتRegistration date : 18 /11 /1392
حمایت کردهthanks : 18906
حمایت شدهThanked : 5424
پاسخAnswer 7 : نقاشی با canvas

نوید طرح خونه و غیره ی واقعی بکش...سعی کن...


===================================================
☼برای تشکر از دکمه « سپاسگزارم » استفاده نمایید☼
سه شنبه 14 بهمن 1393 - 20:34
وب کاربرUser's blog ارسال پیامSend p.m. نقل قولReply سپاس گزارمThanks



moisrex
درباره ماAbout us لینک های ماOur links کلمات کلیدیKeywords
انجمن تخصصی کدستان ، ساخته شده توسط فردی با نام مستعار Moisrex می باشد.This forum designed by a person who called Moisrex.

ایمیلE-mail : Moisrex @ Gmail.com
کدستان,انجمن کدستان,کدنویسی,انجمن پشتیبانی,فروم,رزبلاگ,آموزش کدنویسی,درخواست کد
تمامی حقوق این انجمن مربوط به همین انجمن می باشد | طراحی قالبCopyright (c) By Moisrex , All rights reserved | Desiger : Moisrex