Skip to content

Instantly share code, notes, and snippets.

@yibing0703
yibing0703 / Particle.js
Created January 15, 2022 06:27 — forked from kathykwang/Particle.js
NOC-Dandelion-Kathy Wang
"use strict";
var coRestitution = 0.018;
var coFriction = 0.01;
class Particle {
constructor(x, y) {
this.pos = createVector(x, y);
this.vel = createVector(random(-10, 10), random(-10, 10));
this.acc = createVector(0, 0);
@yibing0703
yibing0703 / getSetValueOnLayer.js
Created January 8, 2021 03:16 — forked from sonburn/getSetValueOnLayer.js
Get or set a value on a layer in Sketch
var value = nil,
key = "kModelPropertiesKey",
layer = context.selection[0],
plugin = "com.animaapp.stc-sketch-plugin";
// Get the value
context.command.valueForKey_onLayer_forPluginIdentifier(key,layer,plugin);
// Set the value
context.command.setValue_forKey_onLayer_forPluginIdentifier(value,key,layer,plugin);
// [0] represents first override, replace with appropriate index if other override is desired
symbolInstance.setValue_forOverridePoint("New text", symbolInstance.overridePoints()[0]);
@yibing0703
yibing0703 / macOS 给 Git(Github) 设置代理(HTTP.SSH).md
Last active November 13, 2020 11:10 — forked from chuyik/README.md
macOS 给 Git(Github) 设置代理(HTTP/SSH)
@yibing0703
yibing0703 / panelAnimationExploration.js
Created September 27, 2020 14:37 — forked from KevinGutowski/panelAnimationExploration.js
Trying to get NSPanel to expand downward.
let threadDictionary = NSThread.mainThread().threadDictionary()
let panelID = "com.betterTypePanel.panel"
if (threadDictionary[panelID]) {
let panel = threadDictionary[panelID]
panel.close()
threadDictionary.removeObjectForKey(panelID)
}
var panelWidth = 312
@yibing0703
yibing0703 / menus.js
Created September 27, 2020 14:36 — forked from KevinGutowski/menus.js
Toggling Sketch menu items
let menu = NSApplication.sharedApplication().mainMenu()
let pluginsMenu = menu.itemWithTitle('Plugins').submenu()
let baseAlignPluginMenuItem = pluginsMenu.itemWithTitle('BaseAlign'))
baseAlignPluginMenuItem.setEnabled(false)
baseAlignPluginMenuItem.setState(true)
@yibing0703
yibing0703 / notification.js
Created September 27, 2020 14:23 — forked from KevinGutowski/notification.js
Create a notification within a sketch plugin
let notification = NSUserNotification.alloc().init()
let randomNumber = Math.random()
notification.setIdentifier("com.kevin.testNotification" + randomNumber)
notification.setTitle("Hi there")
notification.setSubtitle("What about this?")
notification.setInformativeText("Your symbol")
notification.setSoundName = NSUserNotificationDefaultSoundName
let notificationCenter = NSUserNotificationCenter.defaultUserNotificationCenter()
notificationCenter.deliverNotification(notification)
@yibing0703
yibing0703 / blurAnimation.js
Created September 27, 2020 14:19 — forked from KevinGutowski/blurAnimation.js
Animating the background blur of a NSView that is layer backed
let threadDictionary = NSThread.mainThread().threadDictionary()
let panelID = "com.betterTypePanel.panel"
if (threadDictionary[panelID]) {
let panel = threadDictionary[panelID]
panel.close()
threadDictionary.removeObjectForKey(panelID)
}
var panelWidth = 312
@yibing0703
yibing0703 / panel.js
Created September 27, 2020 14:08 — forked from KevinGutowski/panel.js
Creating a Sketch NSPanel
export function runPanel() {
let threadDictionary = NSThread.mainThread().threadDictionary()
let identifier = "co.yourIdentifier"
// If there is already a panel, prevent the plugin from running again
if (threadDictionary[identifier]) return
threadDictionary.panelOpen = true
setupPanel(threadDictionary, identifier)
}
@yibing0703
yibing0703 / Load Preview.js
Created September 26, 2020 15:44 — forked from KevinGutowski/Load Preview.js
Replicating Sketch's Preview window
let previewWindow = NSApplication.sharedApplication().windows().find(window => window.title() == 'Preview')
let webview = previewWindow.contentView().subviews()[1] // need to launch sketch preview in order to find the proper webview and to start up the sketch server
let threadDictionary = NSThread.mainThread().threadDictionary()
let panelID = "com.testPanel"
if (threadDictionary[panelID]) {
let panel = threadDictionary[panelID]
panel.close()
threadDictionary.removeObjectForKey(panelID)