Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2001
    Messaggi
    207

    Disegnare figure geometriche bucate

    Ciao, vorrei disegnare un cerchio bucato (per intenderci una ciambella o meglio una "o") tramite as. La figura mi serve da usare come maschera. Avete qualche idea su come si possa fare?
    Thx

  2. #2
    ciao con questo script, che non e' mio, crei un cerchio con il buco (una ciambella") tutto via AS

    codice:
    //negatyve
    //http://forum.html.it/forum/showthread.php?s=&threadid=811725&perpage=15&highlight=mask&pagenumber=2
    MovieClip.prototype.drawTorus = function(x, y, outerRadius, innerRadius, startAngle, endAngle, segments)
    {
    	var rad = Math.PI / 180;
    	var segm = (endAngle - startAngle) / segments;
    	this.moveTo(x + outerRadius * Math.cos(startAngle * rad), y + outerRadius * Math.sin(startAngle * rad));
    	this.beginFill(0xff0000, 100);
    	for (var s = startAngle + segm; s <= endAngle + 1; s += segm) {
    		var c_x = outerRadius * Math.cos(s * rad);
    		var c_y = outerRadius * Math.sin(s * rad);
    		var a_x = c_x + outerRadius * Math.tan(segm / 2 * rad) * Math.cos((s - 90) * rad);
    		var a_y = c_y + outerRadius * Math.tan(segm / 2 * rad) * Math.sin((s - 90) * rad);
    		this.curveTo(a_x + x, a_y + y, c_x + x, c_y + y);
    	}
    	this.moveTo(x + innerRadius * Math.cos(startAngle * rad), y + innerRadius * Math.sin(startAngle * rad));
    	for (var s = endAngle; s >= 0; s -= segm) {
    		var c_x = innerRadius * Math.cos(s * rad);
    		var c_y = innerRadius * Math.sin(s * rad);
    		var a_x = c_x + innerRadius * Math.tan(segm / 2 * rad) * Math.cos((s + 90) * rad);
    		var a_y = c_y + innerRadius * Math.tan(segm / 2 * rad) * Math.sin((s + 90) * rad);
    		this.curveTo(a_x + x, a_y + y, c_x + x, c_y + y);
    	}
    	this.endFill();
    };
    this.createEmptyMovieClip("mask", 1);
    
    mask.drawTorus(220, 130, 100, 70, 0, 360, 8);
    
    mc.setMask(mask)

    -Nextart.it Graphic Solutions

  3. #3
    Utente di HTML.it
    Registrato dal
    Mar 2001
    Messaggi
    207
    Grazie mille, lo script è perfetto!!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.