HISE Logo Forum
    • Categories
    • Register
    • Login
    1. HISE
    2. civet
    3. Best
    C
    • Profile
    • Following 0
    • Followers 0
    • Topics 10
    • Posts 38
    • Groups 0

    Posts

    Recent Best Controversial
    • RE: Funny slider?

      @IsoWalle My funny dirty code is here:

      Content.makeFrontInterface(400, 400);
      
      // distance squared
      inline function distance2(p0, p1)
      {
      	local dx = p1.x - p0.x;
      	local dy = p1.y - p0.y;
      	return dx * dx + dy * dy;
      }
      
      // angle between two points
      inline function angleBetween(p0, p1)
      {
      	local dx = p1.x - p0.x;
      	local dy = p1.y - p0.y;
      	// convert atan() to atan2()
      	local a = Math.atan(dy / dx);
      	if(dx > 0)
      	{
      		if(dy < 0) 
      			a += Math.PI;
      		else
      			a -= Math.PI;
      	}
      	return a;
      }
      
      const var points = [
      	{x: 200, y: 102},
      	{x: 100, y: 275},
      	{x: 300, y: 275}
      ];
      const var radius = 200;
      const var radius2 = radius * radius;
      
      reg dragger = {x: 200, y: 217};
      reg draggerRadius = 10;
      reg values = [0.0, 0.0, 0.0];
      reg valueIndex = 0;
      
      const var canvas = Content.addPanel("canvas", 0, 0);
      Content.setPropertiesFromJSON("canvas", {
      	"width": 400,
      	"height": 400,
      	"allowCallbacks": "Clicks, Hover & Dragging"
      });
      
      canvas.setPaintRoutine(function(g) 
      {	
      	// draw guides
      	g.setColour(0x40FFFFFF);
      	for(p in points)
      	{
      		g.drawEllipse([p.x - radius, p.y - radius, radius * 2, radius * 2], 1);
      		
      		g.fillEllipse([p.x - 2, p.y - 2, 4, 4]);
      	}
      	
      	// draw dragger
      	g.setColour(0xFFFFFFFF);
      	g.fillEllipse([dragger.x - draggerRadius, dragger.y - draggerRadius, draggerRadius * 2, draggerRadius * 2]);
      });
      
      canvas.setMouseCallback(function(event)
      {
      	if(event.drag)
      	{
      		dragger.x = event.x;
      		dragger.y = event.y;
      		
      		// limit the drag area
      		for(p in points)
      		{
      			if(distance2(dragger, p) >= radius2)
      			{
      				var a = angleBetween(dragger, p);
      				dragger.x = p.x + Math.cos(a) * radius;
      				dragger.y = p.y + Math.sin(a) * radius;	
      			}
      		}
      		
      		canvas.repaint();
      		
      		// calculate distance between points
      		valueIndex = 0;
      		for(p in points)
      		{
      			var d2 = distance2(dragger, p);
      			values[valueIndex] = Math.round((200.0 - Math.sqrt(d2)) / 2);
      			valueIndex++;
      		}
      		Console.print(values.join(", "));
      	}
      });
      
      posted in General Questions
      C
      civet
    • RE: Animate panel colors

      @dustbro @d-healey I found a simple function here to convert decimal to hex string, but it hasn't been fully tested yet.

      inline function toHex(num, digits) 
      {
      	local hexTable = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
      	local n = num;
      	local s = digits;
      	local result = "";
      	while (s--)
      	{
      		result = hexTable[n & 0xF] + result;
      		n = n >> 4;
      	}
      	return result;
      }
      
      Console.print(toHex(4278221567, 8)); 
      // output: FF007AFF
      

      By the way, using HSV or HSL makes it easier to control color variations, just change the value of Hue as you did in the colorpicker.
      You may need to use some functions that convert between RGB and HSV/HSL.

      posted in Scripting
      C
      civet
    • RE: Funny slider?

      @IsoWalle said in Funny slider?:

      @civet I tried messing around a little with your code and I noticed that it takes the value from where the mouse is and not from where the "dragger" is. So if you click and drag and continue outside the "triangle" the value keeps changing.

      Any way to make it stop?

      Sorry, I just wrote some dirty code to prove that it works.

      It takes more work to finish a custom component, such as redraw the appearance, encapsulation with namespace, configure parameters more flexibly, etc.

      And there are many other implementations.

      I just modified the code and added some comments on it, hope this helps.

      posted in General Questions
      C
      civet
    • RE: Export Samples for Installer - hanging at Compressing 100%

      @d-healey Many thanks for your support.
      I have tried another one.
      Now I can reproduce this issue with a .ch1 file (683MB). I can share it later.

      posted in General Questions
      C
      civet
    • Export Samples for Installer - hanging at Compressing 100%

      20220422.PNG

      It's a large .ch1 file about 1.5GB. No error message in the console.
      I have tried to delete same samples from samplemap to reduce the size of monolith file. ~400MB, 600MB is OK, about 800MB hanging again... has it reached the limit?

      posted in General Questions
      C
      civet
    • Engine.getMidiNoteFromName("G8");

      The missing note?

      Console.print(Engine.getMidiNoteFromName("G8")); // -1
      
      Console.print(Engine.getMidiNoteName(127)); // G8
      
      posted in Bug Reports
      C
      civet
    • RE: How to add table points to a UI table?

      @d-healey

      Content.makeFrontInterface(600, 600);
      
      reg tableData = Engine.createAndRegisterTableData(1);
      
      const var table = Content.getComponent("Table1");
      table.set("saveInPreset", false);
      table.referToData(tableData);
      
      tableData.reset(); 
      tableData.addTablePoint(0.5, 0.5);
      
      posted in Scripting
      C
      civet