bocciofila
This commit is contained in:
parent
e602555567
commit
d922f01df1
17
bocciofila/TweenMax.min.js
vendored
Normal file
17
bocciofila/TweenMax.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
bocciofila/arrow-small.png
Normal file
BIN
bocciofila/arrow-small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
bocciofila/arrow.png
Normal file
BIN
bocciofila/arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.5 KiB |
BIN
bocciofila/audiovideo.webm
Normal file
BIN
bocciofila/audiovideo.webm
Normal file
Binary file not shown.
55
bocciofila/autoptimize_62cbd689f055653f750a3761c62266a5.css
Normal file
55
bocciofila/autoptimize_62cbd689f055653f750a3761c62266a5.css
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
.elementor-kit-517{--e-global-color-primary:#6ec1e4;--e-global-color-secondary:#54595f;--e-global-color-text:#7a7a7a;--e-global-color-accent:#61ce70;--e-global-typography-primary-font-family:"Roboto";--e-global-typography-primary-font-weight:600;--e-global-typography-secondary-font-family:"Roboto Slab";--e-global-typography-secondary-font-weight:400;--e-global-typography-text-font-family:"Roboto";--e-global-typography-text-font-weight:400;--e-global-typography-accent-font-family:"Roboto";--e-global-typography-accent-font-weight:500}.elementor-section.elementor-section-boxed>.elementor-container{max-width:1140px}.elementor-widget:not(:last-child){margin-bottom:20px}{}h1.entry-title{display:var(--page-title-display)}@media(max-width:1024px){.elementor-section.elementor-section-boxed>.elementor-container{max-width:1024px}}@media(max-width:767px){.elementor-section.elementor-section-boxed>.elementor-container{max-width:767px}}
|
@ -0,0 +1,210 @@
|
||||
function Winwheel(options,drawWheel)
|
||||
{defaultOptions={'canvasId':'canvas','centerX':null,'centerY':null,'outerRadius':null,'innerRadius':0,'numSegments':1,'drawMode':'code','rotationAngle':0,'textFontFamily':'Arial','textFontSize':20,'textFontWeight':'bold','textOrientation':'horizontal','textAlignment':'center','textDirection':'normal','textMargin':null,'textFillStyle':'black','textStrokeStyle':null,'textLineWidth':1,'fillStyle':'silver','strokeStyle':'black','lineWidth':1,'clearTheCanvas':true,'imageOverlay':false,'drawText':true,'pointerAngle':0,'wheelImage':null,'imageDirection':'N','responsive':false,'scaleFactor':1,};for(let key in defaultOptions){if((options!=null)&&(typeof(options[key])!=='undefined')){this[key]=options[key];}else{this[key]=defaultOptions[key];}}
|
||||
if(options!=null){for(let key in options){if(typeof(this[key])==='undefined'){this[key]=options[key];}}}
|
||||
if(this.canvasId){this.canvas=document.getElementById(this.canvasId);if(this.canvas){if(this.centerX==null){this.centerX=this.canvas.width/2;}
|
||||
if(this.centerY==null){this.centerY=this.canvas.height/2;}
|
||||
if(this.outerRadius==null){if(this.canvas.width<this.canvas.height){this.outerRadius=(this.canvas.width/2)-this.lineWidth;}else{this.outerRadius=(this.canvas.height/2)-this.lineWidth;}}
|
||||
this.ctx=this.canvas.getContext('2d');}else{this.canvas=null;this.ctx=null;}}else{this.canvas=null;this.ctx=null;}
|
||||
this.segments=new Array(null);for(let x=1;x<=this.numSegments;x++){if((options!=null)&&(options['segments'])&&(typeof(options['segments'][x-1])!=='undefined')){this.segments[x]=new Segment(options['segments'][x-1]);}else{this.segments[x]=new Segment();}}
|
||||
this.updateSegmentSizes();if(this.textMargin===null){this.textMargin=(this.textFontSize/1.7);}
|
||||
if((options!=null)&&(options['animation'])&&(typeof(options['animation'])!=='undefined')){this.animation=new Animation(options['animation']);}else{this.animation=new Animation();}
|
||||
if((options!=null)&&(options['pins'])&&(typeof(options['pins'])!=='undefined')){this.pins=new Pin(options['pins']);}
|
||||
if((this.drawMode=='image')||(this.drawMode=='segmentImage')){if(typeof(options['fillStyle'])==='undefined'){this.fillStyle=null;}
|
||||
if(typeof(options['strokeStyle'])==='undefined'){this.strokeStyle='red';}
|
||||
if(typeof(options['drawText'])==='undefined'){this.drawText=false;}
|
||||
if(typeof(options['lineWidth'])==='undefined'){this.lineWidth=1;}
|
||||
if(typeof(drawWheel)==='undefined'){drawWheel=false;}}else{if(typeof(drawWheel)==='undefined'){drawWheel=true;}}
|
||||
if((options!=null)&&(options['pointerGuide'])&&(typeof(options['pointerGuide'])!=='undefined')){this.pointerGuide=new PointerGuide(options['pointerGuide']);}else{this.pointerGuide=new PointerGuide();}
|
||||
if(this.responsive){winwheelToDrawDuringAnimation=this;this._originalCanvasWidth=this.canvas.width;this._originalCanvasHeight=this.canvas.height;this._responsiveScaleHeight=this.canvas.dataset.responsivescaleheight;this._responsiveMinWidth=this.canvas.dataset.responsiveminwidth;this._responsiveMinHeight=this.canvas.dataset.responsiveminheight;this._responsiveMargin=this.canvas.dataset.responsivemargin;window.addEventListener("load",winwheelResize);window.addEventListener("resize",winwheelResize);}
|
||||
if(drawWheel==true){this.draw(this.clearTheCanvas);}else if(this.drawMode=='segmentImage'){winwheelToDrawDuringAnimation=this;winhweelAlreadyDrawn=false;for(let y=1;y<=this.numSegments;y++){if(this.segments[y].image!==null){this.segments[y].imgData=new Image();this.segments[y].imgData.onload=winwheelLoadedImage;this.segments[y].imgData.src=this.segments[y].image;}}}}
|
||||
Winwheel.prototype.updateSegmentSizes=function()
|
||||
{if(this.segments){let arcUsed=0;let numSet=0;for(let x=1;x<=this.numSegments;x++){if(this.segments[x].size!==null){arcUsed+=this.segments[x].size;numSet++;}}
|
||||
let arcLeft=(360-arcUsed);let degreesEach=0;if(arcLeft>0){degreesEach=(arcLeft/(this.numSegments-numSet));}
|
||||
let currentDegree=0;for(let x=1;x<=this.numSegments;x++){this.segments[x].startAngle=currentDegree;if(this.segments[x].size){currentDegree+=this.segments[x].size;}else{currentDegree+=degreesEach;}
|
||||
this.segments[x].endAngle=currentDegree;}}}
|
||||
Winwheel.prototype.clearCanvas=function()
|
||||
{if(this.ctx){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);}}
|
||||
Winwheel.prototype.draw=function(clearTheCanvas)
|
||||
{if(this.ctx){if(typeof(clearTheCanvas)!=='undefined'){if(clearTheCanvas==true){this.clearCanvas();}}else{this.clearCanvas();}
|
||||
if(this.drawMode=='image'){this.drawWheelImage();if(this.drawText==true){this.drawSegmentText();}
|
||||
if(this.imageOverlay==true){this.drawSegments();}}else if(this.drawMode=='segmentImage'){this.drawSegmentImages();if(this.drawText==true){this.drawSegmentText();}
|
||||
if(this.imageOverlay==true){this.drawSegments();}}else{this.drawSegments();if(this.drawText==true){this.drawSegmentText();}}
|
||||
if(typeof this.pins!=='undefined'){if(this.pins.visible==true){this.drawPins();}}
|
||||
if(this.pointerGuide.display==true){this.drawPointerGuide();}}}
|
||||
Winwheel.prototype.drawPins=function()
|
||||
{if((this.pins)&&(this.pins.number)){let centerX=(this.centerX*this.scaleFactor);let centerY=(this.centerY*this.scaleFactor);let outerRadius=(this.outerRadius*this.scaleFactor);let pinOuterRadius=this.pins.outerRadius;let pinMargin=this.pins.margin;if(this.pins.responsive){pinOuterRadius=(this.pins.outerRadius*this.scaleFactor);pinMargin=(this.pins.margin*this.scaleFactor);}
|
||||
let pinSpacing=(360/this.pins.number);for(let i=1;i<=this.pins.number;i++){this.ctx.save();this.ctx.strokeStyle=this.pins.strokeStyle;this.ctx.lineWidth=this.pins.lineWidth;this.ctx.fillStyle=this.pins.fillStyle;this.ctx.translate(centerX,centerY);this.ctx.rotate(this.degToRad(i*pinSpacing+this.rotationAngle));this.ctx.translate(-centerX,-centerY);this.ctx.beginPath();this.ctx.arc(centerX,(centerY-outerRadius)+pinOuterRadius+pinMargin,pinOuterRadius,0,2*Math.PI);if(this.pins.fillStyle){this.ctx.fill();}
|
||||
if(this.pins.strokeStyle){this.ctx.stroke();}
|
||||
this.ctx.restore();}}}
|
||||
Winwheel.prototype.drawPointerGuide=function()
|
||||
{if(this.ctx){let centerX=(this.centerX*this.scaleFactor);let centerY=(this.centerY*this.scaleFactor);let outerRadius=(this.outerRadius*this.scaleFactor);this.ctx.save();this.ctx.translate(centerX,centerY);this.ctx.rotate(this.degToRad(this.pointerAngle));this.ctx.translate(-centerX,-centerY);this.ctx.strokeStyle=this.pointerGuide.strokeStyle;this.ctx.lineWidth=this.pointerGuide.lineWidth;this.ctx.beginPath();this.ctx.moveTo(centerX,centerY);this.ctx.lineTo(centerX,-(outerRadius/4));this.ctx.stroke();this.ctx.restore();}}
|
||||
Winwheel.prototype.drawWheelImage=function()
|
||||
{if(this.wheelImage!=null){let centerX=(this.centerX*this.scaleFactor);let centerY=(this.centerY*this.scaleFactor);let scaledWidth=(this.wheelImage.width*this.scaleFactor);let scaledHeight=(this.wheelImage.height*this.scaleFactor);let imageLeft=(centerX-(scaledWidth/2));let imageTop=(centerY-(scaledHeight/2));this.ctx.save();this.ctx.translate(centerX,centerY);this.ctx.rotate(this.degToRad(this.rotationAngle));this.ctx.translate(-centerX,-centerY);this.ctx.drawImage(this.wheelImage,imageLeft,imageTop,scaledWidth,scaledHeight);this.ctx.restore();}}
|
||||
Winwheel.prototype.drawSegmentImages=function()
|
||||
{if(this.ctx){let centerX=(this.centerX*this.scaleFactor);let centerY=(this.centerY*this.scaleFactor);if(this.segments){for(let x=1;x<=this.numSegments;x++){let seg=this.segments[x];if(seg.imgData.height){let imageLeft=0;let imageTop=0;let imageAngle=0;let imageDirection='';let scaledWidth=(seg.imgData.width*this.scaleFactor);let scaledHeight=(seg.imgData.height*this.scaleFactor);if(seg.imageDirection!==null){imageDirection=seg.imageDirection;}else{imageDirection=this.imageDirection;}
|
||||
if(imageDirection=='S'){imageLeft=(centerX-(scaledWidth/2));imageTop=centerY;imageAngle=(seg.startAngle+180+((seg.endAngle-seg.startAngle)/2));}else if(imageDirection=='E'){imageLeft=centerX;imageTop=(centerY-(scaledHeight/2));imageAngle=(seg.startAngle+270+((seg.endAngle-seg.startAngle)/2));}else if(imageDirection=='W'){imageLeft=(centerX-scaledWidth);imageTop=(centerY-(scaledHeight/2));imageAngle=(seg.startAngle+90+((seg.endAngle-seg.startAngle)/2));}else{imageLeft=(centerX-(scaledWidth/2));imageTop=(centerY-scaledHeight);imageAngle=(seg.startAngle+((seg.endAngle-seg.startAngle)/2));}
|
||||
this.ctx.save();this.ctx.translate(centerX,centerY);this.ctx.rotate(this.degToRad(this.rotationAngle+imageAngle));this.ctx.translate(-centerX,-centerY);this.ctx.drawImage(seg.imgData,imageLeft,imageTop,scaledWidth,scaledHeight);this.ctx.restore();}else{console.log('Segment '+x+' imgData is not loaded');}}}}}
|
||||
Winwheel.prototype.drawSegments=function()
|
||||
{if(this.ctx){if(this.segments){let centerX=(this.centerX*this.scaleFactor);let centerY=(this.centerY*this.scaleFactor);let innerRadius=(this.innerRadius*this.scaleFactor);let outerRadius=(this.outerRadius*this.scaleFactor);for(let x=1;x<=this.numSegments;x++){let seg=this.segments[x];let fillStyle;let lineWidth;let strokeStyle;if(seg.fillStyle!==null){fillStyle=seg.fillStyle;}else{fillStyle=this.fillStyle;}
|
||||
this.ctx.fillStyle=fillStyle;if(seg.lineWidth!==null){lineWidth=seg.lineWidth;}else{lineWidth=this.lineWidth;}
|
||||
this.ctx.lineWidth=lineWidth;if(seg.strokeStyle!==null){strokeStyle=seg.strokeStyle;}else{strokeStyle=this.strokeStyle;}
|
||||
this.ctx.strokeStyle=strokeStyle;if((strokeStyle)||(fillStyle)){this.ctx.beginPath();if(!this.innerRadius){this.ctx.moveTo(centerX,centerY);}else{let iX=Math.cos(this.degToRad(seg.startAngle+this.rotationAngle-90))*(innerRadius-lineWidth/2);let iY=Math.sin(this.degToRad(seg.startAngle+this.rotationAngle-90))*(innerRadius-lineWidth/2);this.ctx.moveTo(centerX+iX,centerY+iY);}
|
||||
this.ctx.arc(centerX,centerY,outerRadius,this.degToRad(seg.startAngle+this.rotationAngle-90),this.degToRad(seg.endAngle+this.rotationAngle-90),false);if(this.innerRadius){this.ctx.arc(centerX,centerY,innerRadius,this.degToRad(seg.endAngle+this.rotationAngle-90),this.degToRad(seg.startAngle+this.rotationAngle-90),true);}else{this.ctx.lineTo(centerX,centerY);}
|
||||
if(fillStyle){this.ctx.fill();}
|
||||
if(strokeStyle){this.ctx.stroke();}}}}}}
|
||||
Winwheel.prototype.drawSegmentText=function()
|
||||
{if(this.ctx){let fontFamily;let fontSize;let fontWeight;let orientation;let alignment;let direction;let margin;let fillStyle;let strokeStyle;let lineWidth;let fontSetting;let centerX=(this.centerX*this.scaleFactor);let centerY=(this.centerY*this.scaleFactor);let outerRadius=(this.outerRadius*this.scaleFactor);let innerRadius=(this.innerRadius*this.scaleFactor);for(let x=1;x<=this.numSegments;x++){this.ctx.save();let seg=this.segments[x];if(seg.text){if(seg.textFontFamily!==null)fontFamily=seg.textFontFamily;else fontFamily=this.textFontFamily;if(seg.textFontSize!==null)fontSize=seg.textFontSize;else fontSize=this.textFontSize;if(seg.textFontWeight!==null)fontWeight=seg.textFontWeight;else fontWeight=this.textFontWeight;if(seg.textOrientation!==null)orientation=seg.textOrientation;else orientation=this.textOrientation;if(seg.textAlignment!==null)alignment=seg.textAlignment;else alignment=this.textAlignment;if(seg.textDirection!==null)direction=seg.textDirection;else direction=this.textDirection;if(seg.textMargin!==null)margin=seg.textMargin;else margin=this.textMargin;if(seg.textFillStyle!==null)fillStyle=seg.textFillStyle;else fillStyle=this.textFillStyle;if(seg.textStrokeStyle!==null)strokeStyle=seg.textStrokeStyle;else strokeStyle=this.textStrokeStyle;if(seg.textLineWidth!==null)lineWidth=seg.textLineWidth;else lineWidth=this.textLineWidth;fontSize=(fontSize*this.scaleFactor);margin=(margin*this.scaleFactor);let fontSetting='';if(fontWeight!=null){fontSetting+=fontWeight+' ';}
|
||||
if(fontSize!=null){fontSetting+=fontSize+'px ';}
|
||||
if(fontFamily!=null){fontSetting+=fontFamily;}
|
||||
this.ctx.font=fontSetting;this.ctx.fillStyle=fillStyle;this.ctx.strokeStyle=strokeStyle;this.ctx.lineWidth=lineWidth;let lines=seg.text.split('\n');let lineOffset=0-(fontSize*(lines.length/2))+(fontSize/2);if((orientation=='curved')&&((alignment=='inner')||(alignment=='outer'))){lineOffset=0;}
|
||||
for(let i=0;i<lines.length;i++){if(direction=='reversed'){if(orientation=='horizontal'){if(alignment=='inner'){this.ctx.textAlign='right';}else if(alignment=='outer'){this.ctx.textAlign='left';}else{this.ctx.textAlign='center';}
|
||||
this.ctx.textBaseline='middle';let textAngle=this.degToRad((seg.endAngle-((seg.endAngle-seg.startAngle)/2)+this.rotationAngle-90)-180);this.ctx.save();this.ctx.translate(centerX,centerY);this.ctx.rotate(textAngle);this.ctx.translate(-centerX,-centerY);if(alignment=='inner'){if(fillStyle){this.ctx.fillText(lines[i],centerX-innerRadius-margin,centerY+lineOffset);}
|
||||
if(strokeStyle){this.ctx.strokeText(lines[i],centerX-innerRadius-margin,centerY+lineOffset);}}else if(alignment=='outer'){if(fillStyle){this.ctx.fillText(lines[i],centerX-outerRadius+margin,centerY+lineOffset);}
|
||||
if(strokeStyle){this.ctx.strokeText(lines[i],centerX-outerRadius+margin,centerY+lineOffset);}}else{if(fillStyle){this.ctx.fillText(lines[i],centerX-innerRadius-((outerRadius-innerRadius)/2)-margin,centerY+lineOffset);}
|
||||
if(strokeStyle){this.ctx.strokeText(lines[i],centerX-innerRadius-((outerRadius-innerRadius)/2)-margin,centerY+lineOffset);}}
|
||||
this.ctx.restore();}else if(orientation=='vertical'){this.ctx.textAlign='center';if(alignment=='inner'){this.ctx.textBaseline='top';}else if(alignment=='outer'){this.ctx.textBaseline='bottom';}else{this.ctx.textBaseline='middle';}
|
||||
let textAngle=(seg.endAngle-((seg.endAngle-seg.startAngle)/2)-180);textAngle+=this.rotationAngle;this.ctx.save();this.ctx.translate(centerX,centerY);this.ctx.rotate(this.degToRad(textAngle));this.ctx.translate(-centerX,-centerY);let yPos=0;if(alignment=='outer'){yPos=(centerY+outerRadius-margin);}else if(alignment=='inner'){yPos=(centerY+innerRadius+margin);}
|
||||
let yInc=(fontSize-(fontSize/9));if(alignment=='outer'){for(let c=(lines[i].length-1);c>=0;c--){let character=lines[i].charAt(c);if(fillStyle){this.ctx.fillText(character,centerX+lineOffset,yPos);}
|
||||
if(strokeStyle){this.ctx.strokeText(character,centerX+lineOffset,yPos);}
|
||||
yPos-=yInc;}}else if(alignment=='inner'){for(let c=0;c<lines[i].length;c++){let character=lines[i].charAt(c);if(fillStyle){this.ctx.fillText(character,centerX+lineOffset,yPos);}
|
||||
if(strokeStyle){this.ctx.strokeText(character,centerX+lineOffset,yPos);}
|
||||
yPos+=yInc;}}else if(alignment=='center'){let centerAdjustment=0;if(lines[i].length>1){centerAdjustment=(yInc*(lines[i].length-1)/2);}
|
||||
let yPos=(centerY+innerRadius+((outerRadius-innerRadius)/2))+centerAdjustment+margin;for(let c=(lines[i].length-1);c>=0;c--){let character=lines[i].charAt(c);if(fillStyle){this.ctx.fillText(character,centerX+lineOffset,yPos);}
|
||||
if(strokeStyle){this.ctx.strokeText(character,centerX+lineOffset,yPos);}
|
||||
yPos-=yInc;}}
|
||||
this.ctx.restore();}else if(orientation=='curved'){let radius=0;if(alignment=='inner'){radius=innerRadius+margin;this.ctx.textBaseline='top';}else if(alignment=='outer'){radius=outerRadius-margin;this.ctx.textBaseline='bottom';radius-=(fontSize*(lines.length-1));}else if(alignment=='center'){radius=innerRadius+margin+((outerRadius-innerRadius)/2);this.ctx.textBaseline='middle';}
|
||||
let anglePerChar=0;let drawAngle=0;if(lines[i].length>1){this.ctx.textAlign='left';anglePerChar=(4*(fontSize/10));let radiusPercent=(100/radius);anglePerChar=(anglePerChar*radiusPercent);let totalArc=(anglePerChar*lines[i].length);drawAngle=seg.startAngle+(((seg.endAngle-seg.startAngle)/2)-(totalArc/2));}else{drawAngle=(seg.startAngle+((seg.endAngle-seg.startAngle)/2));this.ctx.textAlign='center';}
|
||||
drawAngle+=this.rotationAngle;drawAngle-=180;for(let c=lines[i].length;c>=0;c--){this.ctx.save();let character=lines[i].charAt(c);this.ctx.translate(centerX,centerY);this.ctx.rotate(this.degToRad(drawAngle));this.ctx.translate(-centerX,-centerY);if(strokeStyle){this.ctx.strokeText(character,centerX,centerY+radius+lineOffset);}
|
||||
if(fillStyle){this.ctx.fillText(character,centerX,centerY+radius+lineOffset);}
|
||||
drawAngle+=anglePerChar;this.ctx.restore();}}}else{if(orientation=='horizontal'){if(alignment=='inner'){this.ctx.textAlign='left';}else if(alignment=='outer'){this.ctx.textAlign='right';}else{this.ctx.textAlign='center';}
|
||||
this.ctx.textBaseline='middle';let textAngle=this.degToRad(seg.endAngle-((seg.endAngle-seg.startAngle)/2)+this.rotationAngle-90);this.ctx.save();this.ctx.translate(centerX,centerY);this.ctx.rotate(textAngle);this.ctx.translate(-centerX,-centerY);if(alignment=='inner'){if(fillStyle){this.ctx.fillText(lines[i],centerX+innerRadius+margin,centerY+lineOffset);}
|
||||
if(strokeStyle){this.ctx.strokeText(lines[i],centerX+innerRadius+margin,centerY+lineOffset);}}else if(alignment=='outer'){if(fillStyle){this.ctx.fillText(lines[i],centerX+outerRadius-margin,centerY+lineOffset);}
|
||||
if(strokeStyle){this.ctx.strokeText(lines[i],centerX+outerRadius-margin,centerY+lineOffset);}}else{if(fillStyle){this.ctx.fillText(lines[i],centerX+innerRadius+((outerRadius-innerRadius)/2)+margin,centerY+lineOffset);}
|
||||
if(strokeStyle){this.ctx.strokeText(lines[i],centerX+innerRadius+((outerRadius-innerRadius)/2)+margin,centerY+lineOffset);}}
|
||||
this.ctx.restore();}else if(orientation=='vertical'){this.ctx.textAlign='center';if(alignment=='inner'){this.ctx.textBaseline='bottom';}else if(alignment=='outer'){this.ctx.textBaseline='top';}else{this.ctx.textBaseline='middle';}
|
||||
let textAngle=seg.endAngle-((seg.endAngle-seg.startAngle)/2);textAngle+=this.rotationAngle;this.ctx.save();this.ctx.translate(centerX,centerY);this.ctx.rotate(this.degToRad(textAngle));this.ctx.translate(-centerX,-centerY);let yPos=0;if(alignment=='outer'){yPos=(centerY-outerRadius+margin);}else if(alignment=='inner'){yPos=(centerY-innerRadius-margin);}
|
||||
let yInc=(fontSize-(fontSize/9));if(alignment=='outer'){for(let c=0;c<lines[i].length;c++){let character=lines[i].charAt(c);if(fillStyle){this.ctx.fillText(character,centerX+lineOffset,yPos);}
|
||||
if(strokeStyle){this.ctx.strokeText(character,centerX+lineOffset,yPos);}
|
||||
yPos+=yInc;}}else if(alignment=='inner'){for(let c=(lines[i].length-1);c>=0;c--){let character=lines[i].charAt(c);if(fillStyle){this.ctx.fillText(character,centerX+lineOffset,yPos);}
|
||||
if(strokeStyle){this.ctx.strokeText(character,centerX+lineOffset,yPos);}
|
||||
yPos-=yInc;}}else if(alignment=='center'){let centerAdjustment=0;if(lines[i].length>1){centerAdjustment=(yInc*(lines[i].length-1)/2);}
|
||||
let yPos=(centerY-innerRadius-((outerRadius-innerRadius)/2))-centerAdjustment-margin;for(let c=0;c<lines[i].length;c++){let character=lines[i].charAt(c);if(fillStyle){this.ctx.fillText(character,centerX+lineOffset,yPos);}
|
||||
if(strokeStyle){this.ctx.strokeText(character,centerX+lineOffset,yPos);}
|
||||
yPos+=yInc;}}
|
||||
this.ctx.restore();}else if(orientation=='curved'){let radius=0;if(alignment=='inner'){radius=innerRadius+margin;this.ctx.textBaseline='bottom';radius+=(fontSize*(lines.length-1));}else if(alignment=='outer'){radius=outerRadius-margin;this.ctx.textBaseline='top';}else if(alignment=='center'){radius=innerRadius+margin+((outerRadius-innerRadius)/2);this.ctx.textBaseline='middle';}
|
||||
let anglePerChar=0;let drawAngle=0;if(lines[i].length>1){this.ctx.textAlign='left';anglePerChar=(4*(fontSize/10));let radiusPercent=(100/radius);anglePerChar=(anglePerChar*radiusPercent);let totalArc=(anglePerChar*lines[i].length);drawAngle=seg.startAngle+(((seg.endAngle-seg.startAngle)/2)-(totalArc/2));}else{drawAngle=(seg.startAngle+((seg.endAngle-seg.startAngle)/2));this.ctx.textAlign='center';}
|
||||
drawAngle+=this.rotationAngle;for(let c=0;c<(lines[i].length);c++){this.ctx.save();let character=lines[i].charAt(c);this.ctx.translate(centerX,centerY);this.ctx.rotate(this.degToRad(drawAngle));this.ctx.translate(-centerX,-centerY);if(strokeStyle){this.ctx.strokeText(character,centerX,centerY-radius+lineOffset);}
|
||||
if(fillStyle){this.ctx.fillText(character,centerX,centerY-radius+lineOffset);}
|
||||
drawAngle+=anglePerChar;this.ctx.restore();}}}
|
||||
lineOffset+=fontSize;}}
|
||||
this.ctx.restore();}}}
|
||||
Winwheel.prototype.degToRad=function(d)
|
||||
{return d*0.0174532925199432957;}
|
||||
Winwheel.prototype.setCenter=function(x,y)
|
||||
{this.centerX=x;this.centerY=y;}
|
||||
Winwheel.prototype.addSegment=function(options,position)
|
||||
{let newSegment=new Segment(options);this.numSegments++;let segmentPos;if(typeof position!=='undefined'){for(let x=this.numSegments;x>position;x--){this.segments[x]=this.segments[x-1];}
|
||||
this.segments[position]=newSegment;segmentPos=position;}else{this.segments[this.numSegments]=newSegment;segmentPos=this.numSegments;}
|
||||
this.updateSegmentSizes();return this.segments[segmentPos];}
|
||||
Winwheel.prototype.setCanvasId=function(canvasId)
|
||||
{if(canvasId){this.canvasId=canvasId;this.canvas=document.getElementById(this.canvasId);if(this.canvas){this.ctx=this.canvas.getContext('2d');}}else{this.canvasId=null
|
||||
this.ctx=null;this.canvas=null;}}
|
||||
Winwheel.prototype.deleteSegment=function(position)
|
||||
{if(this.numSegments>1){if(typeof position!=='undefined'){for(let x=position;x<this.numSegments;x++){this.segments[x]=this.segments[x+1];}}
|
||||
this.segments[this.numSegments]=undefined;this.numSegments--;this.updateSegmentSizes();}}
|
||||
Winwheel.prototype.windowToCanvas=function(x,y)
|
||||
{let bbox=this.canvas.getBoundingClientRect();return{x:Math.floor(x-bbox.left*(this.canvas.width/bbox.width)),y:Math.floor(y-bbox.top*(this.canvas.height/bbox.height))};}
|
||||
Winwheel.prototype.getSegmentAt=function(x,y)
|
||||
{let foundSegment=null;let segmentNumber=this.getSegmentNumberAt(x,y);if(segmentNumber!==null){foundSegment=this.segments[segmentNumber];}
|
||||
return foundSegment;}
|
||||
Winwheel.prototype.getSegmentNumberAt=function(x,y)
|
||||
{let loc=this.windowToCanvas(x,y);let topBottom;let leftRight;let adjacentSideLength;let oppositeSideLength;let hypotenuseSideLength;let centerX=(this.centerX*this.scaleFactor);let centerY=(this.centerY*this.scaleFactor);let outerRadius=(this.outerRadius*this.scaleFactor);let innerRadius=(this.innerRadius*this.scaleFactor);if(loc.x>centerX){adjacentSideLength=(loc.x-centerX);leftRight='R';}else{adjacentSideLength=(centerX-loc.x);leftRight='L';}
|
||||
if(loc.y>centerY){oppositeSideLength=(loc.y-centerY);topBottom='B';}else{oppositeSideLength=(centerY-loc.y);topBottom='T';}
|
||||
let tanVal=oppositeSideLength/adjacentSideLength;let result=(Math.atan(tanVal)*180/Math.PI);let locationAngle=0;hypotenuseSideLength=Math.sqrt((oppositeSideLength*oppositeSideLength)+(adjacentSideLength*adjacentSideLength));if((topBottom=='T')&&(leftRight=='R')){locationAngle=Math.round(90-result);}else if((topBottom=='B')&&(leftRight=='R')){locationAngle=Math.round(result+90);}else if((topBottom=='B')&&(leftRight=='L')){locationAngle=Math.round((90-result)+180);}else if((topBottom=='T')&&(leftRight=='L')){locationAngle=Math.round(result+270);}
|
||||
if(this.rotationAngle!=0){let rotatedPosition=this.getRotationPosition();locationAngle=(locationAngle-rotatedPosition);if(locationAngle<0){locationAngle=(360-Math.abs(locationAngle));}}
|
||||
let foundSegmentNumber=null;for(let x=1;x<=this.numSegments;x++){if((locationAngle>=this.segments[x].startAngle)&&(locationAngle<=this.segments[x].endAngle)){if((hypotenuseSideLength>=innerRadius)&&(hypotenuseSideLength<=outerRadius)){foundSegmentNumber=x;break;}}}
|
||||
return foundSegmentNumber;}
|
||||
Winwheel.prototype.getIndicatedSegment=function()
|
||||
{let prizeNumber=this.getIndicatedSegmentNumber();return this.segments[prizeNumber];}
|
||||
Winwheel.prototype.getIndicatedSegmentNumber=function()
|
||||
{let indicatedPrize=0;let rawAngle=this.getRotationPosition();let relativeAngle=Math.floor(this.pointerAngle-rawAngle);if(relativeAngle<0){relativeAngle=360-Math.abs(relativeAngle);}
|
||||
for(let x=1;x<(this.segments.length);x++){if((relativeAngle>=this.segments[x]['startAngle'])&&(relativeAngle<=this.segments[x]['endAngle'])){indicatedPrize=x;break;}}
|
||||
return indicatedPrize;}
|
||||
Winwheel.prototype.getCurrentPinNumber=function()
|
||||
{let currentPin=0;if(this.pins){let rawAngle=this.getRotationPosition();let relativeAngle=Math.floor(this.pointerAngle-rawAngle);if(relativeAngle<0){relativeAngle=360-Math.abs(relativeAngle);}
|
||||
let pinSpacing=(360/this.pins.number);let totalPinAngle=0;for(let x=0;x<(this.pins.number);x++){if((relativeAngle>=totalPinAngle)&&(relativeAngle<=(totalPinAngle+pinSpacing))){currentPin=x;break;}
|
||||
totalPinAngle+=pinSpacing;}
|
||||
if(this.animation.direction=='clockwise'){currentPin++;if(currentPin>this.pins.number){currentPin=0;}}}
|
||||
return currentPin;}
|
||||
Winwheel.prototype.getRotationPosition=function()
|
||||
{let rawAngle=this.rotationAngle;if(rawAngle>=0){if(rawAngle>360){let timesPast360=Math.floor(rawAngle/360);rawAngle=(rawAngle-(360*timesPast360));}}else{if(rawAngle<-360){let timesPast360=Math.ceil(rawAngle/360);rawAngle=(rawAngle-(360*timesPast360));}
|
||||
rawAngle=(360+rawAngle);}
|
||||
return rawAngle;}
|
||||
Winwheel.prototype.startAnimation=function()
|
||||
{if(this.animation){this.computeAnimation();winwheelToDrawDuringAnimation=this;let properties=new Array(null);properties[this.animation.propertyName]=this.animation.propertyValue;properties['yoyo']=this.animation.yoyo;properties['repeat']=this.animation.repeat;properties['ease']=this.animation.easing;properties['onUpdate']=winwheelAnimationLoop;properties['onComplete']=winwheelStopAnimation;this.tween=TweenMax.to(this,this.animation.duration,properties);}}
|
||||
Winwheel.prototype.stopAnimation=function(canCallback)
|
||||
{if(winwheelToDrawDuringAnimation){if(winwheelToDrawDuringAnimation.tween){winwheelToDrawDuringAnimation.tween.kill();}
|
||||
winwheelStopAnimation(canCallback);}
|
||||
winwheelToDrawDuringAnimation=this;}
|
||||
Winwheel.prototype.pauseAnimation=function()
|
||||
{if(this.tween){this.tween.pause();}}
|
||||
Winwheel.prototype.resumeAnimation=function()
|
||||
{if(this.tween){this.tween.play();}}
|
||||
Winwheel.prototype.computeAnimation=function()
|
||||
{if(this.animation){if(this.animation.type=='spinOngoing'){this.animation.propertyName='rotationAngle';if(this.animation.spins==null){this.animation.spins=5;}
|
||||
if(this.animation.repeat==null){this.animation.repeat=-1;}
|
||||
if(this.animation.easing==null){this.animation.easing='Linear.easeNone';}
|
||||
if(this.animation.yoyo==null){this.animation.yoyo=false;}
|
||||
this.animation.propertyValue=(this.animation.spins*360);if(this.animation.direction=='anti-clockwise'){this.animation.propertyValue=(0-this.animation.propertyValue);}}else if(this.animation.type=='spinToStop'){this.animation.propertyName='rotationAngle';if(this.animation.spins==null){this.animation.spins=5;}
|
||||
if(this.animation.repeat==null){this.animation.repeat=0;}
|
||||
if(this.animation.easing==null){this.animation.easing='Power3.easeOut';}
|
||||
if(this.animation.stopAngle==null){this.animation._stopAngle=Math.floor((Math.random()*359));}else{this.animation._stopAngle=(360-this.animation.stopAngle+this.pointerAngle);}
|
||||
if(this.animation.yoyo==null){this.animation.yoyo=false;}
|
||||
this.animation.propertyValue=(this.animation.spins*360);if(this.animation.direction=='anti-clockwise'){this.animation.propertyValue=(0-this.animation.propertyValue);this.animation.propertyValue-=(360-this.animation._stopAngle);}else{this.animation.propertyValue+=this.animation._stopAngle;}}else if(this.animation.type=='spinAndBack'){this.animation.propertyName='rotationAngle';if(this.animation.spins==null){this.animation.spins=5;}
|
||||
if(this.animation.repeat==null){this.animation.repeat=1;}
|
||||
if(this.animation.easing==null){this.animation.easing='Power2.easeInOut';}
|
||||
if(this.animation.yoyo==null){this.animation.yoyo=true;}
|
||||
if(this.animation.stopAngle==null){this.animation._stopAngle=0;}else{this.animation._stopAngle=(360-this.animation.stopAngle);}
|
||||
this.animation.propertyValue=(this.animation.spins*360);if(this.animation.direction=='anti-clockwise'){this.animation.propertyValue=(0-this.animation.propertyValue);this.animation.propertyValue-=(360-this.animation._stopAngle);}else{this.animation.propertyValue+=this.animation._stopAngle;}}else if(this.animation.type=='custom'){}}}
|
||||
Winwheel.prototype.getRandomForSegment=function(segmentNumber)
|
||||
{let stopAngle=0;if(segmentNumber){if(typeof this.segments[segmentNumber]!=='undefined'){let startAngle=this.segments[segmentNumber].startAngle;let endAngle=this.segments[segmentNumber].endAngle;let range=(endAngle-startAngle)-2;if(range>0){stopAngle=(startAngle+1+Math.floor((Math.random()*range)));}else{console.log('Segment size is too small to safely get random angle inside it');}}else{console.log('Segment '+segmentNumber+' undefined');}}else{console.log('Segment number not specified');}
|
||||
return stopAngle;}
|
||||
function Pin(options)
|
||||
{let defaultOptions={'visible':true,'number':36,'outerRadius':3,'fillStyle':'grey','strokeStyle':'black','lineWidth':1,'margin':3,'responsive':false,};for(let key in defaultOptions){if((options!=null)&&(typeof(options[key])!=='undefined')){this[key]=options[key];}else{this[key]=defaultOptions[key];}}
|
||||
if(options!=null){for(let key in options){if(typeof(this[key])==='undefined'){this[key]=options[key];}}}}
|
||||
function Animation(options)
|
||||
{let defaultOptions={'type':'spinOngoing','direction':'clockwise','propertyName':null,'propertyValue':null,'duration':10,'yoyo':false,'repeat':null,'easing':null,'stopAngle':null,'spins':null,'clearTheCanvas':null,'callbackFinished':null,'callbackBefore':null,'callbackAfter':null,'callbackSound':null,'soundTrigger':'segment'};for(let key in defaultOptions){if((options!=null)&&(typeof(options[key])!=='undefined')){this[key]=options[key];}else{this[key]=defaultOptions[key];}}
|
||||
if(options!=null){for(let key in options){if(typeof(this[key])==='undefined'){this[key]=options[key];}}}}
|
||||
function Segment(options)
|
||||
{let defaultOptions={'size':null,'text':'','fillStyle':null,'strokeStyle':null,'lineWidth':null,'textFontFamily':null,'textFontSize':null,'textFontWeight':null,'textOrientation':null,'textAlignment':null,'textDirection':null,'textMargin':null,'textFillStyle':null,'textStrokeStyle':null,'textLineWidth':null,'image':null,'imageDirection':null,'imgData':null};for(let key in defaultOptions){if((options!=null)&&(typeof(options[key])!=='undefined')){this[key]=options[key];}else{this[key]=defaultOptions[key];}}
|
||||
if(options!=null){for(let key in options){if(typeof(this[key])==='undefined'){this[key]=options[key];}}}
|
||||
this.startAngle=0;this.endAngle=0;}
|
||||
Segment.prototype.changeImage=function(image,imageDirection)
|
||||
{this.image=image;this.imgData=null;if(imageDirection){this.imageDirection=imageDirection;}
|
||||
winhweelAlreadyDrawn=false;this.imgData=new Image();this.imgData.onload=winwheelLoadedImage;this.imgData.src=this.image;}
|
||||
function PointerGuide(options)
|
||||
{let defaultOptions={'display':false,'strokeStyle':'red','lineWidth':3};for(let key in defaultOptions){if((options!=null)&&(typeof(options[key])!=='undefined')){this[key]=options[key];}else{this[key]=defaultOptions[key];}}}
|
||||
function winwheelPercentToDegrees(percentValue)
|
||||
{let degrees=0;if((percentValue>0)&&(percentValue<=100)){let divider=(percentValue/100);degrees=(360*divider);}
|
||||
return degrees;}
|
||||
function winwheelAnimationLoop()
|
||||
{if(winwheelToDrawDuringAnimation){if(winwheelToDrawDuringAnimation.animation.clearTheCanvas!=false){winwheelToDrawDuringAnimation.ctx.clearRect(0,0,winwheelToDrawDuringAnimation.canvas.width,winwheelToDrawDuringAnimation.canvas.height);}
|
||||
let callbackBefore=winwheelToDrawDuringAnimation.animation.callbackBefore;let callbackAfter=winwheelToDrawDuringAnimation.animation.callbackAfter;if(callbackBefore!=null){if(typeof callbackBefore==='function'){callbackBefore();}else{eval(callbackBefore);}}
|
||||
winwheelToDrawDuringAnimation.draw(false);if(callbackAfter!=null){if(typeof callbackAfter==='function'){callbackAfter();}else{eval(callbackAfter);}}
|
||||
if(winwheelToDrawDuringAnimation.animation.callbackSound){winwheelTriggerSound();}}}
|
||||
function winwheelTriggerSound()
|
||||
{if(winwheelToDrawDuringAnimation.hasOwnProperty('_lastSoundTriggerNumber')==false){winwheelToDrawDuringAnimation._lastSoundTriggerNumber=0;}
|
||||
let callbackSound=winwheelToDrawDuringAnimation.animation.callbackSound;let currentTriggerNumber=0;if(winwheelToDrawDuringAnimation.animation.soundTrigger=='pin'){currentTriggerNumber=winwheelToDrawDuringAnimation.getCurrentPinNumber();}else{currentTriggerNumber=winwheelToDrawDuringAnimation.getIndicatedSegmentNumber();}
|
||||
if(currentTriggerNumber!=winwheelToDrawDuringAnimation._lastSoundTriggerNumber){if(typeof callbackSound==='function'){callbackSound();}else{eval(callbackSound);}
|
||||
winwheelToDrawDuringAnimation._lastSoundTriggerNumber=currentTriggerNumber;}}
|
||||
let winwheelToDrawDuringAnimation=null;function winwheelStopAnimation(canCallback)
|
||||
{if(canCallback!=false){let callback=winwheelToDrawDuringAnimation.animation.callbackFinished;if(callback!=null){if(typeof callback==='function'){callback(winwheelToDrawDuringAnimation.getIndicatedSegment());}else{eval(callback);}}}}
|
||||
let winhweelAlreadyDrawn=false;function winwheelLoadedImage()
|
||||
{if(winhweelAlreadyDrawn==false){let winwheelImageLoadCount=0;for(let i=1;i<=winwheelToDrawDuringAnimation.numSegments;i++){if((winwheelToDrawDuringAnimation.segments[i].imgData!=null)&&(winwheelToDrawDuringAnimation.segments[i].imgData.height)){winwheelImageLoadCount++;}}
|
||||
if(winwheelImageLoadCount==winwheelToDrawDuringAnimation.numSegments){winhweelAlreadyDrawn=true;winwheelToDrawDuringAnimation.draw();}}}
|
||||
function winwheelResize()
|
||||
{let margin=40;if(typeof(winwheelToDrawDuringAnimation._responsiveMargin)!=='undefined'){margin=winwheelToDrawDuringAnimation._responsiveMargin;}
|
||||
let width=window.innerWidth-margin;let minWidth=winwheelToDrawDuringAnimation._responsiveMinWidth;let minHeight=winwheelToDrawDuringAnimation._responsiveMinHeight;if(width<minWidth){width=minWidth;}else if(width>winwheelToDrawDuringAnimation._originalCanvasWidth){width=winwheelToDrawDuringAnimation._originalCanvasWidth;}
|
||||
let percent=(width/winwheelToDrawDuringAnimation._originalCanvasWidth);winwheelToDrawDuringAnimation.canvas.width=(winwheelToDrawDuringAnimation._originalCanvasWidth*percent);if(winwheelToDrawDuringAnimation._responsiveScaleHeight){let height=(winwheelToDrawDuringAnimation._originalCanvasHeight*percent);if(height<minHeight){height=minHeight;}else if(height>winwheelToDrawDuringAnimation._originalCanvasHeight){height=winwheelToDrawDuringAnimation._originalCanvasHeight;}
|
||||
winwheelToDrawDuringAnimation.canvas.height=height;}
|
||||
winwheelToDrawDuringAnimation.scaleFactor=percent;winwheelToDrawDuringAnimation.draw();}
|
@ -0,0 +1 @@
|
||||
.elementor-443 .elementor-element.elementor-element-55a9332{padding:0}.elementor-443 .elementor-element.elementor-element-976a94c>.elementor-element-populated{padding:10px}.elementor-443 .elementor-element.elementor-element-bffad37 .hfe-copyright-wrapper{text-align:center}@media(max-width:1024px){.elementor-443 .elementor-element.elementor-element-55a9332{padding:20px}}@media(max-width:767px){.elementor-443 .elementor-element.elementor-element-bffad37 .hfe-copyright-wrapper{text-align:center}}
|
BIN
bocciofila/bravifatelogirare.ogg
Normal file
BIN
bocciofila/bravifatelogirare.ogg
Normal file
Binary file not shown.
BIN
bocciofila/cheers/1.ogg
Normal file
BIN
bocciofila/cheers/1.ogg
Normal file
Binary file not shown.
BIN
bocciofila/cheers/10.ogg
Normal file
BIN
bocciofila/cheers/10.ogg
Normal file
Binary file not shown.
BIN
bocciofila/cheers/11.ogg
Normal file
BIN
bocciofila/cheers/11.ogg
Normal file
Binary file not shown.
BIN
bocciofila/cheers/12.ogg
Normal file
BIN
bocciofila/cheers/12.ogg
Normal file
Binary file not shown.
BIN
bocciofila/cheers/13.ogg
Normal file
BIN
bocciofila/cheers/13.ogg
Normal file
Binary file not shown.
BIN
bocciofila/cheers/14.ogg
Normal file
BIN
bocciofila/cheers/14.ogg
Normal file
Binary file not shown.
BIN
bocciofila/cheers/2.ogg
Normal file
BIN
bocciofila/cheers/2.ogg
Normal file
Binary file not shown.
BIN
bocciofila/cheers/3.ogg
Normal file
BIN
bocciofila/cheers/3.ogg
Normal file
Binary file not shown.
BIN
bocciofila/cheers/4.ogg
Normal file
BIN
bocciofila/cheers/4.ogg
Normal file
Binary file not shown.
BIN
bocciofila/cheers/5.ogg
Normal file
BIN
bocciofila/cheers/5.ogg
Normal file
Binary file not shown.
BIN
bocciofila/cheers/6.ogg
Normal file
BIN
bocciofila/cheers/6.ogg
Normal file
Binary file not shown.
BIN
bocciofila/cheers/7.ogg
Normal file
BIN
bocciofila/cheers/7.ogg
Normal file
Binary file not shown.
BIN
bocciofila/cheers/8.ogg
Normal file
BIN
bocciofila/cheers/8.ogg
Normal file
Binary file not shown.
BIN
bocciofila/cheers/9.ogg
Normal file
BIN
bocciofila/cheers/9.ogg
Normal file
Binary file not shown.
11
bocciofila/confetti.css
Normal file
11
bocciofila/confetti.css
Normal file
@ -0,0 +1,11 @@
|
||||
.confetti{
|
||||
max-width: 640px;
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
border: 1px solid #ddd;
|
||||
user-select: none;
|
||||
}
|
||||
#wheel-container {
|
||||
position: relative;
|
||||
left: 30%;
|
||||
}
|
180
bocciofila/confetti.js
Normal file
180
bocciofila/confetti.js
Normal file
@ -0,0 +1,180 @@
|
||||
//-----------Var Inits--------------
|
||||
canvas = document.getElementById("confetti");
|
||||
ctx = canvas.getContext("2d");
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
cx = ctx.canvas.width / 2;
|
||||
cy = ctx.canvas.height / 2;
|
||||
|
||||
let confetti = [];
|
||||
const confettiCount = 300;
|
||||
const gravity = 0.5;
|
||||
const terminalVelocity = 5;
|
||||
const drag = 0.075;
|
||||
const colors = [
|
||||
{ front: 'red', back: 'darkred' },
|
||||
{ front: 'green', back: 'darkgreen' },
|
||||
{ front: 'blue', back: 'darkblue' },
|
||||
{ front: 'yellow', back: 'darkyellow' },
|
||||
{ front: 'orange', back: 'darkorange' },
|
||||
{ front: 'pink', back: 'darkpink' },
|
||||
{ front: 'purple', back: 'darkpurple' },
|
||||
{ front: 'turquoise', back: 'darkturquoise' }];
|
||||
|
||||
|
||||
//-----------Functions--------------
|
||||
resizeCanvas = () => {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
cx = ctx.canvas.width / 2;
|
||||
cy = ctx.canvas.height / 2;
|
||||
};
|
||||
|
||||
randomRange = (min, max) => Math.random() * (max - min) + min;
|
||||
|
||||
initConfetti = () => {
|
||||
for (let i = 0; i < confettiCount; i++) {
|
||||
confetti.push({
|
||||
color: colors[Math.floor(randomRange(0, colors.length))],
|
||||
dimensions: {
|
||||
x: randomRange(10, 20),
|
||||
y: randomRange(10, 30) },
|
||||
|
||||
position: {
|
||||
x: randomRange(0, canvas.width),
|
||||
y: canvas.height - 1 },
|
||||
|
||||
rotation: randomRange(0, 2 * Math.PI),
|
||||
scale: {
|
||||
x: 1,
|
||||
y: 1 },
|
||||
|
||||
velocity: {
|
||||
x: randomRange(-25, 25),
|
||||
y: randomRange(0, -50) } });
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
//---------Render-----------
|
||||
function render (canvas) {
|
||||
|
||||
let ctx = canvas.getContext('2d');
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
let cx = ctx.canvas.width / 2;
|
||||
let cy = ctx.canvas.height / 2;
|
||||
|
||||
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
confetti.forEach((confetto, index) => {
|
||||
let width = confetto.dimensions.x * confetto.scale.x;
|
||||
let height = confetto.dimensions.y * confetto.scale.y;
|
||||
|
||||
// Move canvas to position and rotate
|
||||
ctx.translate(confetto.position.x, confetto.position.y);
|
||||
ctx.rotate(confetto.rotation);
|
||||
|
||||
// Apply forces to velocity
|
||||
confetto.velocity.x -= confetto.velocity.x * drag;
|
||||
confetto.velocity.y = Math.min(confetto.velocity.y + gravity, terminalVelocity);
|
||||
confetto.velocity.x += Math.random() > 0.5 ? Math.random() : -Math.random();
|
||||
|
||||
// Set position
|
||||
confetto.position.x += confetto.velocity.x;
|
||||
confetto.position.y += confetto.velocity.y;
|
||||
|
||||
// Delete confetti when out of frame
|
||||
if (confetto.position.y >= canvas.height) confetti.splice(index, 1);
|
||||
|
||||
// Loop confetto x position
|
||||
if (confetto.position.x > canvas.width) confetto.position.x = 0;
|
||||
if (confetto.position.x < 0) confetto.position.x = canvas.width;
|
||||
|
||||
// Spin confetto by scaling y
|
||||
confetto.scale.y = Math.cos(confetto.position.y * 0.1);
|
||||
ctx.fillStyle = confetto.scale.y > 0 ? confetto.color.front : confetto.color.back;
|
||||
|
||||
// Draw confetti
|
||||
ctx.fillRect(-width / 2, -height / 2, width, height);
|
||||
|
||||
// Reset transform matrix
|
||||
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||||
});
|
||||
|
||||
// Fire off another round of confetti
|
||||
// if (confetti.length <= 10) initConfetti();
|
||||
|
||||
window.requestAnimationFrame(function() {render(canvas); });
|
||||
};
|
||||
|
||||
//---------Execution--------
|
||||
// initConfetti();
|
||||
// render();
|
||||
|
||||
//----------Resize----------
|
||||
window.addEventListener('resize', function () {
|
||||
resizeCanvas();
|
||||
});
|
||||
|
||||
//------------Click------------
|
||||
// window.addEventListener('click', function () {
|
||||
// initConfetti();
|
||||
// });
|
||||
function renderAnimation() {
|
||||
// Create a new canvas element
|
||||
var canvas = document.createElement('canvas');
|
||||
|
||||
// Set the canvas position to be fixed, covering the entire viewport
|
||||
canvas.style.position = 'fixed';
|
||||
canvas.style.top = '0';
|
||||
canvas.style.left = '0';
|
||||
canvas.style.width = '100%';
|
||||
canvas.style.height = '100%';
|
||||
|
||||
// Make sure the canvas is displayed on top of other elements
|
||||
canvas.style.zIndex = '9999';
|
||||
|
||||
// Append the canvas to the document body
|
||||
document.body.appendChild(canvas);
|
||||
|
||||
// Get the rendering context for the canvas
|
||||
let ctx = canvas.getContext('2d');
|
||||
|
||||
// Perform your animation logic here using the ctx object
|
||||
|
||||
// Example animation: drawing a red circle that moves diagonally
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var radius = 50;
|
||||
|
||||
initConfetti();
|
||||
render(canvas);
|
||||
|
||||
// Add a delay before removing the canvas (adjust the delay time as needed)
|
||||
setTimeout(function() {
|
||||
// Remove the canvas from the document body
|
||||
document.body.removeChild(canvas);
|
||||
}, 15000); // Animation duration in milliseconds
|
||||
}
|
||||
|
||||
function disableScroll() {
|
||||
document.addEventListener('wheel', preventDefault);
|
||||
document.addEventListener('touchmove', preventDefault);
|
||||
document.addEventListener('keydown', preventDefault);
|
||||
}
|
||||
|
||||
function enableScroll() {
|
||||
document.removeEventListener('wheel', preventDefault);
|
||||
document.removeEventListener('touchmove', preventDefault);
|
||||
document.removeEventListener('keydown', preventDefault);
|
||||
}
|
||||
|
||||
function preventDefault(event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// Call disableScroll() to disable scrolling
|
||||
disableScroll();
|
19
bocciofila/cori.js
Normal file
19
bocciofila/cori.js
Normal file
@ -0,0 +1,19 @@
|
||||
var audioFiles = [];
|
||||
var numAudioFiles = 14;
|
||||
|
||||
// Preload the audio files
|
||||
for (var i = 1; i <= numAudioFiles; i++) {
|
||||
var coro = new Audio("cheers/" + i + ".ogg");
|
||||
audioFiles.push(coro);
|
||||
}
|
||||
|
||||
function coro() {
|
||||
// Generate a random index between 0 and the number of audio files
|
||||
var randomIndex = Math.floor(Math.random() * numAudioFiles);
|
||||
|
||||
// Get the randomly selected audio from the array
|
||||
var c = audioFiles[randomIndex];
|
||||
|
||||
// Play the audio
|
||||
c.play();
|
||||
}
|
2
bocciofila/frontend.min.js
vendored
Normal file
2
bocciofila/frontend.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
22
bocciofila/index.html
Normal file
22
bocciofila/index.html
Normal file
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Giochi della Ruota</title>
|
||||
<link rel="stylesheet" href="style2.css">
|
||||
</head>
|
||||
<body>
|
||||
<button id="startButton">Avvia il gioco</button>
|
||||
|
||||
<div id="gameContainer">
|
||||
<video id="gameVideo" controls>
|
||||
<source src="audiovideo.webm" type="video/mp4">
|
||||
</video>
|
||||
<div id="wheel"></div>
|
||||
</div>
|
||||
<div>
|
||||
<!-- <iframe id="gameIframe" src="./ruota.html" width="100%" height="100%" scrolling="no" frameborder="0"></iframe> -->
|
||||
</div>
|
||||
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
2
bocciofila/jquery.cookie.min.js
vendored
Normal file
2
bocciofila/jquery.cookie.min.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/*! jquery.cookie v1.4.1 | MIT */
|
||||
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?a(require("jquery")):a(jQuery)}(function(a){function b(a){return h.raw?a:encodeURIComponent(a)}function c(a){return h.raw?a:decodeURIComponent(a)}function d(a){return b(h.json?JSON.stringify(a):String(a))}function e(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return a=decodeURIComponent(a.replace(g," ")),h.json?JSON.parse(a):a}catch(b){}}function f(b,c){var d=h.raw?b:e(b);return a.isFunction(c)?c(d):d}var g=/\+/g,h=a.cookie=function(e,g,i){if(void 0!==g&&!a.isFunction(g)){if(i=a.extend({},h.defaults,i),"number"==typeof i.expires){var j=i.expires,k=i.expires=new Date;k.setTime(+k+864e5*j)}return document.cookie=[b(e),"=",d(g),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}for(var l=e?void 0:{},m=document.cookie?document.cookie.split("; "):[],n=0,o=m.length;o>n;n++){var p=m[n].split("="),q=c(p.shift()),r=p.join("=");if(e&&e===q){l=f(r,g);break}e||void 0===(r=f(r))||(l[q]=r)}return l};h.defaults={},a.removeCookie=function(b,c){return void 0===a.cookie(b)?!1:(a.cookie(b,"",a.extend({},c,{expires:-1})),!a.cookie(b))}});
|
5
bocciofila/jquery.min.js
vendored
Normal file
5
bocciofila/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3
bocciofila/jquery.min_002.js
Normal file
3
bocciofila/jquery.min_002.js
Normal file
File diff suppressed because one or more lines are too long
55
bocciofila/lasfida.py
Normal file
55
bocciofila/lasfida.py
Normal file
@ -0,0 +1,55 @@
|
||||
import random
|
||||
|
||||
a = """La povertà è una brutta bestia ma ti fa scoprire la solidarietà.
|
||||
Il tuo compagno di ponte Riccardo condivide un cicchetto di colluttorio con te"""
|
||||
|
||||
PENITENZE = [
|
||||
"X punti",
|
||||
"X punti per te e Riccardo",
|
||||
"X punti per te e un altro infame",
|
||||
"-X punti per Riccardo",
|
||||
"-X punti per te e Riccardo",
|
||||
"Sei ignorante, lanciagli il pezzo che hai appena estratto. Se non cade a terra, Ieso fa X punti",
|
||||
"Sei horny per Riccardo e glielo devi far capire. Mano sulla coscia",
|
||||
"Fai il pappagallo",
|
||||
"Sei il gemello di Riccardo. Fai tutto quello che fa lui, meglio",
|
||||
"Sei il gemello di Riccardo. Fai tutto quello che fa lui",
|
||||
"Riccardo esprime un desiderio, tu lo realizzi",
|
||||
"Riccardo esprime due desideri, tu ne realizzi uno e fai il possibile per non far avverare l'altro",
|
||||
"Esprimi un desiderio, Riccardo lo avvererà",
|
||||
"COLLUTTORIO",
|
||||
"TRIVIA",
|
||||
"Riccardo è la tua badante",
|
||||
"Fai un complimento a Riccardo, un complimento falso?",
|
||||
"Tu e Riccardo perdete un indumento",
|
||||
"Fai delle flessioni. Riccardo ne farà il doppio",
|
||||
"Sei un genitore severo, ricorda a Riccardo quale scelta sbagliata ha fatto nella vita",
|
||||
"Ruba la sedia a Riccardo, lui sta in piedi per un po'",
|
||||
"Fatti insegnare un coro",
|
||||
"Fatti un selfie",
|
||||
"Fatti mandare una sexy fotina col pelo",
|
||||
"Fatti mandare vocalino sexy prima di andare a dormire stanotte",
|
||||
"Gli USA sono un paese pericoloso. Spiegagli perchè farà una brutta fine",
|
||||
]
|
||||
|
||||
PERIOD = 12
|
||||
def perform_extraction(nround: int, requirements: set):
|
||||
assert(nround < PERIOD)
|
||||
assert(nround > 0)
|
||||
|
||||
range_ = 100 / (PERIOD - len(requirements)) * nround
|
||||
r = random.uniform(0, 100)
|
||||
if r < range_:
|
||||
return random.choice(requirements)
|
||||
else:
|
||||
return random.choice(PENITENZE)
|
||||
|
||||
def advance(nround: int, last_choices: list):
|
||||
return None
|
||||
|
||||
|
||||
# Requisiti:
|
||||
# - ogni 12 estrazioni si deve garantire che almeno una di queste abbia risultato TRIVIA
|
||||
# - ogni 12 estrazioni si deve garantire che almeno tre di queste abbiano risultato X
|
||||
# - il risultato COLLUTTORIO può capitare solo una volta ogni 80 estrazioni
|
||||
# - il risultato delle precedenti 6 estrazioni non si ripete, eccetto che per risultato X
|
BIN
bocciofila/mancini.mp4
Normal file
BIN
bocciofila/mancini.mp4
Normal file
Binary file not shown.
2
bocciofila/preloaded-modules.min.js
vendored
Normal file
2
bocciofila/preloaded-modules.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
494
bocciofila/ruota.html
Normal file
494
bocciofila/ruota.html
Normal file
File diff suppressed because one or more lines are too long
74
bocciofila/script.js
Normal file
74
bocciofila/script.js
Normal file
@ -0,0 +1,74 @@
|
||||
// Aspetta che il documento HTML sia completamente caricato prima di eseguire lo script
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
// Ottieni il riferimento al pulsante di avvio del gioco
|
||||
var startButton = document.getElementById("startButton");
|
||||
|
||||
// Aggiungi un gestore di eventi al pulsante di avvio
|
||||
startButton.addEventListener("click", function() {
|
||||
// Nascondi il pulsante di avvio
|
||||
startButton.style.display = "none";
|
||||
|
||||
// Ottieni il riferimento al contenitore del gioco
|
||||
var gameContainer = document.getElementById("gameContainer");
|
||||
var ruota = document.getElementById("gameIframe");
|
||||
|
||||
// Mostra il contenitore del gioco
|
||||
gameContainer.style.display = "block";
|
||||
var ruota = document.getElementById("block");
|
||||
|
||||
// Ottieni il riferimento al video del gioco
|
||||
var gameVideo = document.getElementById("gameVideo");
|
||||
|
||||
// Avvia il video
|
||||
gameVideo.play();
|
||||
|
||||
// Aggiungi una classe CSS per far girare la ruota
|
||||
gameContainer.classList.add("spin");
|
||||
loadIframeWithTimeout();
|
||||
});
|
||||
});
|
||||
|
||||
function loadIframeWithTimeout() {
|
||||
// Specify the timeout duration in milliseconds (e.g., 3000ms = 3 seconds)
|
||||
var timeoutDuration = 0;
|
||||
|
||||
// Wait for the specified timeout
|
||||
setTimeout(function() {
|
||||
// Create the iframe element
|
||||
var iframe = document.createElement('iframe');
|
||||
|
||||
// Set the source URL of the iframe
|
||||
iframe.src = './ruota.html';
|
||||
|
||||
// Set the desired attributes for the iframe
|
||||
iframe.width = '100%';
|
||||
iframe.height = '100%';
|
||||
iframe.frameBorder = '0';
|
||||
// Apply CSS styles to cut the left part and center the iframe
|
||||
iframe.style.position = 'absolute';
|
||||
// iframe.style.left = '50%';
|
||||
// iframe.style.transform = 'translateX(-50%)';
|
||||
|
||||
// Append the iframe to the bottom of the document body
|
||||
document.body.appendChild(iframe);
|
||||
console.log("loaded");
|
||||
}, timeoutDuration);
|
||||
}
|
||||
function disableScroll() {
|
||||
document.addEventListener('wheel', preventDefault);
|
||||
document.addEventListener('touchmove', preventDefault);
|
||||
document.addEventListener('keydown', preventDefault);
|
||||
}
|
||||
|
||||
function enableScroll() {
|
||||
document.removeEventListener('wheel', preventDefault);
|
||||
document.removeEventListener('touchmove', preventDefault);
|
||||
document.removeEventListener('keydown', preventDefault);
|
||||
}
|
||||
|
||||
function preventDefault(event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// Call disableScroll() to disable scrolling
|
||||
disableScroll();
|
1
bocciofila/script.min.js
vendored
Normal file
1
bocciofila/script.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
27
bocciofila/style2.css
Normal file
27
bocciofila/style2.css
Normal file
@ -0,0 +1,27 @@
|
||||
#gameContainer {
|
||||
width: 400px;
|
||||
height: auto;
|
||||
margin: 0 auto; /* Centers the container horizontally */
|
||||
display: none; /* Hides the container by default */
|
||||
}
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* #gameContainer { */
|
||||
/* position: absolute; */
|
||||
/* top: 0; */
|
||||
/* left: 0; */
|
||||
/* width: 100%; */
|
||||
/* height: 100%; */
|
||||
/* } */
|
||||
|
||||
#gameIframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
/* display: none; /\* Hides the container by default *\/ */
|
||||
margin: 0 auto; /* Centers the container horizontally */
|
||||
}
|
BIN
bocciofila/tick.mp3
Normal file
BIN
bocciofila/tick.mp3
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user